jcsp-1.1-rc4.orig/0000755000000000000000000000000011410045055010620 5ustar jcsp-1.1-rc4.orig/overview.html0000644000000000000000000002277111113671251013370 0ustar This document is the specification for the JCSP core API.

JCSP provides a complete library for building complex functionality through layered networks of communicating processes. It conforms to the CSP model of cummunicating systems so that twenty years of theory, tools and practical experience can be brought to bear in the support of Java multi-threaded applications. Newcomers to JCSP should start with the documentation on the {@link org.jcsp.lang.CSProcess CSProcess} interface, which outlines and motivates the notion of components as communicating processes and the process oriented design pattern.

Processes interact solely via CSP synchronising primitives, such as {@link org.jcsp.lang.Channel channels} ({@link org.jcsp.lang.One2OneChannel one-to-one}, {@link org.jcsp.lang.Any2OneChannel any-to-one}, {@link org.jcsp.lang.One2AnyChannel one-to-any}, {@link org.jcsp.lang.Any2AnyChannel any-to-any}), {@link org.jcsp.lang.One2OneCallChannel CALL channels}, {@link org.jcsp.lang.CSTimer timers}, {@link org.jcsp.lang.Crew crews}, {@link org.jcsp.lang.Barrier barriers}, {@link org.jcsp.lang.AltingBarrier alting barriers}, {@link org.jcsp.lang.Bucket buckets} or other well-defined modes of access to shared passive objects. Processes do not invoke each other's methods. Processes may be combined to run in {@link org.jcsp.lang.Sequence sequence} or {@link org.jcsp.lang.Parallel parallel}. Processes may be combined to wait passively on a number of {@link org.jcsp.lang.Alternative alternative} events, with one of them trigered into action only by the external generation of that event. Such collections of events may be serviced either {@link org.jcsp.lang.Alternative#fairSelect() fairly} (guaranteeing no starvation of one event by the repeated arrival of its siblings), by any user-defined {@link org.jcsp.lang.Alternative#priSelect() priority} or in an {@link org.jcsp.lang.Alternative#select() arbitrary} manner.

JCSP is an alternative to the built-in monitor model for Java threads. JCSP primitives should not normally be mixed into designs with synchronized method declarations, instances of the java.lang.Runnable interface or java.lang.Thread class, or invocations of the wait/notify/notifyAll methods from java.lang.Object.

However, JCSP is compatible with the built-in model and, with care, can be mixed safely and profitably. In particular, process communication via wait-free synchronized method invocations on a shared passive object directly implements a common CSP server idiom (see {@link org.jcsp.awt.DisplayList DisplayList} for an example). Further, existing libraries that interact with user software via listener registration and callback (such as the standard AWT and Swing) can be easily tailored to operate as processes with channel-based interfaces (for example, see {@link org.jcsp.awt org.jcsp.awt}).

Finally, we note that the JCSP library reflects the occam-pi realisation of CSP and pi-calculus., An occam-pi PROC declaration maps simply into a class implementing {@link org.jcsp.lang.CSProcess CSProcess}, whose constructor parameters mirror the PROC parameters and whose run method mirrors the PROC body.

Acknowledgements

This JCSP library is being developed from work originally carried out and presented by numerous individuals at the WoTUG Java Threads Workshop and conferences (WoTUG-20, WoTUG-21, WoTUG-22, WoTUG-23/CPA-2000, WoTUG-24/CPA-2001, WoTUG-25/CPA-2002, WoTUG-26/CPA-2003, WoTUG-27/CPA-2004, WoTUG-28/CPA-2005, WoTUG-29/CPA-2006, WoTUG-30/CPA-2007, WoTUG-31/CPA-2008) in the period 1996-2008 and continuing. Please follow the links to find the original sources. Special thanks are owed to Paul Austin, who developed the original JCSP library.

References

`Communicating Sequential Processes', C.A.R. Hoare, CACM, 21-8, pp. 666-677, August 1978.
This is the original exposition of CSP. Presentation is largely from the programmer's point of view. The Ada tasking model and the occam/transputer process model were derived from this work.
`Communicating Sequential Processes', C.A.R. Hoare, Prentice Hall, 1985.
This is `the book'. Presentation is more abstract (i.e. mathematical) and a more general theory is given than in the original CACM paper. One crucial difference is that events (and channels) become concepts that are separate from the processes that engage in them. This difference was adopted in the occam/transputer model, but Ada missed out on it. The JCSP library follows the model presented in this book.
`The Theory and Practice of Concurrency', A.W. Roscoe, Prentice Hall, ISBN 0-13-674409-5, 1997.
This brings CSP up to date with refinements developed over the past decade. It is `the new book'.
`Communicating Sequential Processes and Deadlock' J.M.R.Martin, Chapter 1 from his Ph.D thesis ("The Design and Construction of Deadlock-Free Concurrent Systems"), University of Buckingham, UK, 1996.
This gives a crisp, amusing and accurate tour around all the CSP concepts, strongly recommended for beginners and experienced CSP users alike. [Actually only up to (and including) page 11 are for normal mortals - after that it starts to get scary. But those first few pages are a gem.]
`A Classical Mind - Essays in Honour of C.A.R. Hoare', Edited by A.W. Roscoe, Prentice Hall, ISBN 0-13-294844-3, 1994.
Serious bedtime reading.
`Parallel Processing with Communicating Process Architecture', I.R.East, UCL press, ISBN 1-85728-239-6, 1995.
This is an excellent text on how to design and program with the CSP model - many higher level design issues are addressed.
`occam 2 -- including occam 2.1', John Galletly, UCL press, ISBN 1-85728-362-7, 1996.
This is a good textbook on the occam version of the CSP model. A knowledge of occam gives insight that makes multithreading in Java simpler and, hence, safer to manage ;-) ...
`Parallel and Distributed Computing in Education', P.H.Welch, in Proceedings of VecPar'98, Lecture Notes in Computer Science #1573, Springer-Verlag, April 1999.
This is a tutorial introduction to CSP from the point of view of the programmer/designer. JCSP bindings to key examples are given in an appendix. See Abstract.
`Java Threads in the Light of occam/CSP', P.H.Welch, in Architectures, Languages and Patterns for Parallel and Distributed Applications, Proceedings of WoTUG-21, pp. 259-284, IOS Press (Amsterdam), ISBN 90 5199 391 9, April 1998.
This is a tutorial introduction to the Java monitor model. It raises concern over its ease of use and the safety of its standard design patterns, but shows how it may be used to build the CSP primitives. Finally, it revisits those concerns and shows how they fade in the light of CSP. See Abstract.

Request for Feedback

Currently, the more complex the system requirements, the less likely it becomes that concurrency (or multi-threading) play a major role. This is because concurrency is thought to make system design especially hard - so many additional problems (race hazards, deadlock etc.) to worry about. A good model of concurrency, however, should simplify the design, implementation, verification and maintenance of systems. A design goal for our CSP-for-Java collaboration is to enable concurrency to play that natural role. Feedback on moving towards that goal is always welcome.

jcsp-1.1-rc4.orig/README.txt0000644000000000000000000004521311113671251012326 0ustar ============================================================================= CSP for Java : JCSP 1.1 Release Candidate 1 (rc4) ============================================================================= This file contains: o the manifest list of files/directories in this release; o installation notes; o incremental change list since JCSP 0.5. Please read the GNU-LGPL-2.1.txt file. Retention of these files is assumed to imply acceptance of the terms in that license. This release is licenced under the Lesser GNU Public Licence, version 2.1 (LGPL 2.1). A copy is included with the distribution, or you can read an online version at: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html There are rather a lot of deprecated items now in the library. Most of these will be removed in JCSP 1.2. This vew version will contain a completely re-written networking support (org.jcsp.lang.channel). Peter Welch and Neil Brown. (28th. November, 2008) ============================================================================= JCSP 1.1 (rc4) Manifest ============================================================================= jcsp.jar (class library containing all features, both net and core - add either this, or jcsp-core.jar, to your CLASSPATH) jcsp-core.jar (class library containing just the core features - add either this or jcsp.jar to your CLASSPATH) Note: jcsp-core excludes the networking mechanisms (and some other things) contained within jcsp.jar. It is a smaller library for applications running in a single JVM. It efficiently exploits multicore processors. jcsp-demos/ (directory with sources for lots of demos) jcsp-demos-util.jar (addtional class library - needed for the demos) jcsp-doc/ (javadoc HTML tree for jcsp.jar) jcsp-core-doc/ (javadoc HTML tree for jcsp-core.jar) Note: the jcsp-core-doc folder is included so that jcsp-core users are not overloaded with materials they do not use. For either of the above trees, point your browser at the index.html file at their top level. GNU-LGPL-2.1 (open source licence agreement) README-JCSP-1.1-rc4.txt (this file) L-GPL open sources are available from the subversion repository: svn checkout http://projects.cs.kent.ac.uk/projects/jcsp/svn/jcsp/tags/jcsp-1.1-rc4/ You will need the JDK1.3 libraries (or any later JDK) installed to work with the JCSP library. ============================================================================= Installation Notes ============================================================================= Put the file jcsp.jar (or jcsp-core.jar) in your CLASSPATH. You do *not* need to unpack these files. Point your web browser at (and, maybe, bookmark): jcsp-doc/index.html or jcsp-core-doc/index.html for the documentation to the JCSP library. The jcsp-demos directory contains many JCSP demonstration applications and applets. These are not embedded in any Java packages. Each demo is contained in a single sub-directory. To run one, change to that directory, compile (javac *java) and run the main program (which usually has the word "Main" as part of its name). ============================================================================= Change List ============================================================================= Changes since JCSP 1.1 (rc3) release ------------------------------------ At last, the documentation has been changed to conform to the API changes introduced in version 1.1. Many minor bugs fixed. Some new demos added. The documentation of org.jcsp.lang.Channel (from which all channels should be made) and org.jcsp.lang.Poisonable (for simplifying network shut-down) has been finished. There are rather a lot of deprecated items now in the library. Most of these will be removed in JCSP 1.2. This vew version will contain a completely re-written networking support (org.jcsp.lang.channel). Peter Welch and Neil Brown. (28th. November, 2008) Changes since JCSP 1.1 (rc2) release ------------------------------------ Deprecated the remaining old methods of channel creation and fixed some public visibility mistakes. Neil Brown and Peter Welch. (3rd. March, 2008). Changes since JCSP 1.1 (rc1) release ------------------------------------ Deprecated some of the channel factories, and updated the overview of the documentation and this README file. Neil Brown and Peter Welch. (9th. October, 2007). Changes since JCSP 1.0 (rc8) release ------------------------------------ The library has been merged with the old Quickstone version, which includes a great many changes. The channels are now interfaces with hidden implementations, and must be created using methods in the Channel class. The networking aspects from Quickstone's JCSP.NET have been included. Poisonable channels are now included. Many Quickstone classes have been removed (from JCSP.NET; JCSP core users will not notice any difference) or deprecated ready for future removal. Symmetric Object channels have been added. Neil Brown and Peter Welch. (5th. October, 2007). Changes since JCSP 1.0 (rc7) release ------------------------------------ Symmetric channels (One2OneChannelSymmetricInt) added, with demo added to CommsTime (to run with symmetric channels) and a new output-guards demo folder. Peter Welch. (16th. August, 2007) Changes since JCSP 1.0 (rc6) release ------------------------------------ One correction to AltingBarrier. Lots more documentation and examples for AltingBarrier. Minor documentation improvements elsewhere. Some Framed* classes added to jcsp.plugNplay. These wrap some jcsp.awt Active* widgets (buttoms and scrollbars) in frames for immediate use. They are useful for quick demonstrations (and used in the documentation of AltingBarrier). The Parallel class has a new contructor taking a 2D-array of processes. Spurious wakeup protection/logging has been added to the Bucket and Stop classes. These has been overlooked when preparing the rc6 version. Peter Welch. (19th. December, 2006) Changes since JCSP 1.0 (rc5) release ------------------------------------ The introduction of an (experimental) AltingBarrier class. This is a Guard useable for Alternative selections. It implements multiway synchronisation (i.e. a CSP 'event'), allowing all parties to back off choice operations. One party to the AltingBarrier will select it if and only if *all* parties select it. Prioritised choice is not allowed if the choice includes an AltingBarrier, since conflicting priorities would be easy to set up and impossible to resolve. Fair choice is allowed, but only on the understanding that a completed AltingBarrier takes precedence over other typse of Guard (because of the necessity for all parties to the choice making the same one). The Alternative class has had to be modified to support AltingBarriers. This should have negligeable overhead on its operation without AltingBarriers. An AlternativeError class has been added, which is thrown in the attempt to make a prioritised choice over a set of Guards including an AltingBarrier. A JCSP_InternalError class has been added. This is thrown if an internal inconsistency is detected. Currently, this is used for defensive programming only of the AltingBarrier (which, we stress, is experimental). Spurious wakeup protection has been added to all blocking methods (channel communications, barrier synchronisation, alting, etc.). These are implemented with invocations of "Object.wait()". The Java specification has always included a footnote that those calls may "spuriously" return for no proper reason (where "proper" means being released through an "Object.notify()", "Object.notifyAll()", an "InterruptedException" or a timeout)! There was no mention of this danger in the (javadoc) documentation in JDK 1.3 and earlier versions. The danger is heavily emphasised in the documentation for JDK 1.5, so we thought we should take it seriously. Spurious wakeup protection requires a few extra fields in some of the classes and extra work (and ugly code) at run-time -- but these overheads are pretty slight. Optional logging of detected spurious wakeups is provided (see the "SpuriousLog"). Running stress tests on Sun's JVMs, with logging switched on, has *never* shown any! It has long been known that "early" timeouts (from "Object.wait(long)") occur and JCSP has always allowed them. The above logging mechanism also reports counts of these -- and they occur frequently. The acceptable margin for "early" timeouts may be set by "SpuriousLog.setEarlyTimeout(long)"; by default, that margin is set to 9 milliseconds (which covers most of those encountered using Sun's JVMs). Timeouts returning earlier than the acceptable margin are treated as spurious wakeups and the timeout is reset. A margin of zero may be defined, but that would lead to many re-timeouts that are not really needed -- note that JCSP running on standard JVMs should not be used for critical ("hard") real-time applications. Peter Welch. (6th. January, 2006) and (19th. December, 2006) Changes since JCSP 1.0 (rc4) release ------------------------------------ First, many apologies for the long interval sine the last release. We are very positive about this work, but have been concentrating our time on developing the occam-pi language and supporting infrastructure. occam-pi and JCSP are closely related - common goals, differing technologies. Anyone interested in finding more about occam-pi, please check out: http://www.cs.kent.ac.uk/projects/ofa/kroc/ (motivation and download) http://frmb.org/occ21-extensions.html (summary of extensions over occam2.1) http://rmox.net/prelude/ (experimental OS) Back to JCSP! This release is mostly just maintenance over rc4, with several sets of classes re-implemented for better efficiency and security (i.e. no semantic change). Some changes have been made though: o several more items have been deprecated: interfaces: jcsp.lang.Channel, jcsp.lang.ChannelInt. Note: these are just the union of their separate input/output classes: jcsp.lang.Channel = jcsp.lang.ChannelInput union jcsp.lang.ChannelOutput jcsp.lang.ChannelInt = jcsp.lang.ChannelInputInt union jcsp.lang.ChannelOutputInt They are never needed! Such interfaces are used for the parameters of CSProcess class constructors and should only hold one end (either input ot output, but not both!) of the channel plugged in to any given instance. Any other use is misconceived. We are afraid that some pieces of JCSP documentation incorrectly used these interfaces. This have been corrected in this release. abstract classes: jcsp.lang.AltingChannel, jcsp.lang.AltingChannelInt. Note: these are deprecated for exactly the same reasons as above. Use AltingChannelInput, respectively AltingChannelInputInt, instead for input channels that need to support ALTing - or ChannelOutput, respectively ChannelOutputInt, for output channels. General note about the above deprecated items: THEY WILL BE REMOVED from the final 1.0 release! That will be a merger with the full JCSP Network Edition i from Quickstone (http://www.quickstone.com/xcsp/jcspnetworkedition/). This has a cleaner (more systematic) way for creating the wide variety of channels supported and we want the name "Channel" as the right name for the class of static `factory' methods. Other changes: o a bunch of deprecated items have now been removed: methods: jcsp.lang.Alternative.select (AltingChannelInput[], ...) etc.. Note: Alternative classes *must* now be constructed bound to their Guard arrays - so there is no need to suppy those to their select methods. constructors: jcsp.lang.Alternative (). Note: use jcsp.lang.Alternative (Guard[] guard) instead - see above. constructors: jcsp.lang.Any2AnyChannel(ChannelDataStore) etc.. Note: all deprecated channel constructors taking ChannelDataStore or ChannelDataStoreInt have been removed. Use the static create methods instead. This removal was needed for technical reasons for improving the efiiciency of default channels (i.e. those without ChannelDataStore buffers). As mentioned in the "General note" above, all channel creation in future releases will be via the Channel static create methods. o a bug fix: class: jcsp.lang.Stop. Note: this simple class was included for completeness - it is one of the primitives of CSP. It never occurred to us that anyone would need to use it and it was never tested! But someone did use it. It carried a very stupid bug - now exterminated. Peter Welch (5th. September, 2005) Changes since JCSP 1.0 (rc3) release ------------------------------------ o Minor corrections and changes to a (very) few of the documentation files. o A new demo - MultiPong :-) o A modified demo - Infection. This has more controls and interaction. See how hard it is fighting (say) Foot-and-Mouth by culling neighbouring animals when the effectiveness of the cull is only 99% ... Peter Welch. (13th. July, 2001) Changes since JCSP 1.0 (rc2) release ------------------------------------ o Fixed bug in jcsp.util.Buffer and jcsp.util.ints.BufferInt. When we tried to create a buffered channel of size n, we used to get one of size (n+1). The channel buffer is now created correctly with the requested size. o Fixed bug in jcsp.awt.GraphicsCommand.DrawArc and jcsp.awt.GraphicsCommand.FillArc. A typing error had omitted startAngle and arcAngle from the constructor's parameter list. It compiled OK under JDK1.2 (but couldn't work correctly). The JDK1.3 compiler was more thorough and, quite properly, rejected it. All is well now. o Several additions to the documentation. In particular, the top-level javadoc page points new users to the documentation in the jcsp.lang.CSProcess interface - where there is an overview of (Communicating Sequential) Process Oriented Design and the implementation pattern for a JCSP process. o Modified Binary Code License (that explicitly allows redistribution of JCSP classes as part of users' applications/applets). Peter Welch. (7th. February, 2001) Changes since JCSP 1.0 (rc1) release ------------------------------------ o Change of name of the "Timer" class in jcsp.lang to "CSTimer". This has been caused by the JDK1.3 release from Sun introducing their own classes called "Timer" in packages java.util and javax.swing. Without this name change, applications importing both jcsp.lang.* and java.util.* (or javax.swing*) would have to qualify declarations and constructions of "Timer" variables and objects - e.g: jcsp.lang.Timer tim = new jcsp.lang.Timer (); With this name change, even if both jcsp.lang.* and java.util.* are imported, we may declare JCSP timers without qualification - e.g: CSTimer tim = new CSTimer tim (); Note that the JDK1.3 java.util.Timer is a very different class from CSTimer. Warning: the old jcsp.lang.Timer has been deleted from this release - not deprecated. If it had just been deprecated, importing java.util.* would still require full qualification for references to its Timers. This means existing JCSP applications using JCSP timers will have to change all occurrences of "Timer" to "CSTimer" - many apologies. Aside: avoidance of a name clash was the reason why JCSP has the "CSProcess" interface, rather than just "Process". There has always been a "Process" class defined in java.lang (again with a very different purpose from ours). o Some improvements to various items in the documentation. o Re-packaging of the release as a single JAR file. o A new applet/application demo - Fireworks! Peter Welch. (11th. August, 2000) Changes since JCSP 0.95 release ------------------------------- o Change of name of the "Many2..." and "...2Many" channel classes. These have been changed to "Any2..." and "...2Any" channels. The "Any" names better reflect the semantics of these channels. ["Many" implied some kind of broadcast - which is not what these channels do.] This has been an outstanding request for some time. The old class names have not simply been deprecated - they have been deleted! The jcsp.lang section of the library would have become embarassingly top heavy with deprecated classes if they had been retained. Apologies to those who may need to make a lot of edits. I have a simple Unix cshell script that will make these edits to all .java files in, or below, a named directory. Please mail me (P.H.Welch@ukc.ac.uk) if you need it! o The bucket synchronisation primitive; o Generation of a jcsp.lang.ProcessInterruptedError if any process, blocked on a JCSP synchonisation primitive, is interrupted. This is not allowed (and is always a panic-induced design error). The error does not need to be caught (and, indeed, should *not* be caught) with a try-catch clutter surrounding the JCSP synchonisation. o Minor tweaks to the documentation (as ever). Peter Welch. (3rd. November, 1999) Changes since JCSP 0.94 release ------------------------------- o Links to Sun's JDK1.2 documentation (from the JCSP documentation) are now in place; o Minor tightening up of the ChannelAccept interface (for CALL channels) to enable the compiler to trap erroneous accepts - no effect on correct programs; o Minor tweaks to the documentation. Peter Welch. (28th. October, 1999) Changes since JCSP 0.5 release ------------------------------ o A more flexible API for ALTing; o Numerous new facilities (and some deprecated old ones); o More and better (javadoc)umentation - including several mini-tutorials. JCSP documentation is now produced using the JDK 1.2 javadoc tool; o More demonstration applications and applets; o (occam3) CALL channels; o Barrier and CREW synchronisation primitives; o Various pieces of maintenance. A source release will be made available shortly under either the GPL or Artistic open source licences. Please contact me (P.H.Welch@ukc.ac.uk). I *hope* to freeze this into a JCSP 1.0 release *shortly* and update the JCSP web pages suitably - at present, these offer only JCSP 0.5. Peter Welch. (28th. October, 1999) jcsp-1.1-rc4.orig/.project0000644000000000000000000000060211072626250012273 0ustar JCSP Trunk org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature jcsp-1.1-rc4.orig/.classpath0000644000000000000000000000035011072626250012607 0ustar jcsp-1.1-rc4.orig/src/0000755000000000000000000000000011410045043011404 5ustar jcsp-1.1-rc4.orig/src/org/0000755000000000000000000000000011410045043012173 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/0000755000000000000000000000000011410045054013134 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/demos/0000755000000000000000000000000011410045050014237 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/demos/util/0000755000000000000000000000000011410045051015215 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/demos/util/ComplexDouble.java0000644000000000000000000001130511105701167020632 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.demos.util; /** * @author Quickstone Technologies Limited */ public class ComplexDouble implements Cloneable { public ComplexDouble(double d, double d1) { real = d; imag = d1; } public ComplexDouble add(ComplexDouble complexdouble) { real += complexdouble.real; imag += complexdouble.imag; return this; } public ComplexDouble addImag(double d) { imag += d; return this; } public ComplexDouble addReal(double d) { real += d; return this; } public Object clone() { Object obj = null; try { obj = super.clone(); } catch (CloneNotSupportedException clonenotsupportedexception) { System.out.println( String.valueOf(clonenotsupportedexception) + " -- can't be happening !!!"); } return obj; } public ComplexDouble div(ComplexDouble complexdouble) { double d = complexdouble.real * complexdouble.real + complexdouble.imag * complexdouble.imag; double d1 = (real * complexdouble.real + imag * complexdouble.imag) / d; imag = (imag * complexdouble.real - real * complexdouble.imag) / d; real = d1; return this; } public double getImag() { return imag; } public double getReal() { return real; } public double modulus() { return Math.sqrt(real * real + imag * imag); } public double modulusSquared() { return real * real + imag * imag; } public ComplexDouble mult(ComplexDouble complexdouble) { double d = real * complexdouble.real - imag * complexdouble.imag; imag = imag * complexdouble.real + real * complexdouble.imag; real = d; return this; } public ComplexDouble scale(double d) { real *= d; imag *= d; return this; } public ComplexDouble set(double d, double d1) { real = d; imag = d1; return this; } public ComplexDouble set(ComplexDouble complexdouble) { real = complexdouble.real; imag = complexdouble.imag; return this; } public ComplexDouble setImag(double d) { imag = d; return this; } public ComplexDouble setReal(double d) { real = d; return this; } public ComplexDouble sub(ComplexDouble complexdouble) { real -= complexdouble.real; imag -= complexdouble.imag; return this; } private double real; private double imag; } jcsp-1.1-rc4.orig/src/org/jcsp/demos/util/Ask.java0000644000000000000000000007062311111260160016604 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.demos.util; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.GridLayout; import java.awt.Label; import java.awt.Panel; import java.awt.TextArea; import java.awt.TextField; import java.awt.event.WindowEvent; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Enumeration; import java.util.Hashtable; import java.util.NoSuchElementException; import java.util.StringTokenizer; import org.jcsp.awt.ActiveButton; import org.jcsp.awt.ActiveFrame; import org.jcsp.lang.Alternative; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Channel; import org.jcsp.lang.Guard; import org.jcsp.lang.One2OneChannel; import org.jcsp.lang.Parallel; import org.jcsp.util.OverWritingBuffer; /** * @author Quickstone Technologies Limited */ public class Ask { private static Container buttonContainer = null; private static class Prompt { public final String label; public final boolean isNumber; public final int min; public final int max; public final int def; public int value; public String valueS; public TextField control; public Prompt(final String label, final int min, final int max, final int def) { this.label = label; this.min = min; this.max = max; this.def = def; this.value = def; buttonContainer.add(new Label(label)); buttonContainer.add(control = new TextField("" + def)); this.isNumber = true; } public Prompt(final String label) { this.label = label; this.min = 0; this.max = 0; this.def = 0; this.valueS = ""; buttonContainer.add(new Label(label)); buttonContainer.add(control = new TextField("")); this.isNumber = false; } } private static Hashtable prompts = null; private static String title = ""; private static String descr = ""; public static void app(final String prompt, final String description) { int l = prompt.length(); System.out.println("\nJCSP Demonstration - " + prompt); for (int i = -21; i < l; i++) { System.out.print("="); } System.out.println("\n" + description + "\n"); title = "JCSP Demonstration - " + prompt; descr = description; } public static void addPrompt(final String prompt, final int min, final int max, final int def) { if (prompts == null) { buttonContainer = new Panel(); buttonContainer.setLayout(new GridLayout(0, 2)); prompts = new Hashtable(); } prompts.put(prompt, new Prompt(prompt, min, max, def)); } public static void addPrompt(final String prompt) { if (prompts == null) { buttonContainer = new Panel(); buttonContainer.setLayout(new GridLayout(0, 2)); prompts = new Hashtable(); } prompts.put(prompt, new Prompt(prompt)); } public static int readInt(final String prompt) { Prompt p = (Prompt) prompts.get(prompt); if (p == null)throw new Error("oops: " + prompt); return p.value; } public static String readStr(final String prompt) { Prompt p = (Prompt) prompts.get(prompt); if (p == null)throw new Error("oops: " + prompt); return p.control.getText().trim(); } public static void show() { final One2OneChannel frameEvent = Channel.one2one(new OverWritingBuffer(1)); final One2OneChannel frameConfig = Channel.one2one(new OverWritingBuffer(1)); final One2OneChannel okEvent = Channel.one2one(new OverWritingBuffer(1)); final One2OneChannel okConfig = Channel.one2one(new OverWritingBuffer(1)); final One2OneChannel cancelEvent = Channel.one2one(new OverWritingBuffer(1)); final One2OneChannel cancelConfig = Channel.one2one(new OverWritingBuffer(1)); final ActiveFrame frame = new ActiveFrame(frameConfig.in(), frameEvent.out(), title); final ActiveButton ok = new ActiveButton(okConfig.in(), okEvent.out(), "Ok"); final ActiveButton cancel = new ActiveButton(cancelConfig.in(), cancelEvent.out(), "Cancel"); frame.setLayout(new BorderLayout()); { // Put the title line in Label l = new Label(title, Label.CENTER); l.setFont(new Font("default", Font.BOLD, 16)); frame.add(l, BorderLayout.NORTH); } { // Put the OK and CANCEL buttons in Container ctr = new Panel(); ctr.add(ok); ctr.add(cancel); frame.add(ctr, BorderLayout.SOUTH); } { Container ctr = new Panel(); ctr.setLayout(new BorderLayout()); { // Put the description in TextArea ta = new TextArea(descr, 0, 0, TextArea.SCROLLBARS_NONE); Color c = ta.getBackground(); ta.setEditable(false); ta.setBackground(c); ctr.add(ta, BorderLayout.NORTH); } if (prompts != null) { Container ctr2 = new Panel(); ctr2.add(buttonContainer); // Put the main control grid in ctr.add(ctr2, BorderLayout.CENTER); } frame.add(ctr, BorderLayout.CENTER); } frame.pack(); Parallel par = new Parallel(new CSProcess[] { frame, ok, cancel, new CSProcess() { public void run() { Alternative alt = new Alternative(new Guard[] {okEvent.in(), cancelEvent.in(), frameEvent.in()}); boolean loop = true; while (loop) { switch (alt.priSelect()) { case 0: okEvent.in().read(); okConfig.out().write(null); cancelConfig.out().write(null); frameConfig.out().write(null); loop = false; break; case 2: WindowEvent e = (WindowEvent) frameEvent.in().read(); if (e.getID() != WindowEvent.WINDOW_CLOSING)break; case 1: System.exit(0); } } } } }); boolean valid = false; do { frame.setVisible(true); par.run(); frame.setVisible(false); valid = true; if (prompts != null) { for (Enumeration e = prompts.elements(); e.hasMoreElements(); ) { Prompt p = (Prompt) e.nextElement(); if (p.isNumber) { String t = p.control.getText(); if (t == null) { valid = false; p.control.setText("" + p.value); continue; } t = t.trim(); if (t.equals("")) { valid = false; p.control.setText("" + p.value); continue; } try { int v = Integer.parseInt(t); if ((v < p.min) || (v > p.max)) { valid = false; p.control.setText("" + p.value); continue; } else { p.value = v; } } catch (NumberFormatException ex) { valid = false; p.control.setText("" + p.value); continue; } } } } } while (!valid); par.releaseAllThreads(); } public static void blank() { if (prompts != null) { prompts = null; buttonContainer = null; } System.out.println(); } //The above Ask class from Quickstone has been merged with the below Ask class from PHW: /** * This Ask class contains a set of static methods for safe interactive input * of individual primitive types. They will not return until an acceptable * answer has been entered. * The implementation techniques draw on those in the `Java Gently' textbook * by Judy Bishop. * * @author P.H. Welch * */ private static InputStreamReader isr = new InputStreamReader (System.in); private static BufferedReader in = new BufferedReader (isr); /** * Don't allow any instances! */ private Ask () { } /** * Ask.Int issues the prompt and returns an int between min and max inclusive. * Keyboard errors in typing the reply are all trapped. The method will * not return until a valid int has been entered in the indicated range. * * @param prompt the string used to prompt for input. * @param min user input must have a value >= min. * @param max user input must have a value <= max. * * @return user input complying with the rules. */ public static int Int (String prompt, int min, int max) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (line); String item = tokens.nextToken(); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only type in one item ..."); } else { int answer = Integer.valueOf (item.trim ()).intValue (); if ((min <= answer) && (answer <= max)) return answer; System.out.println (" *** Please answer between " + min + " and " + max); } } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (NumberFormatException e2) { System.out.println (" *** Please type in an *integer* ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * Ask.Long issues the prompt and returns an long between min and max inclusive. * Keyboard errors in typing the reply are all trapped. The method will * not return until a valid long has been entered in the indicated range. * * @param prompt the string used to prompt for input. * @param min user input must have a value >= min. * @param max user input must have a value <= max. * * @return user input complying with the rules. */ public static long Long (String prompt, long min, long max) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (line); String item = tokens.nextToken(); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only type in one item ..."); } else { long answer = Long.valueOf (item.trim ()).longValue (); if ((min <= answer) && (answer <= max)) return answer; System.out.println (" *** Please answer between " + min + " and " + max); } } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (NumberFormatException e2) { System.out.println (" *** Please type in an *long* ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * Ask.Byte issues the prompt and returns a byte between min and max inclusive. * Keyboard errors in typing the reply are all trapped. The method will * not return until a valid byte has been entered in the indicated range. * * @param prompt the string used to prompt for input. * @param min user input must have a value >= min. * @param max user input must have a value <= max. * * @return user input complying with the rules. */ public static byte Byte (String prompt, byte min, byte max) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (line); String item = tokens.nextToken(); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only type in one item ..."); } else { byte answer = Byte.valueOf (item.trim ()).byteValue (); if ((min <= answer) && (answer <= max)) return answer; System.out.println (" *** Please answer between " + min + " and " + max); } } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (NumberFormatException e2) { System.out.println (" *** Please type in an *byte* ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * Ask.Short issues the prompt and returns a short between min and max inclusive. * Keyboard errors in typing the reply are all trapped. The method will * not return until a valid short has been entered in the indicated range. * * @param prompt the string used to prompt for input. * @param min user input must have a value >= min. * @param max user input must have a value <= max. * * @return user input complying with the rules. */ public static short Short (String prompt, short min, short max) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (line); String item = tokens.nextToken(); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only type in one item ..."); } else { short answer = Short.valueOf (item.trim ()).shortValue (); if ((min <= answer) && (answer <= max)) return answer; System.out.println (" *** Please answer between " + min + " and " + max); } } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (NumberFormatException e2) { System.out.println (" *** Please type in an *short* ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * Ask.Float issues the prompt and returns a float between min and max inclusive. * Keyboard errors in typing the reply are all trapped. The method will * not return until a valid float has been entered in the indicated range. * * @param prompt the string used to prompt for input. * @param min user input must have a value >= min. * @param max user input must have a value <= max. * * @return user input complying with the rules. */ public static float Float (String prompt, float min, float max) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (line); String item = tokens.nextToken(); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only type in one item ..."); } else { float answer = Float.valueOf (item.trim ()).floatValue (); if ((min <= answer) && (answer <= max)) return answer; System.out.println (" *** Please answer between " + min + " and " + max); } } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (NumberFormatException e2) { System.out.println (" *** Please type in an *float* ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * Ask.Double issues the prompt and returns a double between min and max inclusive. * Keyboard errors in typing the reply are all trapped. The method will * not return until a valid double has been entered in the indicated range. * * @param prompt the string used to prompt for input. * @param min user input must have a value >= min. * @param max user input must have a value <= max. * * @return user input complying with the rules. */ public static double Double (String prompt, double min, double max) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (line); String item = tokens.nextToken(); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only type in one item ..."); } else { double answer = Double.valueOf (item.trim ()).doubleValue (); if ((min <= answer) && (answer <= max)) return answer; System.out.println (" *** Please answer between " + min + " and " + max); } } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (NumberFormatException e2) { System.out.println (" *** Please type in an *double* ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * Ask.Boolean issues the prompt and returns a boolean depending on the first * non-white-space character typed. 'y' or 'Y' cause true to be returned, * while 'n' or 'N' cause false to be returned. Anything else is rejected. * * @param prompt the string used to prompt for input. * * @return whether the user typed yes or no (according to the above rules). */ public static boolean Boolean (String prompt) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (line); String item = tokens.nextToken(); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only type in one item ..."); } else { char ch = item.charAt (0); if ((ch == 'y') || (ch == 'Y')) return true; if ((ch == 'n') || (ch == 'N')) return false; System.out.println (" *** Please answer yes or no ..."); } } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * Ask.Char issues the prompt and returns a char depending on the first * non-white-space character typed. This character must be one in * the valid character array. Anything else is rejected. * * @param prompt the string used to prompt for input. * @param valid the array of characters defining valid user responses. * * @return user input complying with the rules. */ public static char Char (String prompt, char[] valid) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (line); String item = tokens.nextToken(); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only type in one item ..."); } else { char ch = item.charAt (0); for (int i = 0; i < valid.length; i++) { if (ch == valid[i]) { System.out.print (""); // JIT bug work-around ?!! return ch; } } System.out.print (" *** Please type one character from \""); for (int i = 0; i < valid.length; i++) { System.out.print (valid[i]); } System.out.println ("\" ..."); } } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } // Void issues the prompt and returns when is pressed. /** * Ask.Void issues the prompt and returns when is pressed. * * @param prompt the string used to prompt for a . */ public static void Void (String prompt) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) return; StringTokenizer tokens = new StringTokenizer (line); if (oneTokenReply && tokens.hasMoreTokens ()) { System.out.println (" *** Please only press ..."); } else { return; } } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * Ask.string issues the prompt and returns the String that is typed. * * @param prompt the string used to prompt for input. * * @return whatever the user inputs. */ public static String string (String prompt) { while (true) { System.out.print (prompt); System.out.flush (); try { String line = in.readLine (); if (line == null) throw new NoSuchElementException (); return line; } catch (NoSuchElementException e) { System.out.println ("\n *** Please type something in ..."); } catch (IOException e) { System.out.println (" *** " + e); System.out.println (" *** abandoning program !!!\n"); System.exit (1); } } } /** * If oneTokenReply, extra tokens in replies cause the input to be rejected. */ private static boolean oneTokenReply = true; /** * Ask.setOneTokenReply (true) specifies that more than one token in * the user reply will be rejected, even if the first token is valid. * This is the default condition for this class. *

* Ask.setOneTokenReply (false) specifies that multiple tokens are * allowed, but that only the first will be processed. *

* The false allows user input to be documented with comments (in the * second and following tokens) explaining the meaning of the first token, which * contains the actual data. This is useful when preparing user input as a file, * from which the standard input stream will later be redirected, so that * each line of input can be documented. * * @param b if true, the response must consist of a single token * - otherwise, multiple tokens are allowed but only the first will be processed. */ public static void setOneTokenReply (boolean b) { oneTokenReply = b; } /** * Ask.getOneTokenReply returns whether multiple response tokens * will be rejected. * * @return whether multiple response tokens will be rejected. */ public static boolean getOneTokenReply () { return oneTokenReply; } } jcsp-1.1-rc4.orig/src/org/jcsp/net/0000755000000000000000000000000011410045050013716 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net/NetChannelEndFactory.java0000644000000000000000000000611511105701167020573 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* This interface defines methods for constructing Networked * channel ends. *

* * @author Quickstone Technologies Limited */ public interface NetChannelEndFactory { /** *

* Constructs a NetAltingChannelInput object. *

* * @return the constructed NetAltingChannelInput object. */ public NetAltingChannelInput createNet2One(); /** *

* Constructs a NetSharedChannelInput object. *

* * @return the constructed NetSharedChannelInput object. */ public NetSharedChannelInput createNet2Any(); /** *

* Constructs a NetChannelOutput object. *

* * @return the constructed NetChannelOutput object. */ public NetChannelOutput createOne2Net(NetChannelLocation loc); /** *

* Constructs a NetSharedChannelOutput object. *

* * @return the constructed NetSharedChannelOutput object. */ public NetSharedChannelOutput createAny2Net(NetChannelLocation loc); }jcsp-1.1-rc4.orig/src/org/jcsp/net/NodeUIImpl.java0000644000000000000000000001201211105701167016533 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * This is a default implementation for NodeUI that is used if no * other implementation is supplied. * * @author Quickstone Technologies Limited */ public class NodeUIImpl extends NodeUI { /** Constructor which is used as standard to create a new NodeUIImpl * object. */ protected NodeUIImpl() { time = System.currentTimeMillis(); mem = Runtime.getRuntime().freeMemory(); hashCode = new Object().hashCode(); } /** * A constructor which takes a String that should be in the * format of that returned by the getImplStringForm() method. * * @param s a String used to construct the NodeUIImpl object. */ public NodeUIImpl(String s) { try { int start = 0; int nlPos = s.indexOf('\n'); if(nlPos < 0 || nlPos == s.length() - 1) throw new IllegalArgumentException("Invalid String"); time = Long.parseLong(s.substring(0, nlPos)); start = nlPos + 1; nlPos = s.indexOf('\n', start); if(nlPos < 0 || nlPos == s.length() - 1) throw new IllegalArgumentException("Invalid String"); mem = Long.parseLong(s.substring(start, nlPos)); start = nlPos + 1; hashCode = Integer.parseInt(s.substring(start, s.length())); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid String"); } } /** * Returns a String object that can be used with the constructor * that takes a String parameter. * * @return a String that holds this object in "string form". */ public String getImplStringForm() { return time+"\n"+mem+"\n"+hashCode; } /** Compares another NodeUI with this NodeUIImpl. * * @param other another NodeUI to compare with this object. * @return true iff the NodeUI supplied is a NodeUIImpl object that contains * the same internal unique identifier as this object. */ public final boolean checkEqual(NodeUI other) { if(other == null || !(other instanceof NodeUIImpl)) return false; NodeUIImpl aOther = (NodeUIImpl) other; return (time == aOther.time) && (mem == aOther.mem) && (hashCode == aOther.hashCode); } /** Returns a String that can be used by the superclass to compare * two NodeUI objects. * @return a String that follows the rules stated for this method in the * NodeUI class. */ protected String getComparisonString() { return time + "" + mem + "" + hashCode; } /** Returns a hash code for this object. * @return an int hash code for this object. */ public final int hashCode() { return hashCode; } private long time; private long mem; private int hashCode; }jcsp-1.1-rc4.orig/src/org/jcsp/net/UnacknowledgedNetChannelEndFactory.java0000644000000000000000000000601111105701167023441 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * Extends the standard network channel factory to give unacknowledged channel output ends. Use these with caution * as the lack of synchronization between sender and receiver can lead to potential problems. * * @author Quickstone Technologies Limited */ public class UnacknowledgedNetChannelEndFactory extends StandardNetChannelEndFactory { /** * Creates a new factory object. */ public UnacknowledgedNetChannelEndFactory() { super(); } /** * Creates an unacknowledged output channel end suitable for use by a single writer. * * @param loc address of the input channel end to connect to. */ public NetChannelOutput createOne2Net(NetChannelLocation loc) { return new One2NetChannel(loc, false); } /** * Creates an unacknowledged output channel end suitable for use by multiple writers. * * @param loc address of the input channel end to connect to. */ public NetSharedChannelOutput createAny2Net(NetChannelLocation loc) { return new Any2NetChannel(loc, false); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Service.java0000644000000000000000000000670011105701167016175 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* An interface that should be implemented by classes that * are intended to be Node level JCSP.NET services. *

*

* Services should be initialized, then started and then stopped. *

* * @author Quickstone Technologies Limited */ public interface Service { /** * This should start the service when called and return. * @return true iff the service has successfully started. */ public boolean start(); /** Should stop the service and then return. * @return true iff the service has successfully stopped. */ public boolean stop(); /** Initialize the service with the specified service settings. * @param settings The settings used by the service. * @return true iff the service has been initialized. */ public boolean init(ServiceSettings settings); /** * Indicates whether or not a service is running. * @return true iff the service is currently running. */ public boolean isRunning(); /** * Obtains a ServiceUserObject from a Service. * This allows Services to expose functionality to users that * it does not want to be able to access admin features. * * @return a ServiceUserObject. * @throws SecurityException if the calling Thread does not have * access to the object. */ public ServiceUserObject getUserObject() throws SecurityException; }jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/0000755000000000000000000000000011410045050015035 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/TCPIPLink.java0000644000000000000000000004526111105701167017416 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.tcpip; import java.net.*; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.*; /** * Implements a link running over TCP/IP sockets. See the definition of Link for * full details. * * @see org.jcsp.net.Link * * @author Quickstone Technologies Limited */ class TCPIPLink extends Link { /*----------------------Constructors------------------------------------------*/ /** * Constructor for using an existing socket. * * @param socket The socket to the remote computer, which must already be * open and active. You must not have transmitted anything * over the socket. */ // package-private TCPIPLink(Socket socket) { this(socket, true); } /** * Constructor for using an existing socket. * * @param socket The socket to the remote computer, which must already be * open and active. You must not have transmitted anything * over the socket. * * @param client Tells the link whether to act as a client or a server * during the handshake process */ // package-private - called from LinkServer with client false TCPIPLink(Socket socket, boolean client) { super(new TCPIPProtocolID(), client, true); this.socket = socket; } /** * Constructor for connecting to a remote computer. The actual connect * happens when you run the process using start(). * * @param remoteTCPIPAddress The remote computer to connect to. */ // package-private - called from LinkManager TCPIPLink(TCPIPAddressID remoteTCPIPAddress) { super(new TCPIPProtocolID(), true, false); this.remoteTCPIPAddress = remoteTCPIPAddress; } /*-------------Implementations of Methods from Link---------------------------*/ /** * Run the send and receive threads to marshall and unmarshall objects. */ protected void runTxRxLoop() { Parallel par = new Parallel( new CSProcess[] {new RxLoop(), new TxLoop()}); par.run(); par.releaseAllThreads(); } /** * Waits for numRepliesOutstanding instances of LinkLost * to arrive from the txChannel. * * @param numRepliesOutstanding LinkLost instances to wait for. */ protected void waitForReplies(int numRepliesOutstanding) { ChannelInput in = txChannel.in(); while (numRepliesOutstanding > 0) { Object obj = in.read(); if (obj instanceof LinkLost) numRepliesOutstanding--; } } /** * Start this Link but allow the caller to continue in parallel. * This is the similar to "new ProcessManager(this).start()" - except * that Link no longer implements CSProcess, so you can't do * that. */ // package-private - called from LinkManager & LinkServer protected void start(boolean newProcess) { ProcessManager pm = new ProcessManager(this); pm.setPriority(ProcessManager.PRIORITY_MAX); if(newProcess) pm.start(); else pm.run(); } /** * Connect to remote host. Should only be called for client-side * Links which have not yet been connected. (i.e. where * socket==null and remoteAddress != null). * * @return true on success, false on failure. */ protected boolean connect() { try { socket = new Socket(remoteTCPIPAddress.getHost(), remoteTCPIPAddress.getPort()); } catch (SecurityException ex) { ex.printStackTrace(); return false; // Give up } catch (ConnectException ex) { ex.printStackTrace(); return false; // Give up } catch (NoRouteToHostException ex) { ex.printStackTrace(); return false; // Give up } catch (IOException ex) { ex.printStackTrace(); return false; // Give up } return true; } /** * Create the object streams used to communicate with the peer system. Called internally by * the superclass. * * @return true on success, false on failure */ protected boolean createResources() { // Create the object streams and do the first part of the handshaking. Parallel par = new Parallel( new CSProcess[] { new CreateRxStream(), new CreateTxStream(), }); par.run(); par.removeAllProcesses(); par.releaseAllThreads(); // check whether it worked. if ((rxStream == null) || (txStream == null)) { // Object Stream creation failed. Node.err.log(this, "Object Stream creation failed."); destroyResources(); // We've already displayed an error message (or two), so just exit return false; } // Ok return true; } /** * Performs the node exchange part of the handshaking process. Creates a process to * send this NodeID and a process to receive the peer node ID. Called internally * by the superclass. * * @return true on success, false on failure */ protected boolean exchangeNodeIDs() { // Do the second part of the handshaking. Parallel par = new Parallel(new CSProcess[] { new RxId(), new TxId() }); par.run(); par.releaseAllThreads(); // check whether it worked. if ((rxStream == null) || (txStream == null)) { Node.err.log(this, "Error during handshaking (stage2)"); return false; } return true; } /** * Writes a test object to the output stream, flushing and resetting the stream afterwards. * Called internally by the superclass during the testing stage to determine link speed. The parameter passed * to this method must be returned by the readTestObject method at the peer * node. * * @param obj Object to be sent */ protected void writeTestObject(Object obj) throws Exception { txStream.writeObject(obj); txStream.flush(); txStream.reset(); } /** * Reads a test object from the input stream. Called internally by the superclass during the testing stage to * determine link speed. Returns the parameter passed to writeTestObject at the * peer node. * * @return the object received. */ protected Object readTestObject() throws Exception { return rxStream.readObject(); } /** * Writes a boolean link decision value to the output stream. Called internally by the superclass during the * handshaking sequence. The parameter passed to this method must be returned by the * readLinkDecision method at the peer node. * * @param use boolean decision value to send. */ protected void writeLinkDecision(boolean use) throws Exception { txStream.writeObject(use ? Boolean.TRUE : Boolean.FALSE); txStream.flush(); } /** * Reads a boolean link decision from the input stream. Called internally during the * handshaking sequence by the superclass. Returns the parameter passed to writeLinkDecision * at the peer node. * * @return the boolean decision. */ protected boolean readLinkDecision() throws Exception { return ((Boolean)rxStream.readObject()).booleanValue(); } /** * Closes the streams and the socket, if needed. Surpresses errors. */ protected void destroyResources() { if (txStream != null) { try { txStream.close(); } catch (Exception ignored) { } txStream = null; } closeRx(); } /*-------------------Private Methods------------------------------------------*/ /** * Closes the Rx stream and the socket, if needed. Surpresses errors. */ private void closeRx() { if (rxStream != null) { try { rxStream.close(); } catch (Exception ignored) { } rxStream = null; } closeSocket(); } /** * Closes the Tx stream and the socket, if needed. Surpresses errors. */ private void closeTx() { if (txStream != null) { try { txStream.close(); } catch (Exception ignored) { } txStream = null; } closeSocket(); } /** * Closes the socket, if needed. Surpresses errors. */ private void closeSocket() { if (socket != null) { try { socket.close(); } catch (Exception ignored) { } socket = null; } } /*----------------------Attributes--------------------------------------------*/ /** * The other computer's IP address and port. */ private TCPIPAddressID remoteTCPIPAddress; /** * The actual socket. */ private Socket socket; /** * The stream for reading from the socket. */ private ObjectInputStream rxStream; /** * The stream for reading from the socket. */ private ObjectOutputStream txStream; /** * Handshaking string. */ private static String PROTOCOL_IDENTIFIER = "JCSP.net version 0.1"; /** * Size of Java buffers. Note that there are also OS buffers, * set using {@link java.net.Socket#setReceiveBufferSize(int)} and * {@link java.net.Socket#setSendBufferSize(int)}. */ private static final int BUFFER_SIZE = 8192; /*----------------------Private Inner Classes---------------------------------*/ /** * The process which creates txStream. It creates an object stream * associated with the socket, and sends the Java object stream header * and the PROTOCOL_IDENTIFIER. On success, it sets txStream in the * outer class to a non-null value. If there is an exception, it * closes the socket and returns without modifying txStream. * * @see #txStream */ private class CreateTxStream implements CSProcess { /** * The run method. */ public void run() { // This is what we close() if we catch an exception. OutputStream rawTxStream = null; try { rawTxStream = socket.getOutputStream(); socket.setTcpNoDelay(true); rawTxStream = new BufferedOutputStream(rawTxStream,BUFFER_SIZE); ObjectOutputStream objTxStream = new ObjectOutputStream(rawTxStream); objTxStream.writeObject(PROTOCOL_IDENTIFIER); objTxStream.flush(); objTxStream.reset(); txStream = objTxStream; return; } catch (Exception ex) { ex.printStackTrace(); if (rawTxStream != null) { try { rawTxStream.close(); } catch (Exception ignored) { } } closeSocket(); } } } /** * The process which creates rxStream. It creates an object stream * associated with the socket, and listens for the Java object stream * header and the PROTOCOL_IDENTIFIER. On success, it sets rxStream in * the outer class to a non-null value. If there is an exception, or * if the object recieved is not PROTOCOL_IDENTIFIER, it closes the * socket and returns without modifying rxStream. * * @see #rxStream */ private class CreateRxStream implements CSProcess { /** * The run method. */ public void run() { // This is what we close() if we catch an exception. InputStream rawRxStream = null; try { rawRxStream = socket.getInputStream(); rawRxStream = new BufferedInputStream(rawRxStream, BUFFER_SIZE); ObjectInputStream objRxStream = new ObjectInputStream(rawRxStream); if (!PROTOCOL_IDENTIFIER.equals(objRxStream.readObject())) { // Wrong PROTOCOL_IDENTIFIER } else { rxStream = objRxStream; return; } } catch (Exception ex) { } if (rawRxStream != null) { try { rawRxStream.close(); } catch (Exception ignored) { } } closeSocket(); } } /** * The process which sends our Id. On success, it doesn't change anything. * If there is an exception, it closes the socket, sets txStream=null, and * returns. */ private class TxId implements CSProcess { /** * The run method. */ public void run() { NodeID localAddress = null; if(sendNodeID) localAddress = Node.getInstance().getNodeID(); try { txStream.writeObject(localAddress); txStream.flush(); txStream.reset(); } catch (Exception ex) { ex.printStackTrace(); closeTx(); } } } /** * The process which recieves the remote Id. On success, it sets * remoteAddress. If there is an exception, it closes the socket, sets * rxStream=null, and returns. */ private class RxId implements CSProcess { /** * The run method. */ public void run() { try { remoteNodeID = (NodeID)rxStream.readObject(); } catch (Exception ex) { ex.printStackTrace(); closeRx(); } } } /** * The process which does transmission to a socket. */ private class TxLoop implements CSProcess { /** * The run method. */ public void run() { ChannelInput in = txChannel.in(); try { Object obj = in.read(); while (!(obj instanceof TxLoopPoison)) { txStream.writeObject(obj); txStream.flush(); txStream.reset(); obj = in.read(); } closeTx(); } catch (Exception ex) { if ((ex instanceof SocketException) || (ex instanceof EOFException)) { // Probably because the other side closed it. } else { synchronized(System.err) { Node.err.log(this, "Error in TX:"); ex.printStackTrace(); } } closeTx(); // Need to wait for RxLoop to die (which it will do because we // just closed the socket it's trying to read from) and then // get the TxLoopPoison it sends us. Meanwhile, black-hole // any incoming data. Object obj = in.read(); while (!(obj instanceof TxLoopPoison)) obj = in.read(); } } } /** * The process which recieves from a socket. */ private class RxLoop implements CSProcess { /** * The run method. */ public void run() { try { // Now enter demux loop while (true) deliverReceivedObject(rxStream.readObject()); } catch (Exception ex) { if ((ex instanceof SocketException) || (ex instanceof EOFException)) { // Probably because the other side closed it. } else { synchronized(System.err) { Node.err.log(this, "Error in RX:"); Node.err.log(this, ex); } } closeRx(); // Now, need to carefully close TxLoop, making sure we don't // deadlock. txChannel.out().write(new TxLoopPoison()); } } } /** * An object of this type is used by RxLoop to poison TxLoop. */ private class TxLoopPoison { } }jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/TCPIPCNSServerNT.java0000644000000000000000000000567011105701167020575 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.tcpip; import org.jcsp.win32.*; /** * Wraps up the TCPIPCNSServer as a Windows NT service. To install the service, register the * path java org.jcsp.net.tcpip.TCPIPCNSServerNT with the service name * JCSP.NET:TCPIPCNSServer.

* * @author Quickstone Technologies Limited */ public class TCPIPCNSServerNT extends NTService { /** * Starts the service by calling TCPIPCNSServer.main. */ protected void startService() { TCPIPCNSServer2.main(new String[0]); // will block } /** * Stops the service. */ protected void stopService() { TCPIPCNSServer2.terminate.out().write(null); } /** * Creates a new service instance. */ private TCPIPCNSServerNT() { super("JCSP.NET:TCPIPCNSServer"); } /** * Creates a new service instance and sets it running. */ public static void main(String[] args) { new TCPIPCNSServerNT().run(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/TCPIPCNSServer2.java0000644000000000000000000000740611105701167020414 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.tcpip; import java.io.*; import org.jcsp.net.*; import org.jcsp.net.cns.*; import org.jcsp.lang.*; /** *

Program to run a Channel Name Service. The service will listen on all locally available * addresses using either a default port of 7890 or a port specified in the XML file.

* * @author Quickstone Technologies Limited */ public class TCPIPCNSServer2 { /** * For use by other sub classes of this class to terminate the server. To terminate the server write a null * to this channel. This gets used in the NT service implementation to response to the STOP event. */ static final One2OneChannel terminate = Channel.one2one(); private TCPIPCNSServer2() { } /** * Main method, running the service. This will never terminate if the service can be started. */ public static void main(String[] args) { Node.info.log(TCPIPCNSServer2.class, "Starting CNS server"); try { NodeKey key = Node.getInstance().init(new XMLNodeFactory("JCSPNetCNSService.xml")); ServiceManager sm = Node.getInstance().getServiceManager(key); CNS cns = new CNS(key); if (sm.installService(cns, "Channel Name Server") && sm.startService("Channel Name Server")) Node.info.log(TCPIPCNSServer2.class, "CNS Started"); else Node.info.log(TCPIPCNSServer2.class, "CNS failed to start"); } catch (NodeInitFailedException e) { e.printStackTrace(); return; } catch (IOException e) { Node.info.log(TCPIPCNSServer2.class,"XML file not found"); return; } Node.info.log(TCPIPCNSServer2.class,"CNS server running on " + Node.getInstance().getNodeID()); // sleep forever (or until terminated) terminate.in().read(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/TCPIPProtocolID.java0000644000000000000000000001234111105701167020530 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.tcpip; import java.net.*; import java.util.*; import org.jcsp.net.*; /** * Defines a protocol ID for the TCP/IP link implementation. * * @see org.jcsp.net.ProtocolID * * @author Quickstone Technologies Limited */ public class TCPIPProtocolID extends ProtocolID { /** * Compares two protocol IDs */ public boolean equals(Object o) { return o instanceof TCPIPProtocolID; } /** * Always returns true. */ public boolean isActive() { return true; } /** * Always returns false. */ public boolean requiresUserInteraction() { return false; } /** * Returns the factory builder for this protocol. */ protected LinkFactory.Builder getLinkBuilder(Hashtable settings) { return new LinkFactory.Builder(this) { public Link testAndBuild(NodeAddressID addressID) { if(!(addressID instanceof TCPIPAddressID)) throw new IllegalArgumentException("Argument not TCP/IP NodeAddressID"); TCPIPAddressID add = (TCPIPAddressID) addressID; return new TCPIPLink(add); } }; } /** * Starts the TCP/IP link server at this node using the given address ID. */ protected LinkServer startLinkServer(NodeAddressID addressID) throws IllegalArgumentException { if(addressID == null) throw new IllegalArgumentException("addressID is null"); return TCPIPLinkServer.create(addressID); } /** * Creates an address from a string form. */ protected NodeAddressID createAddressID(String stAddressID, boolean uniqueAddress) throws IllegalArgumentException { if(stAddressID == null) throw new IllegalArgumentException("addressID is null"); if(stAddressID == "") throw new IllegalArgumentException("Zero length String supplied"); int colonIndex = stAddressID.indexOf(':'); TCPIPAddressID addressID = null; if(colonIndex != -1) { //check that there are characters either side of the colon if(colonIndex > 0 && colonIndex < stAddressID.length() - 1) { String host = stAddressID.substring(0, colonIndex); String stPort = stAddressID.substring(colonIndex + 1, stAddressID.length()); try { int port = Integer.decode(stPort).intValue(); addressID = new TCPIPAddressID(host, port, uniqueAddress); } catch (NumberFormatException e) { throw new IllegalArgumentException("Port not a number"); } catch (UnknownHostException e) { throw new IllegalArgumentException("Unknown host supplied"); } } else { throw new IllegalArgumentException("host and port not fully specified"); } } else { //no port specified try { addressID = new TCPIPAddressID(stAddressID, 0, uniqueAddress); } catch (UnknownHostException e) { throw new IllegalArgumentException("Unknown host supplied"); } } return addressID; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/JCSPNetCNSService.xml0000644000000000000000000000137110522104430020655 0ustar
jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/TCPIPNodeFactory.java0000644000000000000000000002630411105701167020733 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.tcpip; import java.net.*; import java.util.prefs.*; import org.jcsp.net.*; import org.jcsp.net.cns.*; import org.jcsp.net.security.*; /** *

Default factory for simple initialisations using the TCPIPv4 protocol package.

* *

Other constructors can be used to specify a particular CNS server. The default behaviour will * extract a CNS server from the system property "org.jcsp.tcpip.DefaultCNSServer" with the server specified * as a name or IP address with optional port number.

* *

If built with 1.4 or higher the user preferences will also be checked but only if a * runtime supporting the preferences is available. If not present the system preferences will then * be checked.

* * @author Quickstone Technologies Limited */ public class TCPIPNodeFactory implements NodeFactory { /** * Address of the CNS server. */ private final NodeAddressID cnsServer; /** * Port number to use for the local link server. By default will be system assigned. Call * setLocalPort prior to calling Node.init () to set a specific value. */ private int localPort = 0; /** * Optional security service to install. */ private SecurityService security = null; /** * Constructs an instance of this class. This method is provided so that a later implementation can * opt to pass construction to an alternative under certain conditions. This is for use by the * infrastructure only. Users should call the public constructors. */ public static NodeFactory instantiate() { return new TCPIPNodeFactory(); } /** * Construct the server address, assuming the local host if none is specified. * * @param cnsServerAddress address of CNS server or null to use the local host. * @param cnsServerPort port number */ private NodeAddressID construct(String cnsServerAddress, int cnsServerPort) { try { return new TCPIPAddressID((cnsServerAddress == null) ? InetAddress.getLocalHost().getHostName() : cnsServerAddress, cnsServerPort, true); } catch (UnknownHostException e) { throw new RuntimeException("Invalid host - " + cnsServerAddress); } } /** * Split the server string into a server and port component on the : character. If none is * present the default port is assumed and the request passed to the other construct * method. * * @param cnsServer server with optional port number */ private NodeAddressID construct(String cnsServer) { int cnsServerPort; if (cnsServer != null) { int ix = cnsServer.indexOf(':'); if (ix < 0) cnsServerPort = TCPIPCNSServer.DEFAULT_CNS_PORT; else { cnsServerPort = Integer.parseInt(cnsServer.substring(ix + 1)); cnsServer = cnsServer.substring(0, ix); } } else cnsServerPort = TCPIPCNSServer.DEFAULT_CNS_PORT; return construct(cnsServer, cnsServerPort); } /** * This code was moved into this method from the constructor below * in the hope that code would compile on 1.4 and still run on 1.3 and 1.2, * */ private String getServerFromPrefs() { try { String svr = Preferences.userNodeForPackage(getClass()).get("DefaultCNSServer", null); if (svr == null) svr = Preferences.systemNodeForPackage(getClass()).get("DefaultCNSServer", null); return svr; } catch (Exception e) { return null; } } /** * Default constructor, connecting to the local host on the default CNS port or to a host name * in the system properties. The host name should be specified as name:port or * just the host name to use the default CNS port. */ public TCPIPNodeFactory() { try { String svr = System.getProperty("org.jcsp.tcpip.DefaultCNSServer"); if (svr == null) { try { if (Class.forName("java.util.prefs.Preferences") != null) svr = getServerFromPrefs(); } catch (ClassNotFoundException e) { } } this.cnsServer = construct(svr); } catch (SecurityException e) { throw new RuntimeException("Invalid host"); } } /** * Connect to the named host on the default CNS port. If the server name is given as null * then the CNS service will not be loaded. * * @param cnsServer name of server */ public TCPIPNodeFactory(String cnsServer) { this.cnsServer = (cnsServer == null) ? null : construct(cnsServer); } /** * Connect to a named host on a specific port. * * @param cnsServerAddress name of the server * @param cnsServerPort port to connect to */ public TCPIPNodeFactory(String cnsServerAddress, int cnsServerPort) { cnsServer = construct(cnsServerAddress, cnsServerPort); } /** * Initialise the node to listen on all local addresses, and start a CNS service. * * @param node the node to be initialized * @param attribs access to the restricted node attributes * @throws NodeInitFailedException if a problem occurs */ public NodeKey initNode(Node node, Node.Attributes attribs) throws NodeInitFailedException { // Get UI factory from system property; or use default UIFactory uiFactory; String uiFactoryClassName = System.getProperty("JCSP.UIFactoryClass"); if (uiFactoryClassName != null) { try { Class uiFactoryClass = Class.forName(uiFactoryClassName); uiFactory = (UIFactory) uiFactoryClass.newInstance(); } catch (Exception e) { Node.err.log(this, "Error trying to load UIFactory: " + uiFactoryClassName); return null; } } else { uiFactory = new UIFactory(); } attribs.setUIFactory(uiFactory); // Setup protocols ... // Setup local addresses (defaults to all local addresses) try { InetAddress[] allLocal = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); for (int i = 0; i < allLocal.length; i++) { try { TCPIPAddressID addr = new TCPIPAddressID(allLocal[i], localPort, true); if (!attribs.getProtocolManager().installProtocolServer(addr, null)) throw attribs.exception("Unable to start LinkServer on " + addr); if (!attribs.getProtocolManager().installProtocolClient(addr.getProtocolID(), null, null)) throw attribs.exception("Unable to install protocol " + addr.getProtocolID()); } catch (Exception e) { if (e instanceof NodeInitFailedException) throw e; Node.err.log(this, "Cannot listen on " + allLocal[i]); } } } catch (Exception e) { if (e instanceof NodeInitFailedException) throw attribs.exception(e.getMessage()); Node.err.log(this, "Error determining local addresses"); } // Setup node specifications ... // Setup profiles ... // Node profiles ... // Setup security service if (security != null) { ServiceManager sm = attribs.getServiceManager(); if (sm.installService(security, "security") && security.init(null) && sm.startService("security")) Node.info.log(this, "Security service started"); else { Node.info.log(this, "Security service failed to start"); return null; } } // Start link manager attribs.startLinkManager(); // Node is now initialized attribs.setInitialized(); // Setup CNS service if (cnsServer != null) { ServiceManager sm = attribs.getServiceManager(); CNSService cnsService = new CNSService(cnsServer, false); if (sm.installService(cnsService, CNSService.CNS_DEFAULT_SERVICE_NAME) && cnsService.init(null) && sm.startService(CNSService.CNS_DEFAULT_SERVICE_NAME)) { Node.info.log(this, "CNS Started"); } else { Node.info.log(this, "CNS failed to start"); return null; } } return attribs.getNodeKey(); } /** * Sets the port number that should be used. If this is not called then the system will allocate * an arbitrary port. * * @param port the port number, 0 <= port < 65536. */ public void setLocalPort(int port) { localPort = port; } /** * Sets the security service to be used. * * @param security the new security authority. */ public void setSecurityAuthority(SecurityService security) { this.security = security; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/TCPIPCNSServer.java0000644000000000000000000001405211105701167020325 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.tcpip; import java.io.*; import java.net.*; import org.jcsp.net.*; import org.jcsp.net.cns.*; import org.jcsp.lang.*; /** *

Program to run a Channel Name Service. The service will listen on all locally available * addresses using either a default port of 7890 or a port specified by the first parameter on the * command line.

* * @author Quickstone Technologies Limited */ public class TCPIPCNSServer { /** * For use by other sub classes of this class to terminate the server. To terminate the server write a null * to this channel. This gets used in the NT service implementation to response to the STOP event. */ static final One2OneChannel terminate = Channel.one2one(); private TCPIPCNSServer() { } /** * Main method, running the service. This will never terminate if the service can be started. */ public static void main(String[] args) { // Parse args int port = DEFAULT_CNS_PORT; if (args.length == 1) { try { port = Integer.parseInt(args[0]); if ((port > 0) && (port <= 0xFFFF)) // Valid port args = new String[0]; } catch (NumberFormatException ex) { // do nothing } } if (args.length > 0) { System.err.println("Usage: java org.jcsp.net.tcpip.TCPIPCNSServer [port]\n" + "where 0 0) { TCPIPAddressID[] localAddressIDsCopy = new TCPIPAddressID[localAddressIDs.length - nullCount]; int copyPointer = 0; for (int i = 0; i < localAddressIDs.length; i++) { if (localAddressIDs[i] != null) { localAddressIDsCopy[copyPointer] = localAddressIDs[i]; copyPointer++; } } localAddressIDs = localAddressIDsCopy; } try { NodeKey key = Node.getInstance().init(localAddressIDs); ServiceManager sm = Node.getInstance().getServiceManager(key); CNS cns = new CNS(key); if (sm.installService(cns, "Channel Name Server") && sm.startService("Channel Name Server")) Node.info.log(TCPIPCNSServer.class, "CNS Started"); else Node.info.log(TCPIPCNSServer.class, "CNS failed to start"); } catch (NodeInitFailedException e) { e.printStackTrace(); } } catch (IOException e) { Node.err.log(TCPIPCNSServer.class, "Cannot start CNS server - port is probably in use."); Node.err.log(TCPIPCNSServer.class, e); System.exit(1); } Node.info.log(TCPIPCNSServer.class, "CNS server running on " + Node.getInstance().getNodeID()); // sleep forever (or until terminated) terminate.in().read(); } /** * The default port number for a Channel Name Server. This value will be used by default if none * is specified on the command line. When locating a CNS the TCPIPNodeFactory will also use this * default value if none is supplied to it. */ public static final int DEFAULT_CNS_PORT = 7890; }jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/TCPIPLinkServer.java0000644000000000000000000001364311105701167020604 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.tcpip; import java.net.*; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.*; /** * A process to accept links to a ServerSocket, create appropriate * TCPIPLink objects, and register them with the LinkManager. *

* * This is a package-private implementation class. * * @author Quickstone Technologies Limited */ // package-private. class TCPIPLinkServer extends LinkServer implements CSProcess { /*----------------------Constructors------------------------------------------*/ /** * Private constructor. To make life easier for you, you don't have to * call this. Just use the static start() method in this class and a * process will be created and executed for you. * * @see #start(ServerSocket) * * @param socket The ServerSocket to accept from */ private TCPIPLinkServer(ServerSocket serverSocket, boolean uniqueAddress) { super(new TCPIPProtocolID(), new TCPIPAddressID(serverSocket.getInetAddress(), serverSocket.getLocalPort(),uniqueAddress)); this.serverSocket = serverSocket; } /*----------------------Public Methods----------------------------------------*/ /** * Start accepting links and dealing with them. * This method runs forever. */ public void run() { try { Node.info.log(this, "TCP/IP V4 LinkServer listening on " + getLinkServerAddressID() + " Started"); while (true) { // Accept an incoming link Socket incoming = serverSocket.accept(); // Create a Link object to represent it. TCPIPLink link = new TCPIPLink(incoming, false); // spawn off the Link object to deal with it, but // let us continue in parallel. new ProcessManager(link).start(); } } catch (Exception ex) { // Will be IOException // warn but otherwise ignore Node.err.log(this, ex); } try { serverSocket.close(); } catch (Exception ignored) { } Node.info.log(this, "TCP/IP V4 LinkServer listening on " + getLinkServerAddressID() + " Ended"); } /*----------------------Non-public Methods------------------------------------*/ /** * Create a server on a specified NodeAddressID, and start it. The server * is spawned off in parallel, so this call returns immediately. * * This NEEDS to be overridden. * * @param addressID The NodeAddressID to accept from */ // package-private protected static LinkServer create(NodeAddressID addressID) { if(!(addressID instanceof TCPIPAddressID)) throw new IllegalArgumentException("Unable to start TCPIPLinkServer, wrong type of address."); TCPIPAddressID add = (TCPIPAddressID) addressID; InetAddress ipAdd = add.getHost(); int port = add.getPort(); TCPIPLinkServer ls; try { ServerSocket serverSocket = new ServerSocket(port, QUEUE_LENGTH, ipAdd); ls = new TCPIPLinkServer(serverSocket, addressID.isGloballyUnique()); new ProcessManager(ls).start(ProcessManager.PRIORITY_MAX); } catch(IOException e) { Node.info.log(TCPIPLinkServer.class, e.getMessage()); ls = null; } return ls; } /** * Stops the LinkServer. * * This NEEDS to be overridden. */ protected boolean stop() { try { Node.info.log(this, "Trying to stop TCP/IP V4 LinkServer listening on " + getLinkServerAddressID()); serverSocket.close(); } catch(IOException e) { e.printStackTrace(); } return true; } /*----------------------Attributes--------------------------------------------*/ /** * The socket to accept from. */ private final ServerSocket serverSocket; private static int QUEUE_LENGTH = 10; }jcsp-1.1-rc4.orig/src/org/jcsp/net/tcpip/TCPIPAddressID.java0000644000000000000000000001751211105701167020321 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.tcpip; import java.net.*; import org.jcsp.net.*; /** *

Provides a concrete implementation of the abstract NodeAddressID for use with the * TCP/IP link protocol. A TCP/IP node address consists of an internet host address (IP address) * and 16bit IP port number.

* * @author Quickstone Technologies Limited */ public class TCPIPAddressID extends NodeAddressID { /*----------------------Constructors------------------------------------------*/ /** * Creates a TCPIPAddressID for a computer, given it's IP address * and port number. * * @param host The computer's IP address. * @param port The computer's port number, in the range 0-65535 inclusive. * @param isUnique True if the address ID is globally unique, false otherwise. * * @throws IllegalArgumentException If the port is invalid. */ public TCPIPAddressID(InetAddress host, int port, boolean isUnique) throws IllegalArgumentException { if ((port > 0xFFFF) || (port < 0)) throw new IllegalArgumentException("new ComputerID(): Port must be < 65536 and >= 0"); if (host == null) throw new NullPointerException("new ComputerID: null host InetAddress!"); this.host = host; this.port = port; //Store a String represenation of host and port //the port stored as hex StringBuffer buf = new StringBuffer(19); buf.append(Integer.toHexString(0xFFFF & port)); while (buf.length() < 4) buf.insert(0, '0'); StringBuffer ipBuf = new StringBuffer(17); ipBuf.insert(0, host.getHostAddress()); while (ipBuf.length() < 15) ipBuf.append(' '); buf.insert(0, ipBuf); if (isUnique) buf.append("T"); else buf.append("F"); stringForm = buf.toString(); } /** * Creates a TCPIPAddressID for a computer, given it's host name * and port number. * * @param host The computer's IP address, as a string * @param port The computer's port number. * * @throws IllegalArgumentException If the port is invalid. * @throws UnknownHostException If the host name cannot be resolved. */ public TCPIPAddressID(String host, int port, boolean isUnique) throws IllegalArgumentException, UnknownHostException { this(InetAddress.getByName(host), port, isUnique); } /*----------------------Public Methods----------------------------------------*/ /** * Constructs and returns a TCPIPv4 NodeAddressID from a String. * The String MUST be in the form of that returned from the * getStringForm method. * * @param stringForm The String form representing a NodeAddressID. * @throws IllegalArgumentException if the string is incorrectly formatted. */ public static NodeAddressID getAddressIDFromString(String stringForm) throws IllegalArgumentException { if(stringForm == null || stringForm.length() < 20) throw new IllegalArgumentException("Illegal String"); String ipString = stringForm.substring(0,15).trim(); String portString = stringForm.substring(15,19); int port; try { port = Integer.parseInt(portString,16); } catch (NumberFormatException ex) { // oops throw new IllegalArgumentException("Unable to create TCPIPv4 AddressID - Bad Port"); } String sUnique = stringForm.substring(19); boolean isUnique = sUnique.equals("T"); //this method used to thrown the UnknownHostException, however //this does not compile under jdk 1.4 due to superclass' static //method not throwing this try { return new TCPIPAddressID(ipString, port, isUnique); } catch (UnknownHostException e) { throw new RuntimeException(e.getMessage()); } } /** * Returns a string representation of the address suitable for use in the createAddressID * method of TCPIPProtocolID. */ protected String getStringForm() { return stringForm; } /** * Returns the ProtocolID for this address */ public ProtocolID getProtocolID() { return protocolID; } /** * Returns the computer's IP address * * @return IP address of server. */ public final InetAddress getHost() { return host; } /** * Returns the computer's port number for incoming link requests. * * @return Port number of server. */ public final int getPort() { return port; } /** * Compares two TCPIPAddressID for equality. * * @return true iff obj is a non-null TCPIPAddressID for the same port & * host, false otherwise. */ public final boolean equals(Object obj) { if ((obj == null) || !(obj instanceof TCPIPAddressID)) return false; TCPIPAddressID other = (TCPIPAddressID)obj; return (other.port == port) && (host.equals(other.host)); } /** * Returns a hashCode for this TCPIPAddressID * */ public final int hashCode() { return host.hashCode() + (port << 16); } public boolean isGloballyUnique() { return isUnique; } /** * Returns a string representation of this TCPIPAddressID, in the form * "123.45.67.234:5678". * * @return A string representation of this ComputerID. */ public final String toString() { return host.getHostAddress() + ":" + port; } /*----------------------Attributes--------------------------------------------*/ private InetAddress host; private final int port; private ProtocolID protocolID = new TCPIPProtocolID(); private String stringForm; private boolean isUnique = false; }jcsp-1.1-rc4.orig/src/org/jcsp/net/Specification.java0000644000000000000000000000707511105701167017363 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** * * @author Quickstone Technologies Limited. */ class Specification implements Serializable { Specification(String name, int intValue) { this.name = name; this.intValue = intValue; strValue = ""; dblValue = -1; booValue = false; type = Integer.TYPE; } Specification(String name, String strValue) { this.name = name; this.strValue = strValue; intValue = -1; dblValue = -1; booValue = false; type = String.class; } Specification(String name, double dblValue) { this.name = name; this.dblValue = dblValue; intValue = -1; strValue = ""; booValue = false; type = Double.TYPE; } Specification(String name, boolean booValue) { this.name = name; this.booValue = booValue; intValue = -1; strValue = ""; dblValue = -1; type = Boolean.TYPE; } public boolean equals(Object o) { if(o == null || !(o instanceof Specification)) return false; Specification other = (Specification) o; return type.equals(other.type) && name.equals(other.name) && intValue == other.intValue && strValue.equals(other.strValue) && dblValue == other.dblValue && booValue == other.booValue; } public int hashCode() { return name.hashCode(); } final Class type; final String name; final int intValue; final String strValue; final double dblValue; final boolean booValue; }jcsp-1.1-rc4.orig/src/org/jcsp/net/LinkLostException.java0000644000000000000000000000547411105701167020222 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * An exception caused by a link underlying a channel breaking. * * @author Quickstone Technologies Limited. */ public class LinkLostException extends RuntimeException { /** * The object which threw this exception. */ Object source; /** * Get the object which threw this exception. This could be a channel * or any other distributed construct. * * @return The object which broke. */ Object getSource() { return source; } /** * Constructor. */ public LinkLostException(Object source) { this.source = source; } /** * Constructor. * * @param description Description of the error. */ public LinkLostException(Object source, String description) { super(description); this.source = source; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetBufferedChannelEndFactory.java0000644000000000000000000000545511105701167022244 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.util.ChannelDataStore; /** * This interface defines methods for constructing buffered * Networked ChannelInput objects. * * @author Quickstone Technologies Limited */ public interface NetBufferedChannelEndFactory { /** * Constructs a NetAltingChannelInput object. * * @param buffer the ChannelDataStore to use as a buffer. * @return the constructed NetAltingChannelInput object. */ public NetAltingChannelInput createNet2One(ChannelDataStore buffer); /** * Constructs a NetSharedChannelInput object. * * @param buffer the ChannelDataStore to use as a buffer. * @return the constructed NetSharedChannelInput object. */ public NetSharedChannelInput createNet2Any(ChannelDataStore buffer); }jcsp-1.1-rc4.orig/src/org/jcsp/net/ProtocolID.java0000644000000000000000000001437111105701167016616 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; import java.util.*; /** *

* Abstract class that identifies a protocol. * Provides methods for obtaining the protocol's Builder to be * installed in the LinkFactory, starting a LinkServer for this * protocol and for creating a NodeAddressID for this protocol * from a String. *

*

* Protocols must not make use of the NodeID so that protocols can be installed before the node ID * is determined. The current definition of TCPIPv4 protocol meets this criteria. Such a change * will allow the UIFactory or other initialisation details to be obtained from a central server. *

* * @author Quickstone Technologies Limited */ public abstract class ProtocolID implements Serializable { /** * This tests whether another object is equal to this object. * Two ProtocolID objects are equal if their classes are the same. * This is a default implementation, it is probably more efficient to * override this with an implementation that uses the instanceof operator. * @param o an object to compare with this object. * @return true iff the supplied object's class is the same as * the class of this object. */ public boolean equals(Object o) { Class thisClass = this.getClass(); Class otherClass = o.getClass(); return thisClass.equals(otherClass); } /** * Returns a hash code for this object. * * @return the hash code for the object. */ public final int hashCode() { return this.getClass().hashCode(); } /** *

* Not currently used. *

*

* This is envisaged to be used if a protocol that is in use and needs to be * removed sometime in the future. This will stop any further use of the * protocol. *

* * @return boolean indicating whether protocol is active. */ public abstract boolean isActive(); /** *

* Returns whether the protocol requires user interaction in order for * data to be delivered. There could be a protocol that writes data * out to floppy disk or CD-R (see Tanenbaum's example of bandwidth and * lorry!). *

* * @return boolean indicating whether user interaction is required. */ public abstract boolean requiresUserInteraction(); /** * Sets the position of this protocol in the order of general preference. * * @param position the position of this protocol in the order. */ final void setPosition(int position) { this.position = position; } /** * Gets the position of this protocol in the order of preference. * * @return the order of preference as an int. */ public final int getPosition() { return position; } /** * Obtains the Builder for this protocol. Provides a Hashtable that can * can contain settings needed to construct the Link. * * @param settings Hashtable containing settings. * @return the Builder for constructing Links. */ protected abstract LinkFactory.Builder getLinkBuilder(Hashtable settings); /** *

* Constructs, starts and returns a LinkServer on a * specified NodeAddressID. *

* * @return the constructed LinkServer * @param addressID The address for the server to listen on. * @throws IllegalArgumentException if the supplied NodeAddressID is invalid. */ protected abstract LinkServer startLinkServer(NodeAddressID addressID) throws IllegalArgumentException; /** * Constructs a NodeAddressID from a String. * * @return the constructed NodeAddressID * @param stAddressID The address in String form. * @param uniqueAddress boolean indicating whether address is unique. * @throws IllegalArgumentException if the String supplied is invalid. */ protected abstract NodeAddressID createAddressID(String stAddressID, boolean uniqueAddress) throws IllegalArgumentException; /** * The position in the order of preference of protocols. */ private int position = 0; }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetConnectionFactory.java0000644000000000000000000000656611105701167020705 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* This class should be implemented by classes wishing to act * as factories for creating Networked ConnectionServer * and ConnectionClient objects. *

*

* An implementation is provided, see * {@link StandardNetConnectionFactory}. *

* @author Quickstone Technologies Limited */ public interface NetConnectionFactory { /** *

* Constructs a NetAltingConnectionServer object. *

* * @return the constructed NetAltingConnectionServer object. */ public NetAltingConnectionServer createNet2One(); /** *

* Constructs a NetSharedConnectionServer object. *

* * @return the constructed NetSharedConnectionServer object. */ public NetSharedConnectionServer createNet2Any(); /** *

* Constructs a NetAltingConnectionClient object. *

* * @return the constructed NetAltingConnectionClient object. */ public NetAltingConnectionClient createOne2Net(NetChannelLocation serverLoc); /** *

* Constructs a NetSharedAltingConnectionClient object. *

* * @return the constructed NetSharedAltingConnectionClient object. */ public NetSharedAltingConnectionClient createAny2Net(NetChannelLocation serverLoc); }jcsp-1.1-rc4.orig/src/org/jcsp/net/ApplicationID.java0000644000000000000000000001073611105701167017261 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** *

* A Class whose instances represent a unique identifier for a JCSP.NET application. * An application is defined as being a process network that forms a complete program. * Applications have a parent Node which is the Node on which the application was started. *

*

* For a full explanation, see {@link AbstractID}. *

* @author Quickstone Technologies Limited */ public class ApplicationID extends AbstractID implements Serializable { private NodeID nodeID; private int appID; ApplicationID(NodeID nodeID, int appID) { this.nodeID = nodeID; this.appID = appID; } /** *

* Returns a String representation of this object. * The current implemenation returns a human readable * String which shows the application's home * NodeID and the integer application id. *

* * @return the String representing this Application ID. */ public String toString() { return "Application " + " " + nodeID + " " + appID; } /** *

* Compares the supplied Object with this * ApplicationID. *

* @param o another Object to compare with * this ApplicationID. * @return true iff the parameter o is an * ApplicationID that represents the * same application as this object. */ public boolean equals(Object o) { if (o == null || !(o instanceof ApplicationID)) return false; ApplicationID other = (ApplicationID)o; if (nodeID.equals(other.nodeID)) return appID == other.appID; return false; } /** *

* Returns a hash code for this Object. Two equal * ApplicationID objects return the same hash code. *

* @return an int hash code. */ public int hashCode() { return nodeID.hashCode() + appID; } boolean onSameBranch(AbstractID abstractID) { if (abstractID == null) return false; if (abstractID instanceof ApplicationID) return this.equals(abstractID); return nodeID.onSameBranch(abstractID); } /** * Returns the parent NodeID of this * object. * * @return the parent NodeID. */ public AbstractID getParentID() { return nodeID; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/LinkManager.java0000644000000000000000000006646311105701167017001 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; import org.jcsp.util.*; import java.util.*; /** * This class manages the list of open links. It ensures that there is * only ever one link between two given JCSP servers.

* * @author Quickstone Technologies Limited. */ // package-private class LinkManager implements CSProcess { /*-------------------Singleton Class Instance---------------------------------*/ private static LinkManager instance = new LinkManager(); /*-------------------Private Constructor--------------------------------------*/ LinkManager() { ProcessManager pm = new ProcessManager(loopbackLink); pm.setPriority(ProcessManager.PRIORITY_MAX); pm.start(); } /*----------------------Attributes--------------------------------------------*/ /** * The active links. This is a hashtable where the key is a * NodeID and the value is a Link. * * @see NodeID * @see Link */ private Hashtable linkHolders = new Hashtable(); /** * This maps Link objects to a channel that is used to receive notification * that the link has been established. This is necessary for when * links are created to Nodes where the NodeID is not known. This means that * a link holder cannnot be created as they are identified by the remote * NodeID of the links they hold. * * This would typically be used when establishing a connection to the * CNS Server as the NodeID would not be known until after the connection is * made. */ //private Hashtable synchChannels = new Hashtable(); /** * The LoopBackLink used for local connections. * */ private LoopbackLink loopbackLink = new LoopbackLink(); private final Any2OneConnection registerConn = Connection.createAny2One(); private final Any2OneChannel requestLink = Channel.any2one(); private final Any2OneChannel lostLinkChan = Channel.any2one(); private final Any2OneChannel linkFailureChan = Channel.any2one(); private final Any2OneChannel checkForLink = Channel.any2one(); private final Any2OneChannel getNodeIDChan = Channel.any2one(); private final Any2OneChannel registerEventChannel = Channel.any2one(); private static final int ALT_LOST_LINK = 0; private static final int ALT_LINK_FAIL = 1; private static final int ALT_REG_CHAN = 2; private static final int ALT_REQ_LINK = 3; private static final int ALT_CHECK_FOR_LINK = 4; /*----------------------Methods-----------------------------------------------*/ /** Used to run the LinkManager. */ public void run() { Node.info.log(this, "Running"); //Start a process to hand event channel registration and //distribution of events final Any2OneChannel sendEvent = Channel.any2one(new Buffer(10)); CSProcess eventProc = new CSProcess() { public void run() { Alternative alt = new Alternative(new Guard[] {registerEventChannel.in(), sendEvent.in()}); Vector eventChans = new Vector(); while (true) { switch(alt.fairSelect()) { case 0: eventChans.add(registerEventChannel.in().read()); break; case 1: final ChannelOutput[] chans = new ChannelOutput[eventChans.size()]; final Object eventToSend = sendEvent.in().read(); eventChans.toArray(chans); new ProcessManager(new CSProcess() { public void run() { //the channels have infinite buffers //so ok to just use one thread. for (int i=0; i 0 ) { registerServer.replyAndClose(Boolean.TRUE); success = true; } } } else { //This Node was connected to from another Node. //create a linkHolder for the target LinksToNodeHolder lh = new LinksToNodeHolder(id); linkHolders.put(id, lh); lh.addLink(conn, true); registerServer.replyAndClose(Boolean.TRUE); success = true; } if (!success) registerServer.replyAndClose(Boolean.FALSE); if (success) Node.info.log(this, "Link established to " + id); break; } case ALT_REQ_LINK: { //Link Request //create a new scope LinkRequest lr = (LinkRequest)requestLink.in().read(); final ChannelOutput channel = lr.replyChan; final NodeID target = lr.target; final Profile linkProfile = lr.linkProfile; LinksToNodeHolder lhTemp = (LinksToNodeHolder) linkHolders.get(target); if(lhTemp == null) { //create a linkHolder for the target lhTemp = new LinksToNodeHolder(target); linkHolders.put(target, lhTemp); } final LinksToNodeHolder lh = lhTemp; //join a queue for the link, if one already exists then //the Link will be sent straight down the channel if(lh.joinQueue(channel, linkProfile)) { //Need to initiate the link new ProcessManager(new CSProcess() { public void run() { Link conn = LinkFactory.getInstance().makeLink(target, linkProfile); if(conn != null) { //run the connection in the same process //as this ProcessManager pm = new ProcessManager(conn); pm.setPriority(ProcessManager.PRIORITY_MAX); pm.run(); } else { //notify all those waiting that Link //establishment has failed LinkEstablishmentException exc = new LinkEstablishmentException( "No matching can be " + "established.", lh, linkProfile); linkFailureChan.out().write(exc); } } }).start(); } } break; case ALT_CHECK_FOR_LINK: { LinkCheck lc = (LinkCheck) checkForLink.in().read(); final ChannelOutput channel = lc.replyChan; final NodeID target = lc.target; channel.write(linkHolders.get(target)); } break; } } catch (Exception e) { Node.err.log(this, e); } } } /** * Starts this instance of the LinkManager and returns. */ public void start() { new ProcessManager(this).start(); } /** * Get the singleton instance of LinkManager. * * @return The singleton LinkManager object. */ // package-private static LinkManager getInstance() { return instance; } /** * Register a Link in the database. Prevents duplicates. * Returns true if there was no prior entry for that NodeID, and one * was added. (In that case it has also notified any waiting processes). * Returns false (and does not change the database) if there is an * existing entry. * * @return true iff there was no prior entry for that NodeID */ //package-private - only called from Link. boolean registerLink(Link conn) { Node.info.log(this, "register link " + conn); ConnectionClient cc = registerConn.client(); cc.request(conn); return ((Boolean)cc.reply()).booleanValue(); } void registerFailure(Link conn) { Node.err.log(this, "Link failed to be established: " + conn); linkFailureChan.out().write(conn); } /** * Get a channel to use to send to a remote PC. Will block (possibly * forever) while the link is being established. * * @param target The system to connect to. * @return The Channel to use to send to the requested computer. * @throws IllegalStateException If init() has not been called. */ // package-private ChannelOutput getTxChannel(NodeID target) { return getLink(target, null).getTxChannel(); } ChannelOutput getTxChannel(NodeID target, Profile linkProfile) { return getLink(target, linkProfile).getTxChannel(); } /** * This is used to get a Link when no details are known about the other * Node except for one of its addresses. A typical situation when this * would be used is to connect to the CNS. * * @param targetAddress The address to which to create a link. * @return the ChannelOuput that writes to the link. */ ChannelOutput getTxChannel(NodeAddressID targetAddress) { Node.getInstance().checkInitialized(); Link link = LinkFactory.getInstance().makeLink(targetAddress); if(link != null) { NodeID remoteNodeID = link.obtainNodeID(); if(remoteNodeID != null) { return getTxChannel(remoteNodeID); } } return null; } /** * Get a Link to a remote PC. Will block (possibly forever) while * the link is being established. * * @param target The system to connect to. * @return The Link to the requested computer. * @throws IllegalStateException If init() has not been called. */ private Link getLink(NodeID target, Profile linkProfile) { Node.getInstance().checkInitialized(); if(Node.getInstance().isThisNode(target)) //attempt to get a link to the local Node - return the LoopbackLink return loopbackLink; One2OneChannel channel = Channel.one2one(new InfiniteBuffer()); requestLink.out().write(new LinkRequest(channel.out(), target, linkProfile)); Link conn = null; Object obj = channel.in().read(); if(obj instanceof Link) conn = (Link) obj; else if(obj instanceof ProfileMatchFailureException) throw new IllegalStateException("No matching link exists."); else throw new IllegalStateException("No matching link exists."); return conn; } /** * Called by a Link to indicate the link broke. * * @param conn The broken link. */ int lostLink(Link conn) { lostLinkChan.out().write(conn); return IndexManager.getInstance().broadcastLinkLost(new LinkLost(conn)); } /** * This method tests whether a link exists to * a specified remote Node in this LinkManager. * * @param otherNode The NodeID of a remote Node to check * the existance * @return true iff a link currently exists to * the specified remote Node. */ boolean linkExists(NodeID otherNode) { Node.getInstance().checkInitialized(); One2OneChannel channel = Channel.one2one(new InfiniteBuffer()); checkForLink.out().write(new LinkCheck(channel.out(), otherNode)); return (channel.in().read() != null); } AltingChannelInput getLinkLostEventChannel() { Node.getInstance().checkInitialized(); final One2OneChannel eventChan = Channel.one2one(new InfiniteBuffer()); registerEventChannel.out().write(eventChan.out()); //this should be a Safe channel return eventChan.in(); } /*----------------------Inner Classes-----------------------------------------*/ private static class LinksToNodeHolder { public LinksToNodeHolder(NodeID target) { this.target = target; } public Link getLink(Profile profile) { if(profile == null) { if(linkWithNoSpecifiedFacilities != null) return linkWithNoSpecifiedFacilities; } else { Iterator it = links.iterator(); while(it.hasNext()) { Link l = (Link) it.next(); //test whether the link meets the profile's requirements Specification[] linkSpecs = l.getSpecifications(); int matches = profile.matches(linkSpecs); //if so, return it if(matches == 1) return l; else if(!profile.requiresExactMatch() && matches == 0) return l; } } return null; } public NodeID getTarget() { return target; } /** * This sends the supplied link to any processes that are waiting for * matching link. If there were some processes waiting or the * addIfNoQueue parameter was true, then the link is * added to this link manager. * * @param link the Link to add. * @param addIfNoQueue boolean inidicating whether to add the link * if there were no queued processes. * * @return the number of processes to which this link was sent. */ public int addLink(Link link, boolean addIfNoQueue) { Specification[] specs = link.getSpecifications(); int noNotified = notifyQueuedProcesses(specs, link); if(noNotified > 0 || addIfNoQueue) { //if link has not specs or it uses the favoured protocol //set it as the the link with no specified facilities if(specs == null || specs.length == 0 || link.getProtocolID().getPosition() == 0) linkWithNoSpecifiedFacilities = link; links.add(link); } return noNotified; } public int notifyQueuedProcesses(Profile profile, Object toSend) { if(profile == null) profile = Profile.getAlwaysMatchProfile(); Object queue = waiting.get(profile); int notifyCount = 0; if (queue != null) { if (queue instanceof Vector) { Vector v = (Vector) queue; for (int i = 0; i < v.size(); i++) { ChannelOutput ch = ((ChannelOutput)v.elementAt(i)); ch.write(toSend); } } else { ChannelOutput ch = ((ChannelOutput)queue); ch.write(toSend); } notifyCount++; waiting.remove(profile); } return notifyCount; } /** * This takes a set of link specifications, looks through the set of * queues, checks whether the specifications meet requirements of * the profile of a queue, and if so, sends the supplied Link to the * processes in that queue. * * The method returns the number of queues that were notified. * * @param specs an array of Specifcation objects that * the link provides. * @param linkToSend the link to send to the queued processes. * * @return the number of queues that were notified. */ public int notifyQueuedProcesses(Specification[] specs, Link linkToSend) { int notifyCount = 0; Iterator it = waiting.keySet().iterator(); while(it.hasNext()) { Profile profile = (Profile) it.next(); //check whether the specs match the profile int matchValue = 0; if (profile != null) matchValue = profile.matches(specs); Object toSend = null; if(profile == null || matchValue == 1 ||(matchValue == 0 && !profile.requiresExactMatch())) { notifyCount++; toSend = linkToSend; } else if(profile != null) { if(linkToSend.getProfile().equals(profile)) toSend = new ProfileMatchFailureException(); } if(toSend != null) { //the profile matches the specs if(profile == null) profile = Profile.getAlwaysMatchProfile(); Object queue = waiting.get(profile); if (queue != null) { if (queue instanceof Vector) { Vector v = (Vector) queue; for (int i = 0; i < v.size(); i++) { ChannelOutput ch = ((ChannelOutput)v.elementAt(i)); ch.write(toSend); } } else { ChannelOutput ch = ((ChannelOutput)queue); ch.write(toSend); } } it.remove(); } } return notifyCount; } public void removeLink(Link conn) { links.remove(conn); } /** * This method allows processes to join a queue waiting for a link * to a Node (with a known NodeID) to be established. An infinite * buffered channel is supplied. When it is known that a link has * been created or failed to be created, notification can be sent down * the supplied channel to the waiting process. * * There is one queue per link required matching matching a given * profile. When a link is established, the profile of each queue * is tested against the link and, if the profile matches, then all * queued processes are notified. This can mean that multiple links to * a remote Node might be established but by the time a link has been * established, there may be no processes waiting for it as other links * may have met their requirements. * * @param channel the channel to put in the queue. * @param profile the profile that the required link must meet. * * @return a boolean inidicating whether the channel is the first * in the queue and hence the link needs to be initiated. */ public boolean joinQueue(ChannelOutput channel, Profile profile) { boolean initiate = false; Link link = getLink(profile); if(profile == null) profile = Profile.getAlwaysMatchProfile(); if(link != null) channel.write(link); else if (waiting.containsKey(profile)) { Object o = waiting.get(profile); Vector v; if (o instanceof Vector) v = (Vector) o; else { v = new Vector(); v.add(o); } v.add(channel); waiting.put(profile, v); initiate = false; } else { waiting.put(profile, channel); initiate = true; } return initiate; } private NodeID target; private HashSet links = new HashSet(); /** * A link with no special facilities. This is so that if no features * are required then no iteration will be needed. * */ private Link linkWithNoSpecifiedFacilities = null; /** * The processes waiting for a link. * The key is the FacilitiesRequired of the link we're waiting for, * the value is the channel to the waiting process * (or a Vector of these). When the link is available, we notify the * process(es) by sending the Link down the channel(s). */ private Hashtable waiting = new Hashtable(); } private static class ProfileMatchFailureException extends Exception { public ProfileMatchFailureException() { } public ProfileMatchFailureException(String msg) { super(msg); } } public static class LinkEstablishmentException extends RuntimeException { private LinkEstablishmentException(String msg, LinksToNodeHolder lh, Profile profile) { super(msg); this.lh = lh; this.profile = profile; } private LinksToNodeHolder lh; private Profile profile; } private static class LinkRequest { LinkRequest(ChannelOutput replyChan, NodeID target, Profile linkProfile) { this.replyChan = replyChan; this.target = target; this.linkProfile = linkProfile; } final ChannelOutput replyChan; final NodeID target; final Profile linkProfile; } private static class LinkCheck { LinkCheck(ChannelOutput replyChan, NodeID target) { this.replyChan = replyChan; this.target = target; } final ChannelOutput replyChan; final NodeID target; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Message.java0000644000000000000000000000752011105701167016162 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.Serializable; import org.jcsp.lang.ChannelOutput; /** *

* Message to be transmitted. This is an abstract class containing * only header information - you must subclass it to use it. *

*

* This is a package-private implementation class. *

* * @author Quickstone Technologies Limited */ // package-private abstract class Message implements Serializable { public Message() { } static final PingMessage PING_MESSAGE = new PingMessage(); static final PingReplyMessage PING_REPLY_MESSAGE = new PingReplyMessage(); public final void bounce(ChannelOutput txChannel) { BounceMessage msg = new BounceMessage(); msg.destIndex = sourceIndex; msg.sourceIndex = -1; txChannel.write(msg); } /** * The destination channel index. * * @serial */ // package-private long destIndex; String destVCNLabel; /** * The source channel index. * * @serial */ // package-private long sourceIndex; /** * The source computer address. This is not transmitted, instead, it * is filled in automatically by the demux on arrival. (Indeed, it * is not usually even filled in at the sending end). */ // package-private transient NodeID sourceID; /** * The channel for transmitting replies. It doesn't make sense to * transmit this value (or even to bother to fill it in at the * transmitting end), so it is filled in automatically by the demux * on arrival. */ // package-private transient ChannelOutput txReplyChannel; public static class BounceMessage extends Message { private BounceMessage() { } } public static class PingMessage extends Message { } public static class PingReplyMessage extends Message { } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Net2AnyChannel.java0000644000000000000000000001356711105701167017357 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.ProcessManager; import org.jcsp.lang.RejectableBufferedOne2AnyChannel; import org.jcsp.lang.RejectableChannel; import org.jcsp.lang.RejectableOne2AnyChannel; import org.jcsp.util.ChannelDataStore; /** * A channel for network input (RX). This is a "Net2Any" channel, * which can be safely used by multiple readers on the same Node. * * @author Quickstone Technologies Limited */ class Net2AnyChannel implements NetSharedChannelInput, Networked { /*-----------------Attributes-------------------------------------------------*/ /** * The channel name. */ private final String label; /** * The local channel used for output from the recieving process */ private RejectableChannel ch; private NetChannelInputProcess netChannelInputProcess; public Net2AnyChannel(String label) throws NullPointerException { if (label == null) throw new NullPointerException("Label supplied is null"); if (label != "") Node.info.log(this, "Creating a channel with VCN label: " + label); ch = new RejectableOne2AnyChannel(); netChannelInputProcess = new NetChannelInputProcess(label,ch); this.label = label; } /** *

* Creates an anonymous input channel. *

*

* To create writers that write to this channel, you need to call * getChannelName() to get a valid name for this channel. You * will need to use some other means (e.g. a named channel) to pass * the channel name to the writing computer. *

*/ public Net2AnyChannel() { ch = new RejectableOne2AnyChannel(); this.label = null; netChannelInputProcess = new NetChannelInputProcess(label,ch); new ProcessManager(netChannelInputProcess).start(); } /** *

* Creates an anonymous, buffered input channel. *

*

* To create writers that write to this channel, you need to call * getChannelName() to get a valid name for this channel. You * will need to use some other means (e.g. a named channel) to pass * the channel name to the writing computer. *

* * @param buffer The ChannelDataStore to use. */ public Net2AnyChannel(ChannelDataStore buffer) { ch = new RejectableBufferedOne2AnyChannel(buffer); netChannelInputProcess = new NetChannelInputProcess(null,ch); this.label = null; new ProcessManager(netChannelInputProcess).start(); } /** * * * * */ public Net2AnyChannel(String label, ChannelDataStore buffer) { if (label == null) throw new NullPointerException("Label supplied is null"); if (label != "") Node.info.log(this, "Creating a channel with VCN label: " + label); this.label = label; ch = new RejectableBufferedOne2AnyChannel(buffer); netChannelInputProcess = new NetChannelInputProcess(label,ch); new ProcessManager(netChannelInputProcess).start(); } /** * Read data from this channel. This can safely be called by * multiple readers. * * @return The object read from the network. */ public Object read() { return ch.in().read(); } public Object startRead() { return ch.in().startRead(); } public void endRead() { ch.in().endRead(); } /** * Currently, network channels are unpoisonable so this method has no effect. */ public void poison(int strength) { } public NetChannelLocation getChannelLocation() { return new NetChannelLocation(Node.getInstance().getNodeID(), netChannelInputProcess.getChannelIndex()); } public Class getFactoryClass() { return StandardNetChannelEndFactory.class; } public void destroyReader() { netChannelInputProcess.breakChannel(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/jcsp-config.dtd0000644000000000000000000000643010520670125016630 0ustar jcsp-1.1-rc4.orig/src/org/jcsp/net/ChannelID.java0000644000000000000000000001242111105701167016357 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** * * @author Quickstone Technologies Limited. */ class ChannelID implements Serializable { /*-------------------Constructor----------------------------------------------*/ /** * Creates a ChannelID for a channel. * * @param nodeID The host node. * @param index the channel index. */ public ChannelID(NodeID nodeID, long index) { this.nodeID = nodeID; this.index = index; } ChannelID(String stringForm) throws IllegalArgumentException { if(stringForm == null) throw new IllegalArgumentException("null"); int colonIndex = stringForm.indexOf(":",STRING_FORM_PREFIX.length()); if(!stringForm.startsWith(STRING_FORM_PREFIX)) throw new IllegalArgumentException("Invalid String provided"); String channelIndexString = stringForm.substring(STRING_FORM_PREFIX.length(),colonIndex); try { index = Long.parseLong(channelIndexString); } catch (NumberFormatException e) { throw new IllegalArgumentException("Channel Index not a number"); } nodeID = NodeID.createFromStringForm(stringForm.substring(colonIndex + 1)); } /*-------------------Public Methods-------------------------------------------*/ /** * This returns a ChannelID created from its String form as returned by * the getStringForm method. * * @param stringForm the String to use to create the ChannelID. * @return the recreated ChannelID. */ static ChannelID createFromStringForm(String stringForm) throws IllegalArgumentException { return new ChannelID(stringForm); } /** * This returns a String representation of this ChannelID. The ChannelID * can be recreated by calling the createFromString method. * * @return the String representing this ChannelID. */ String getStringForm() { return STRING_FORM_PREFIX + index + ":" + nodeID.getStringForm(); } /** * Returns the channel's NodeID. * * @return the channel's NodeID. */ public final NodeID getNodeID() { return nodeID; } /** * Returns the channel's index number. * * @return the channel's index number. */ public final long getIndex() { return index; } /** * Compares two ChannelIDs for equality. * * @param obj Another Object to compare with this Object. * @return true iff obj is a non-null ChannelID which represents the * same channel. */ public final boolean equals(Object obj) { if ((obj == null) || !(obj instanceof ChannelID)) return false; ChannelID other = (ChannelID)obj; return (index == other.index && (nodeID.equals(other.getNodeID()))); } /** Returns a human readable string representation of the current instance of this class. * @return a human readable String object. */ public String toString() { return nodeID + "--" + index; } /*-------------------Private Attributes---------------------------------------*/ private NodeID nodeID; private long index; private static final String STRING_FORM_PREFIX = "ChannelID:"; }jcsp-1.1-rc4.orig/src/org/jcsp/net/StandardNetChannelEndFactory.java0000644000000000000000000001204211105701167022250 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.util.ChannelDataStore; /** * A standard implementation of the JCSP.NET * Networked channel factory interaces. * * @author Quickstone Technologies Limited */ public class StandardNetChannelEndFactory implements NetChannelEndFactory, NetLabelledChannelEndFactory, NetBufferedChannelEndFactory, NetLabelledBufferedChannelEndFactory { private static StandardNetChannelEndFactory instance = new StandardNetChannelEndFactory(); private final Profile linkProfile; public StandardNetChannelEndFactory() { linkProfile = null; } /** * Creates a factory that creates links using a given profile rather than the default one. */ public StandardNetChannelEndFactory(Profile profile) { linkProfile = profile; } public static StandardNetChannelEndFactory getDefaultInstance() { return instance; } /** * @see org.jcsp.net.NetChannelEndFactory#createNet2One() */ public NetAltingChannelInput createNet2One() { return Net2OneChannel.create(); } /** * @see org.jcsp.net.NetLabelledChannelEndFactory#createNet2One(String) */ public NetAltingChannelInput createNet2One(String label) { return Net2OneChannel.create(label); } /** * @see org.jcsp.net.NetBufferedChannelEndFactory#createNet2One(ChannelDataStore) */ public NetAltingChannelInput createNet2One(ChannelDataStore buffer) { return Net2OneChannel.create(buffer); } /** * @see org.jcsp.net.NetLabelledBufferedChannelEndFactory#createNet2One(String, ChannelDataStore) */ public NetAltingChannelInput createNet2One(String label, ChannelDataStore buffer) { return Net2OneChannel.create(label, buffer); } /** * @see org.jcsp.net.NetChannelEndFactory#createNet2Any() */ public NetSharedChannelInput createNet2Any() { return new Net2AnyChannel(); } /** * @see org.jcsp.net.NetLabelledChannelEndFactory#createNet2Any(String) */ public NetSharedChannelInput createNet2Any(String label) { return new Net2AnyChannel(label); } /** * @see org.jcsp.net.NetBufferedChannelEndFactory#createNet2Any(ChannelDataStore) */ public NetSharedChannelInput createNet2Any(ChannelDataStore buffer) { return new Net2AnyChannel(buffer); } /** * @see org.jcsp.net.NetLabelledBufferedChannelEndFactory#createNet2Any(String, ChannelDataStore) */ public NetSharedChannelInput createNet2Any(String label, ChannelDataStore buffer) { return new Net2AnyChannel(label, buffer); } /** * @see org.jcsp.net.NetChannelEndFactory#createOne2Net(NetChannelLocation) */ public NetChannelOutput createOne2Net(NetChannelLocation loc) { return new One2NetChannel(loc, linkProfile); } /** * @see org.jcsp.net.NetChannelEndFactory#createAny2Net(NetChannelLocation) */ public NetSharedChannelOutput createAny2Net(NetChannelLocation loc) { return new Any2NetChannel(loc, linkProfile); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetChannelLocation.java0000644000000000000000000003635411105701167020315 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.Serializable; /** *

* Instances of this class hold location information for a networked * ChannelInput object. Instances of the class hold sufficient * information for a networked ChannelOutput object to establish * a connection to the networked ChannelInput object. *

*

* Instances of this class may either be constructed by the * jcsp.net user or by the networking infrastructure. *

* @author Quickstone Technologies Limited */ public class NetChannelLocation implements Cloneable, Serializable { /*----------------Constructors-----------------------------------------------*/ /** *

* Constructor which takes the NodeID of the Node hosting * the networked ChannelInput object and the label assigned * to the channel's Virtual Channel Number (VCN). *

* * @param channelNode the NodeID of the Node hosting the * read end of the channel. * @param channelLabel the label assigned to the channel's Virtual * Channel Number (VCN). */ public NetChannelLocation(NodeID channelNode, String channelLabel) throws IllegalArgumentException { if (channelNode == null || channelLabel == null) throw new IllegalArgumentException ("A null parameter supplied"); this.channelLabel = channelLabel; this.vcn = IndexManager.getInvalidVCN(); this.channelNode = channelNode; this.channelAddress = null; } /** *

* Constructor which takes a NodeAddressID on which the * channel's Node is listening and the label assigned to the channel's * Virtual Channel Number (VCN). *

*

* This constructor is intended to be used by code that wishes to connect * to a ChannelInput running on a Node to which a * Link has not yet been established. An address of the Node * must be known by some means. For example, with a JCSP network running * over TCP/IP, a program may prompt the user for an IP address to which * to connect. *

* @param channelAddress a NodeAddressID on which the channel's * Node is listening. * @param channelLabel the label assigned to the channel's VCN. */ public NetChannelLocation(NodeAddressID channelAddress, String channelLabel) throws IllegalArgumentException { if (channelAddress == null || channelLabel == null) throw new IllegalArgumentException("A null parameter supplied"); this.channelLabel = channelLabel; this.vcn = IndexManager.getInvalidVCN(); this.channelNode = null; this.channelAddress = channelAddress; } /** *

* Package private constructor which takes the NodeID of the * Node hosting the networked ChannelInput object and a * long holding the VCN of the channel. *

*

* Users of the jcsp.net package cannot use this constructor. * It is intended to be used by the infrastructure for creating an instance * of the class in order to return it to the user. *

*

* When used like this, the class may seem to be the same as the * ChannelID class, however, this class is publicly * visible outside the jcsp.net. *

* * @param channelNode the NodeID of the Node hosting the * read end of the channel. * @param vcn the VCN of the channel * */ NetChannelLocation(NodeID channelNode, long vcn) throws IllegalArgumentException { if (channelNode == null || !IndexManager.checkIndexIsValid(vcn)) throw new IllegalArgumentException("A null NodeID or invalid VCN was supplied"); this.channelLabel = null; this.vcn = vcn; this.channelNode = channelNode; this.channelAddress = null; } /** *

* This is a protected constructor which takes another * NetChannelLocation object and "clones" it into this one. * This allows sub-classes to adopt the field values of an instance of * this class by passing a reference of it to this constructor. *

* * @param other Another NetChannelLocation to "clone" * into this one. * @throws IllegalArgumentException iff the parameter is null. */ protected NetChannelLocation(NetChannelLocation other) throws IllegalArgumentException { refreshFrom(other); } /*----------------Fields-----------------------------------------------------*/ /** * The label, if any, assigned to a channel's VCN. */ private String channelLabel; /** * The VCN of a channel, if known. */ private long vcn; /** * The NodeID of the channel's Node. * This should be null if channelAddress is * not null. */ private NodeID channelNode; /** * The NodeAddressID on which the channel's Node is listening. * This should be null if channelNode is * not null. */ private NodeAddressID channelAddress; /*----------------Public Methods---------------------------------------------*/ /** *

* Public accessor for the channel label property. *

* * @return the channel label held by the instance of this object, * if exists or else null. * */ public final String getChannelLabel() { return channelLabel; } /** *

* Public accessor for the channel's address, if held. *

* * @return a NodeAddressID on which the channel's Node is * listening. If the channel's Node's NodeID is * known, then this will return null. * */ public final NodeAddressID getChannelAddress() { return channelAddress; } /** *

* Public accessor for the channel label property. *

* * @return the NodeID of the channel's Node, if known, * else null. * */ public final NodeID getChannelNodeID() { return channelNode; } /** *

* This method requests that the instance of this class refresh * its information. This class does not actually do anything when * this method is called, however, instances of subclasses may take the * opportunity to refresh their data. *

*

* An example, of when this might be useful is if this class were * extended as part of a name service that resolves names to * NetChannelLocation objects. If a user of an instance * of this extended version wanted to check that the data were still * up to date, it would call this method which would then check the * information with a name service. *

* * @return true if any information has changed, otherwise * false. * * */ public boolean refresh() { //does not do anything - this is for subclasses to implement return false; } /* It is not necessary to be able to create a labelled VCN for a channel that will migrate. Labelled * VCNs should only be used as a bootstrapping mechanism (eg for an alternative CNS service). If there * is a possibility of a channel end moving then the CNS should be used. */ /** *

* Returns a String ID for this * NetChannelLocation object. *

*

* This method does not need to be used by normal JCSP users. *

* * @return the id. */ public final String getStringID() { if (channelNode == null) throw new IllegalStateException("Unable to provide an ID for a " + "NetChannelLocation with null NodeID"); if (channelLabel != null) throw new IllegalStateException("Unable to provide an ID for a NetChannelLocation with an unresolved label"); return channelNode + " " + Long.toString(vcn); } /*----------------Public Methods from Cloneable Interface--------------------*/ /** *

* Returns a clone of the instance of this class. All mutable fields * are also cloned. *

* * @return a clone of the instance of this class. * */ public Object clone() throws CloneNotSupportedException { NetChannelLocation clone = (NetChannelLocation)super.clone(); //either the channelNode or channelAddress should be null if (channelNode != null) { clone.channelNode = (NodeID) channelNode.clone(); clone.channelAddress = null; } else { clone.channelNode = null; clone.channelAddress = (NodeAddressID) channelAddress.clone(); } return clone; } /*----------------Methods overriden from Object------------------------------*/ /** *

* Returns whether this object is equal to another object. *

* * @return true iff the supplied object is equal. */ public final boolean equals(Object o) { if (o == null || !(o instanceof NetChannelLocation)) return false; NetChannelLocation other = (NetChannelLocation) o; boolean equal = true; if (this.channelAddress != null && other.channelAddress != null) equal = channelAddress.equals(other.channelAddress); else if (!(this.channelAddress == null && other.channelAddress == null)) equal = false; if (equal) { if (this.channelLabel != null && other.channelLabel != null) equal = channelLabel.equals(other.channelLabel); else if (!(this.channelLabel == null && other.channelLabel == null)) equal = false; } if (equal) { if (this.channelNode != null && other.channelNode != null) equal = channelNode.equals(other.channelNode); else if (!(this.channelNode == null && other.channelNode == null)) equal = false; } return equal && this.vcn == other.vcn && checkEqual(other); } /** * Return a hashcode for this object. * * @return the int hash code. */ public final int hashCode() { return (this.channelNode != null) ? this.channelNode.hashCode() + (int) this.vcn : this.channelAddress.hashCode() + this.channelLabel.hashCode(); } /*----------------Protected Methods------------------------------------------*/ /** *

* This method refreshes the fields in the instance of this object to * equal the fields in the supplied object. Only members of the * NetChannelLocation class are copied and not members * added by sub-classes. *

* * @param other Another NetChannelLocation to "clone" * into this one. * @throws IllegalArgumentException iff the parameter is null. */ protected final void refreshFrom(NetChannelLocation other) throws IllegalArgumentException { this.channelAddress = other.channelAddress; this.channelLabel = other.channelLabel; this.channelNode = other.channelNode; this.vcn = other.vcn; } /** *

* This method is used by the equals(Object) method * to determine whether another object is equal to the one on which * it is invoked. *

*

* This should be used by sub-classes as they cannot override the * equals method. *

* * @param other the NetChannelLocation object to * compare with this object. * @return true if the other object is equal to this one. */ protected boolean checkEqual(NetChannelLocation other) { return true; } /*----------------Package level Methods--------------------------------------*/ /** *

* Package level accessor for the channel's VCN if held. * Users of jcsp.net should not have any control over VCN * allocation so this accessor is not publicly accessible. *

* * @return the VCN value held for the channel. * */ long getVCN() { return vcn; } /** *

* Package level mutator for the channel's actual location details. * The details can only be set if the current NodeID held is null. *

* * @param nodeID the NodeID of the channel. * @param vcn the VCN of the channel. */ void setLocationDetails(NodeID nodeID, long vcn) { if (this.channelNode == null) { this.channelNode = nodeID; this.vcn = vcn; this.channelLabel = null; this.channelAddress = null; } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Any2NetChannel.java0000644000000000000000000001364211105701167017351 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.Serializable; /** * A channel for network output (TX). This is a "Any2Net" channel, * which can be safely used by multiple writers. *

* Note that this is merely a thread-safe wrapper around * {@link One2NetChannel} * * @see One2NetChannel * @author Quickstone Technologies Limited */ class Any2NetChannel implements NetSharedChannelOutput, Serializable { /***********Constructors******************************************************/ /** * Equivalent to the (NetChannelLocation) constructor of * One2NetChannel. * * @see One2NetChannel */ public Any2NetChannel(NetChannelLocation channelLocation) { impl = new One2NetChannel(channelLocation); } /** * Equivalent to the (NetChannelLocation, boolean) constructor * of One2NetChannel. * * @see One2NetChannel */ public Any2NetChannel(NetChannelLocation channelLocation, boolean acknowledged) { impl = new One2NetChannel(channelLocation, acknowledged); } /** * Equivalent to the (NetChannelLocation, Profile) constructor * of One2NetChannel. * * @see One2NetChannel */ public Any2NetChannel(NetChannelLocation channelLocation, Profile linkProfile) { impl = new One2NetChannel(channelLocation, linkProfile); } /** * Equivalent to the (NetChannelLocation, boolean, Profile) * constructor of One2NetChannel. * * @see One2NetChannel */ public Any2NetChannel(NetChannelLocation channelLocation, boolean acknowledged, Profile linkProfile) { impl = new One2NetChannel(channelLocation, acknowledged, linkProfile); } /***********Private fields****************************************************/ /** * Implementation */ private One2NetChannel impl; /***********Public Methods****************************************************/ /** * Output data to this channel. The data must be Serializable. *

* Note that this is merely a thread-safe wrapper around * {@link One2NetChannel#write(Object)} - see that method for full * documentation. * * @param data The data to send over the channel. The object should implement the Serializable interface in order to be sent over a network. */ public void write(Object data) { synchronized (impl) { impl.write(data); } } /** * Public accessor for obtaining the location of the read * end of this channel. * * @return a NetChannelLocation object containing * information needed to connect to */ public NetChannelLocation getChannelLocation() { return impl.getChannelLocation(); } /** * Requests that the channel recreates itself and reconnects to the * other end of the channel. */ public void recreate() { synchronized (impl) { impl.recreate(); } } /** * Requests that the channel recreates itself and reconnects * to the other end of the channel. A new reader location * must be supplied. * * @param loc the new location of the reader. */ public void recreate(NetChannelLocation loc) { synchronized (impl) { impl.recreate(loc); } } /** * Destroys the write end of a channel and frees any resources * used within the JCSP networking infrastructure. * */ public void destroyWriter() { synchronized (impl) { impl.destroyWriter(); } } public Class getFactoryClass() { return StandardNetChannelEndFactory.class; } /** * Currently, network channels are unpoisonable so this method has no effect. */ public void poison(int strength) { } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NodeFactory.java0000644000000000000000000000516011105701167017011 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** * Node initialisation factory interface. A specific initialisation can be written by implementing * this interface and passing an instance to the factoryInit method of * Node. * * @author Quickstone Technologies Limited */ public interface NodeFactory extends Serializable { /* * Initialises the node passed and returns the resulting NodeKey for the caller * to subsequently use. * * @return the NodeKey of the Node or null * if initialization failed. */ public NodeKey initNode(Node node, Node.Attributes attribs) throws NodeInitFailedException; }jcsp-1.1-rc4.orig/src/org/jcsp/net/LinkLost.java0000644000000000000000000000521711105701167016336 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.ChannelOutput; /** * Message warning that a Link broke. * *

This is a package-private implementation class. * * @author Quickstone Technologies Limited */ // package-private public class LinkLost { /** * The broken Link's transmit channel. */ // package-private final ChannelOutput txChannel; /** * The broken Link's computer address. */ // package-private final NodeID address; /** * Constructor. * * @param conn The broken Link. */ // package-private LinkLost(Link conn) { txChannel = conn.getTxChannel(); address = conn.getRemoteNodeID(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/0000755000000000000000000000000011410045050015342 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/OutputReconnectionManagerCNSImpl.java0000644000000000000000000002556111105701167024557 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.*; import org.jcsp.net.cns.*; /** * Implementation of the output reconnection manager that uses a CNS service to track channel ends. * If this class is used for the output end, InputReconnectionManagerCNSImpl should be * used at the input end. * * @author Quickstone Technologies Limited */ /* NOTE: * The reconnection manager can be created with a cnsServiceName for channels that do not use the * default CNS service. For channels using the default CNS service, cnsServiceName should be null * and not set to the default service name. Any code in this class requiring behaviours from the CNS * service should check the value of this attribute and call the default CNS directly if it is null * and resolve the service name otherwise. This gives an efficiency gain. * * The CNS service name is tracked so that channels registered with a non-default CNS under one JVM * will not become mapped to the default CNS under peer JVMs following communication of a channel end. * * If the user passes an invalid service name to the constructor, an exception will only be raised when * a channel movement occurs (a NullPointerException). A possible modification would be to look up the * service name at construction time and raise an exception if it does not exist. * * Doesn't work for non-acknowledged channels. Either warn users of this or provide factory methods * for migratable channels that ensures the local writing end is acknowledged. */ class OutputReconnectionManagerCNSImpl implements OutputReconnectionManager { /** * Underlying networked channel output end. */ private transient NetChannelOutput chanOut; /** * Constant specifying the maximum number of retry attempts before aborting a write operation. */ private final int maxAttemptCount = 10; /** * true iff the object can be serialized and sent (migrated) to another node. */ private transient boolean serializable = false; /** * Name of the CNS service to use. */ private String cnsServiceName; /** * Constructs a new OutputReconnectionManagerCNSImpl with the given underlying * networked channel output end. The default CNS service name will be used. * * @param out underlying networked channel end. */ public OutputReconnectionManagerCNSImpl(NetChannelOutput out) { this(out, null); } /** * Constructs a new OutputReconnectionManagerCNSImpl with the given underlying * networked channel output end using a specific CNS service. * * @param out the underlying networked channel end. * @param cnsServiceName name of the CNS service to use. */ public OutputReconnectionManagerCNSImpl(NetChannelOutput out, String cnsServiceName) { super(); this.chanOut = out; this.cnsServiceName = cnsServiceName; } /** * @see org.jcsp.net.dynamic.OutputReconnectionManager#getOutputChannel() */ public NetChannelOutput getOutputChannel() { if(chanOut == null) return null; return new NetChannelOutput() { public void write(Object value) { try { chanOut.write(value); } catch(LinkLostException e) { dealWithWriteError(value, e); } catch (ReaderIndexException e) { dealWithWriteError(value, e); } catch(ChannelDataRejectedException e) { dealWithWriteError(value, e); } } public NetChannelLocation getChannelLocation() { return chanOut.getChannelLocation(); } public void recreate() { chanOut.recreate(); } public void recreate(NetChannelLocation newLoc) { chanOut.recreate(newLoc); } public void destroyWriter() { chanOut.destroyWriter(); } public Class getFactoryClass() { return null; } /** * Currently, network channels are unpoisonable so this method has no effect. */ public void poison(int strength) { } }; } /** * Attempts to resolve the new channel location. This method is called when a write error occurs * because the destination is no longer valid. The CNS service is queried to find out where the * other channel end moved to. A number of attempts to write to the new location are made. If these * fail, the channel is recreated. If the number of retry attempts exceeds the limit set by * maxAttemptCount the write is considered to have failed and the original exception * is rethrown. * * @param value the data value that the user was trying to write and that should be written. * @param e the exception originally raised to be thrown if the channel cannot be reconnected. */ private void dealWithWriteError(Object value, RuntimeException e) { boolean written = false; int attemptCount = 1; if (!(this.chanOut.getChannelLocation() instanceof CNSNetChannelLocation)) { //the channel did not obtain location information from the CNS String cnsRegisteredName = InputReconnectionManagerCNSImpl.anonymousCnsNamePrefix + chanOut.getChannelLocation().getStringID(); NetChannelLocation newLoc = (cnsServiceName == null) ? CNS.resolve(cnsRegisteredName) : ((CNSUser)Node.getInstance().getServiceUserObject(cnsServiceName)) .resolve(cnsRegisteredName); chanOut.recreate(newLoc); } else chanOut.recreate(); while((!written) && (attemptCount < maxAttemptCount)) { try { chanOut.write(value); written = true; } catch (LinkLostException e2) { chanOut.recreate(); attemptCount++; } catch (ReaderIndexException e2) { chanOut.recreate(); attemptCount++; } catch (ChannelDataRejectedException e2) { chanOut.recreate(); attemptCount++; } } if(!written) throw e; } /** * @see org.jcsp.net.dynamic.OutputReconnectionManager#prepareToMove() */ public void prepareToMove() { if(serializable) return; if(chanOut != null) serializable = true; } /** * Serializes this object to the output stream. Before moving this channel end, prepareToMove * should be called. * * @param out destination stream to serialize to. * @throws IOException if there is a problem with the output stream. */ private void writeObject(ObjectOutputStream out) throws IOException { if(!serializable) throw (new NotSerializableException(this.getClass().getName())); if(chanOut != null) { if(chanOut instanceof Serializable) { out.writeInt(1); out.writeObject(chanOut); //free up resources in JCSP networked infrastructure this.chanOut.destroyWriter(); } else throw (new NotSerializableException(this.getClass().getName())); } out.writeInt(3); } /** * Deserializes this object from an input stream. * * @param in input stream to read the object from. * @throws IOException if there is a problem with the input stream. * @throws ClassNotFoundException if the class definition for the channel implementation cannot be * found. This is only likely to occur if there are different versions * of the infrastructure library on each node. */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { int i = in.readInt(); if(i < 3) { switch(i) { case 1: { chanOut = (NetChannelOutput)in.readObject(); i = in.readInt(); break; } } } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/MigratableChannelOutputImpl.java0000644000000000000000000001711311105701167023624 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.IOException; import java.util.Vector; import org.jcsp.net.NetChannelLocation; import org.jcsp.net.NetChannelOutput; import org.jcsp.util.filter.Filter; import org.jcsp.util.filter.FilteredChannelOutput; /** * Implements of a migratable networked channel output end. * * @author Quickstone Technologies Limited */ class MigratableChannelOutputImpl implements MigratableChannelOutput { /** * The output reconnection manager for the channel. */ private OutputReconnectionManager mgr; /** * The actual networked output channel end. */ private transient NetChannelOutput actualOut; /** * The filtered channel end. */ private transient FilteredChannelOutput filteredOut; /** * The filters applied to the channel. */ private Vector filters = null; /** * MigratableChannelOutputImpl objects constructed with * this constructor make use of the default channel name service. * * @param out the underlying networked channel output. */ public MigratableChannelOutputImpl(NetChannelOutput out) { this(new OutputReconnectionManagerCNSImpl(out)); } /** * Constructs a new MigratableChannelOutputImpl with the given reconnection manager. * * @param mgr the reconnection manager to use for the channel. */ public MigratableChannelOutputImpl(OutputReconnectionManager mgr) { super(); this.mgr = mgr; actualOut = mgr.getOutputChannel(); if (actualOut == null) throw new NullPointerException("Output channel provided is null"); filteredOut = MigratableAltingChannelInputImpl.FACTORY.createFiltered(actualOut); } /** * @see org.jcsp.net.dynamic.MigratableChannelOutput#prepareToMove() */ public void prepareToMove() { mgr.prepareToMove(); } /** * @see org.jcsp.net.NetChannelOutput#recreate() */ public void recreate() { actualOut.recreate(); } /** * @see org.jcsp.net.NetChannelOutput#recreate(NetChannelLocation) */ public void recreate(NetChannelLocation newLoc) { actualOut.recreate(newLoc); } /** * @see org.jcsp.net.NetChannelOutput#destroyWriter() */ public void destroyWriter() { actualOut.destroyWriter(); } /** * @see org.jcsp.lang.ChannelOutput#write(Object) */ public void write(Object object) { if(actualOut == null) { actualOut = mgr.getOutputChannel(); if (actualOut == null) throw new NullPointerException("Output channel provided is null"); filteredOut = MigratableAltingChannelInputImpl.FACTORY.createFiltered(actualOut); } filteredOut.write(object); } /** * @see org.jcsp.net.Networked#getChannelLocation() */ public NetChannelLocation getChannelLocation() { return actualOut.getChannelLocation(); } public Class getFactoryClass() { return null; } /** * @see org.jcsp.util.filter.WriteFiltered#addWriteFilter(Filter) */ public void addWriteFilter(Filter filter) { if (filteredOut == null && filters != null) filters.addElement(filter); filteredOut.addWriteFilter(filter); } /** * @see org.jcsp.util.filter.WriteFiltered#addWriteFilter(Filter, int) */ public void addWriteFilter(Filter filter, int index) { if (filteredOut == null && filters != null) filters.add(index, filter); filteredOut.addWriteFilter(filter, index); } /** * @see org.jcsp.util.filter.WriteFiltered#removeWriteFilter(Filter) */ public void removeWriteFilter(Filter filter) { if (filteredOut == null && filters != null) filters.remove(filter); filteredOut.removeWriteFilter(filter); } /** * @see org.jcsp.util.filter.WriteFiltered#removeWriteFilter(int) */ public void removeWriteFilter(int index) { if (filteredOut == null && filters != null) filters.remove(index); filteredOut.removeWriteFilter(index); } /** * @see org.jcsp.util.filter.WriteFiltered#getWriteFilter(int) */ public Filter getWriteFilter(int index) { if (filteredOut == null && filters != null) return (Filter)filters.elementAt(index); return filteredOut.getWriteFilter(index); } /** * @see org.jcsp.util.filter.WriteFiltered#getWriteFilterCount() */ public int getWriteFilterCount() { if (filteredOut == null && filters != null) return filters.size(); return filteredOut.getWriteFilterCount(); } private void writeObject(java.io.ObjectOutputStream out) throws IOException { //the filtered channel input object used by this class is a //transient field. This code extracts the filters from the //filter channel input and stores them into a Filter[] field. //They are resinserted into a new filtered channel input on the //first call to read() if (filteredOut != null) { filters = new Vector(filteredOut.getWriteFilterCount()); for (int i=0; i < filteredOut.getWriteFilterCount(); i++) filters.addElement(filteredOut.getWriteFilter(i)); } //writes all non-transient variables to the output stream out.defaultWriteObject(); } /** * Currently, network channels are unpoisonable so this method has no effect. */ public void poison(int strength) { } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/JFTP.java0000644000000000000000000005302211105701167016763 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.*; import java.net.*; import java.util.*; import java.util.jar.*; import java.util.zip.*; import org.jcsp.lang.*; import org.jcsp.net.*; /** *

A server process for dispatching binary images of classes to nodes that do not hold suitable * definitions locally. An instance of this process is started for a node by the DynamicClassLoader * service. A request channel is connected to this process through which remote nodes can request * images of classes.

* *

Classes can be retrieved from individual .class files in the class path or from a * Java archive. The current implementation does not support compressed archives. If a file from an * archive is requested, the remote node will be sent a manifest listing all of the other classes * available in the archive. This allows the remote node to better determine where to request classes * from in the case of objects being passed through a lengthy pipeline of nodes.

* *

Once a remote node has requested a file from an archive the rest of the archive will be queued * for dispatch to that node. This preemptive forwarding of information can give more reliable * performance by increasing the likelihood of a node passing on all of the definitions its peers * might require before it terminates.

* * @author Quickstone Technologies Limited */ class JFTP implements CSProcess { /** * Constructs a new JFTP process. * * @param classLoader the class loader to obtain resources held locally from. * @param req the request channel for communication with other nodes. * @param cm the local class manager responsible for classes dynamically loaded by this node. */ public JFTP(ClassLoader classLoader, AltingChannelInput req, ClassManager cm) { this.classLoader = classLoader; this.req = req; this.cm = cm; } /** * Main process thread, servicing requests sent on the req channel. Once a request is * received, a process will be spawned to complete the operation and allow another node to be * serviced. Where possible, requests for the same class are combined so that it is only loaded * once. */ public void run() { final One2OneChannel toQueueFlusher = Channel.one2one(), fromQueueFlusher = Channel.one2one(); final AltingChannelInput notifyIn = classNotify.in(), queueIn = classQueue.in(), flushNotifyIn = fromQueueFlusher.in(); final ChannelOutput notifyOut = classNotify.out(), queueOut = classQueue.out(); // This process will be sent class names from the output queue. It will look up the // class file and pass the result back on the notify channel. Any nodes that are marked // as needing this file will then be sent it. new ProcessManager(new QueuedClassLoaderProcess(toQueueFlusher.in(), notifyOut, queueOut, fromQueueFlusher.out())).start(); final Alternative alt = new Alternative(new Guard[] { queueIn, notifyIn, req, flushNotifyIn, new Skip() }); final boolean cond[] = new boolean[] { true, true, true, true, true }; boolean queueEnable = true; int queueCount = 0; while(true) { try { cond[4] = queueEnable && (queueCount > 0); switch (alt.priSelect(cond)) { case 0 : { // Request added to queue. The class request has not actually been issued by // a node yet. It has been generated by the loader as the node has requested // another class from the same archive. ClassRequest cr = (ClassRequest)queueIn.read(); ChanSet cs = (ChanSet)outputQueue.get(cr.className); if (cs == null) { cs = new ChanSet(cr.replyChan); outputQueue.put(cr.className, cs); queueCount++; } else cs.addRequest(cr.replyChan); break; } case 1 : { // Notification of class loaded // Send the class to all waiting processes. The class has now been loaded. // All nodes that requested the class (or were marked as wanting it as a // result of a manifest check) are sent it and the class is removed from the // output queue. ClassReply cr = (ClassReply)notifyIn.read(); ChanSet cs = (ChanSet)outputQueue.remove(cr.className); cs.writeToAll(cr); break; } case 2 : { // Request for a class // Tag the node onto an existing request if there is one. Start a new thread // to load the class. Starting a new thread solves the priority problem. A // thread is not started if the class is already being processed by another // unless a manifest is requested. If a thread is not started, the requesting // node will receive the data when the other thread sends it on the notify // channel. final ClassRequest cr = (ClassRequest) req.read(); Node.info.log(this, "JFTP Received a request for " + cr.className); ChanSet cs = (ChanSet)outputQueue.get(cr.className); final boolean loadManifest, loadClass; if (cs == null) { // No one else is waiting for the class, so create a response object // and start a process to go and get the class cs = new ChanSet(cr.replyChan); loadClass = true; loadManifest = ((cr.flags & CR_WANT_MANIFEST) != 0); outputQueue.put(cr.className, cs); } else { cs.addRequest(cr.replyChan); if (cs.isBeingProcessed()) { if ((cr.flags & CR_WANT_MANIFEST) != 0) { loadClass = false; loadManifest = true; } else loadClass = loadManifest = false; } else { loadClass = true; loadManifest = ((cr.flags & CR_WANT_MANIFEST) != 0); } } if (loadClass || loadManifest) { cs.nowBeingProcessed(); new ProcessManager (new CSProcess() { public void run() { findAndLoadClass(cr.className, loadClass, loadManifest, cr.replyChan, notifyOut, queueOut); } }).start(); } break; } case 3 : { // Previous queued retrieval has completed; allow another flushNotifyIn.read(); queueEnable = true; break; } case 4 : { // Try and push some data queueEnable = false; // suppress this guard until operation completed // by process sending a message on notify channel Enumeration e = outputQueue.keys(); String className = null; ChanSet cs = null; // Find a class that isn't being loaded for anyone do { if (!e.hasMoreElements()) { cs = null; break; } className = (String)e.nextElement(); cs = (ChanSet)outputQueue.get(className); } while (cs.isBeingProcessed()); if (cs == null) { queueCount = 0; break; } else queueCount--; cs.nowBeingProcessed(); toQueueFlusher.out().write(className); // When the queued class loader process finishes this class it will send a // value on the flushNotify channel which will reenable this guard. break; } } } catch (Exception e) { Node.err.log(this, "Error ignored"); Node.err.log(this, e); } } } /** * Child process spawned by the run() method of JFTP to retrieve a class * that has been queued for output to another node. */ private class QueuedClassLoaderProcess implements CSProcess { private final ChannelInput classIn; private final ChannelOutput notifyOut; private final ChannelOutput queueOut; private final ChannelOutput flushOut; public QueuedClassLoaderProcess(ChannelInput classIn, ChannelOutput notifyOut, ChannelOutput queueOut, ChannelOutput flushOut) { this.classIn = classIn; this.notifyOut = notifyOut; this.queueOut = queueOut; this.flushOut = flushOut; } public void run() { while (true) { String cn = (String)classIn.read(); findAndLoadClass(cn, true, false, null, notifyOut, queueOut); flushOut.write(null); } } } /** *

Attempts to load a class using the local class loader. If the class was not found locally, the * class manager is queried - the class might have been dynamically loaded. If the class manager has * an image for the file it is sent. If the class manager has marked the class as pending then it * will issue a request to the originating node's JFTP process.

* *

If the class is loaded locally from a Java archive, a manifest is generated and returned with * the class to the client. The other contents of the archive are then queued for transmission to * the client. If the class was dynamically loaded by this node and a manifest was received, this * manifest is forwarded to the client.

* * @param className name of the class to find. * @param wantClass true iff the binary image for the class is required. * @param wantManifest true iff a manifest reply is required. * @param toRequestingClient manifest replies to the client are sent on this channel. * @param notifyOthers the ClassReply is sent on this channel for dispatch to all clients needing it. * @param queueFurtherRequest if loading from an archive, new class requests are generated for the client on this channel. */ private void findAndLoadClass(String className, boolean wantClass, boolean wantManifest, ChannelOutput toRequestingClient, ChannelOutput notifyOthers, ChannelOutput queueFurtherRequest) { Node.info.log(this, "Beginning " + ((toRequestingClient == null) ? "preemptive " : "") + "load for " + className); try { String filename = className.replace('.', File.separatorChar) + ".class"; URL url = classLoader.getResource(filename); if (url != null) { if (wantManifest) { String uStr = url.toString(); if (uStr.startsWith("jar:file:")) { // This is a JAR file - create and send a manifest try { uStr = uStr.substring(9, uStr.indexOf('!')); JarFile jf = new JarFile(uStr); Enumeration e = jf.entries(); String[] manifest = new String[jf.size()]; int index = 0; for (int i = 0; i < manifest.length; i++) { String n = ((ZipEntry)e.nextElement()).getName(); if (n.endsWith(".class")) { String cn = n.substring(0, n.length() - 6); queueFurtherRequest.write(new ClassRequest(cn, toRequestingClient, CR_WANT_CLASS)); manifest[index++] = cn; } } toRequestingClient.write(new JarManifestReply(manifest)); } catch (IOException e) { } } } if (wantClass) { // Get the single file requested InputStream fileFound = url.openStream(); int size = fileFound.available(); byte[] fileBytes = new byte[size]; fileFound.read(fileBytes, 0, size); // Dispatch the file to all waiting processes notifyOthers.write(new ClassReply(className, fileBytes)); } } else { // Not held locally; perhaps our class manager has it ... JarManifestReply jmr = cm.checkForPendingClass(className); byte[] fileBytes = cm.getClassBytes(className); if (fileBytes != null) { if ((jmr != null) && (wantManifest)) { // Forward manifest of other files from the same source for (int i = 0; i < jmr.elements.length; i++) if (jmr.elements[i] != null) queueFurtherRequest.write(new ClassRequest(jmr.elements[i], toRequestingClient, CR_WANT_CLASS)); toRequestingClient.write(jmr); } if (wantClass) // Dispatch the file to all waiting processes notifyOthers.write(new ClassReply(className, fileBytes)); } else { if (wantClass) // Dispatch the error to all waiting processes notifyOthers.write(new ClassReply(className, null)); } } } catch (Throwable e) { if (wantClass) // Dispatch the error to all waiting processes notifyOthers.write(new ClassReply(className, null)); } } /** * Child processes spawned to load classes from disk or from another node pass the loaded data on * this channel to the main process fror forwarding to the requesting clients. */ private final Any2OneChannel classNotify = Channel.any2one(); /** * Child processes spawned to load classes from Java archives will create additional requests on * this channel to queue other files from the archive to be sent to a client. */ private final Any2OneChannel classQueue = Channel.any2one(); /** * Incoming requests from the clients. */ private final AltingChannelInput req; /** * The default class loader to get locally held classes from. */ private final ClassLoader classLoader; /** * The local class manager for tracking classes that were dynamically loaded by this node. */ private final ClassManager cm; /** * Queues (and combines) requests for classes by clients. Associates String class * names with ChanSet objects that contain the ClassRequest objects. */ private final Hashtable outputQueue = new Hashtable(); /** * Flag for indicating in a ClassRequest that a manifest is required. */ public static final int CR_WANT_MANIFEST = 0x0001; /** * Flag for indicating in a ClassRequest that the class image is required. */ public static final int CR_WANT_CLASS = 0x0002; /** * Implementation of a set type structure for holding ChannelOutput objects with * a flag to indicate that the request set is currently being processed. */ private static class ChanSet { /** * Holds the ChannelOutput objects. */ private Vector set; /** * true if a class is currently being loaded. */ private boolean beingProcessed; /** * Constructs a new ChanSet with an initial entry in the set. */ public ChanSet(ChannelOutput out) { set = new Vector(1); set.addElement(out); beingProcessed = false; } /** * Sets the flag to indicate that a class is currently being loaded. */ public void nowBeingProcessed() { beingProcessed = true; } /** * Returns true if a class is being loaded by another thread. */ public boolean isBeingProcessed() { return beingProcessed; } /** * Adds a request (the channel to reply on) to the set. * * @param out channel to send the reply on. */ public void addRequest(ChannelOutput out) { for (int i = set.size() - 1; i >= 0; i--) if (set.elementAt(i) == out) return; set.addElement(out); } /** * Broadcast the reply to all of the clients in the set. * * @param reply the message to send. */ public void writeToAll(ClassReply reply) { for (Enumeration e = set.elements(); e.hasMoreElements(); ) { ChannelOutput out = (ChannelOutput)e.nextElement(); out.write(reply); } } } /** * Represents a class request, indicating the class required, the channel to reply to the client * on and the flags to indicate whether a manifest is also wanted. */ static class ClassRequest implements Serializable { public ClassRequest(String className, ChannelOutput replyChan, int flags) { this.className = className; this.replyChan = replyChan; this.flags = flags; } public final String className; public final ChannelOutput replyChan; public final int flags; } /** * Represents a reply to a client for a loaded class, giving the class name and binary image. */ static class ClassReply implements Serializable { public ClassReply(String className, byte[] fileBytes) { this.className = className; this.fileBytes = fileBytes; } public final String className; public final byte[] fileBytes; } /** * Represents a reply to a client detailing a manifest of an archive. */ static class JarManifestReply implements Serializable { public JarManifestReply(String[] elements) { this.elements = elements; } public final String[] elements; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/SerializedData.java0000644000000000000000000002335711105701167021115 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.*; /** * Serialized form of an object as as part of a DynamicClassLoaderMessage. The object is * serialized to a byte array for transfer to another node. This will allow the message to be * deserialized to obtain the JFTP reference even if the class held here is not available. When the * relevant class has been loaded the data from the byte array can be deserialized. * * @author Quickstone Technologies Limited */ class SerializedData implements Externalizable { /*-------------------Constructors---------------------------------------------*/ /** * This is the public used constructor. It takes an object and attempts * to serialize it. * * @param obj the Object to Serialize. * @param storeToString if true will create a string representation of the serialized object. * @throws NotSerializableException If obj is not Serializable. * @throws IOException if an IO error occurs during Serialization, * should not happen unless there is a bug. */ public SerializedData(Object obj, boolean storeToString) throws NotSerializableException, IOException { if(obj == null) { serializedData = null; if (storeToString) objectToString = "null"; return; } if (storeToString) objectToString = obj.toString(); AccesibleByteArrayOutputStream serializedDataDestination = new AccesibleByteArrayOutputStream(); ObjectOutputStream objOut = new ObjectOutputStream(serializedDataDestination); objOut.writeObject(obj); objOut.flush(); serializedData = serializedDataDestination.getByteArray(); try { serializedDataDestination.close(); objOut.close(); } catch(IOException e) { e.printStackTrace(); } } /** * A private constructor used during the deserialization process of this * object. Externalizable objects require a no-arg constructor so a * replacement object is serialized in this object's place. On * deserialization, this object is reconstructed using this constructor. * * @param data a byte[] containing the serialized data of the object * that this object is holding. * @param objectToString The toString value of the stored object. */ SerializedData(byte[] data, String objectToString) { this.serializedData = data; this.objectToString = objectToString; } /*-------------------Public Methods-------------------------------------------*/ /** * Returns the binary serialized object. */ public byte[] getSerializedData() { return serializedData; } /** * Deserializes the object from the byte[] array and returns it. * * @throws ClassNotFoundException if the class is not available locally and should be requested. * @throws IOException if there is a problem with the stream. */ public Object get() throws ClassNotFoundException, IOException { return get(new BasicInputStreamFactory()); } /** * Deserializes the object from the byte[] array and returns it. * * @param factory the factory for creating the input stream. * @throws ClassNotFoundException if the class is not available locally and should be requested. * @throws IOException if there is a problem with the stream. */ public Object get(InputStreamFactory factory) throws ClassNotFoundException, IOException { if (serializedData == null) return null; ByteArrayInputStream serializedDataSource = new ByteArrayInputStream(serializedData); ObjectInput objIn = factory.create(serializedDataSource); Object obj = objIn.readObject(); try { serializedDataSource.close(); objIn.close(); } catch(IOException e) { e.printStackTrace(); } return obj; } /** * Returns the string form of an object. */ public String getObjectToString() { if(objectToString == null) return ""; return objectToString; } public void writeExternal(ObjectOutput out) throws IOException { } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { } /** * Replaces this object with another during serialization. * * @return the replacement. */ public Object writeReplace() throws ObjectStreamException { ExtClass e = new ExtClass(); e.serializedData = serializedData; e.objectToString = objectToString; return e; } /*-------------------Attributes-----------------------------------------------*/ /** * The binary form of the object in this message. */ private byte[] serializedData; /** * The string representation of the object. */ private String objectToString = null; /*-------------------Inner Classes--------------------------------------------*/ /** * This class exists purely for performance reasons. It provides an * accessor to the internal byte[] and means that it does not need to * be copied. */ private static class AccesibleByteArrayOutputStream extends ByteArrayOutputStream { public byte[] getByteArray() { return buf; } } /** * Factory for creating object input streams. * * @author Quickstone Technologies Limited */ public interface InputStreamFactory { /** * Creates an object input stream based on the given input stream. */ public ObjectInput create(InputStream in) throws IOException; } /** * Implementation of the InputStreamFactory to create a ObjectInputStream. * * @author Quickstone Technologies Limited */ private class BasicInputStreamFactory implements InputStreamFactory { /** * Creates an ObjectInputStream over the top of the given input stream. */ public ObjectInput create(InputStream in) throws IOException { return new ObjectInputStream(in); } } /** * This class exists because the main class cannot have a no-arg * constructor as required by externalizable. * * On serialization, this object replaces the SerializedObject. */ private static class ExtClass implements Externalizable { /** * Constructs a new instance of this class. */ public ExtClass() {} public void writeExternal(ObjectOutput out) throws IOException { if(serializedData == null) out.writeInt(0); else { out.writeInt(serializedData.length); out.write(serializedData, 0, serializedData.length); } out.writeObject(objectToString); } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int arrayLength = in.readInt(); if (arrayLength > 0) { serializedData = new byte[arrayLength]; in.readFully(serializedData); } else serializedData = null; objectToString = (String)in.readObject(); } public Object readResolve() throws ObjectStreamException { return new SerializedData(serializedData, objectToString); } /** * Binary serialized form of the object. */ public byte[] serializedData; /** * String representation of the object. */ public String objectToString = null; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/MigratableChannelEndFactory.java0000644000000000000000000000717511105701167023547 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import org.jcsp.net.*; /** * Factory for creating networked migratable channel ends. An instance of this can be created and * the methods used. Alternatively the static methods in MigratableChannelEnd can be * used to create the channel ends. * * @author Quickstone Technologies Limited */ public class MigratableChannelEndFactory implements NetChannelEndFactory { /** * Default channel factory for creating the underlying channels. */ private static NetChannelEndFactory FACTORY = StandardNetChannelEndFactory.getDefaultInstance(); /** * Constructs a new MigratableChannelEndFactory. */ public MigratableChannelEndFactory() { super(); } /** * @see org.jcsp.net.NetChannelEndFactory#createNet2One() */ public NetAltingChannelInput createNet2One() { return new MigratableAltingChannelInputImpl(FACTORY.createNet2One()); } /** * @see org.jcsp.net.NetChannelEndFactory#createNet2Any() */ public NetSharedChannelInput createNet2Any() { throw new UnsupportedOperationException("Cannot create a shared migratable channel"); } /** * @see org.jcsp.net.NetChannelEndFactory#createOne2Net(NetChannelLocation) */ public NetChannelOutput createOne2Net(NetChannelLocation loc) { return new MigratableChannelOutputImpl(FACTORY.createOne2Net(loc)); } /** * @see org.jcsp.net.NetChannelEndFactory#createAny2Net(NetChannelLocation) */ public NetSharedChannelOutput createAny2Net(NetChannelLocation loc) { throw new UnsupportedOperationException("Cannot create a shared migratable channel"); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/MigratableAltingChannelInputImpl.java0000644000000000000000000001755211105701167024571 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.*; import java.util.Vector; import org.jcsp.net.*; import org.jcsp.util.filter.*; /** * Implements a migratable input channel end that can be used in an Alternative. * * @author Quickstone Technologies Limited */ class MigratableAltingChannelInputImpl extends MigratableAltingChannelInput { /** * Factory for creating filtered channel ends. */ static FilteredChannelEndFactory FACTORY = new FilteredChannelEndFactory(); /** * The actual channel input. This should not be read from. * Use the filteredIn channel. * */ private transient NetAltingChannelInput actualIn; /** * A filtered channel input wrapper that wraps the actualIn * channel. * */ private transient FilteredChannelInput filteredIn; /** * The reconnection manager for the channel. */ private InputReconnectionManager mgr; /** * A Vector of Filter objects that is used during * serialization. * */ private Vector filters = null; /** * Constructor for MigratableAltingChannelInputImpl. * This takes a NetAltingChannelInput and constructs * a default InputReconnectionManager object and then uses * the constructor taking a single InputReconnectionManager * object. * * MigratableAltingChannelInputImpl objects constructed with * this constructor make use of the default channel name service. * * @param in the actual NetAltingChannelInput object to * use. */ public MigratableAltingChannelInputImpl(NetAltingChannelInput in) { this(new InputReconnectionManagerCNSImpl(in)); } /** * Constructs a new MigratableAltingChannelInputImpl with a specified reconnection * manager object. This should have been given the channel when it was constructed. * * @param mgr the reconnection manager. */ public MigratableAltingChannelInputImpl(InputReconnectionManager mgr) { super(mgr.getInputChannel()); actualIn = mgr.getInputChannel(); if (actualIn == null) throw new NullPointerException("Input channel provided is null"); filteredIn = FACTORY.createFiltered(actualIn); this.mgr = mgr; } /** * @see org.jcsp.net.Networked#getChannelLocation() */ public NetChannelLocation getChannelLocation() { return this.mgr.getCurrentLocation(); } /** * Reads an object from the underlying channel. * * @return the object read. */ public Object read() { if(filteredIn == null) { actualIn = mgr.getInputChannel(); super.setChannel(actualIn); filteredIn = FACTORY.createFiltered(actualIn); if (filters != null) { for (int i=0; i < filters.size(); i++) filteredIn.addReadFilter((Filter)filters.elementAt(i)); filters = null; } } Object o = filteredIn.read(); return o; } /** * @see org.jcsp.util.filter.ReadFiltered#addReadFilter(Filter) */ public void addReadFilter(Filter filter) { filteredIn.addReadFilter(filter); } /** * @see org.jcsp.util.filter.ReadFiltered#addReadFilter(Filter, int) */ public void addReadFilter(Filter filter, int index) { filteredIn.addReadFilter(filter, index); } /** * @see org.jcsp.util.filter.ReadFiltered#removeReadFilter(Filter) */ public void removeReadFilter(Filter filter) { filteredIn.removeReadFilter(filter); } /** * @see org.jcsp.util.filter.ReadFiltered#removeReadFilter(int) */ public void removeReadFilter(int index) { filteredIn.removeReadFilter(index); } /** * @see org.jcsp.util.filter.ReadFiltered#getReadFilter(int) */ public Filter getReadFilter(int index) { return filteredIn.getReadFilter(index); } /** * @see org.jcsp.util.filter.ReadFiltered#getReadFilterCount() */ public int getReadFilterCount() { return filteredIn.getReadFilterCount(); } /** * @see org.jcsp.net.NetChannelInputManager#destroyReader() */ public void destroyReader() { actualIn.destroyReader(); } /** * Returns null. */ public Class getFactoryClass() { return null; } /** * @see org.jcsp.dynamic.MigratableChannelInput#prepareToMove() */ public void prepareToMove() { mgr.prepareToMove(); } /** * When serializing object to the output stream, the filters from the underlying channel are * extracted so that they too get serialized. * * @param out the stream to write the object to. */ private void writeObject(ObjectOutputStream out) throws IOException { //the filtered channel input object used by this class is a //transient field. This code extracts the filters from the //filter channel input and stores them into a Filter[] field. //They are resinserted into a new filtered channel input on the //first call to read() if (filteredIn != null) { filters = new Vector(filteredIn.getReadFilterCount()); for (int i=0; i < filteredIn.getReadFilterCount(); i++) filters.addElement(filteredIn.getReadFilter(i)); } //writes all non-transient variables to the output stream out.defaultWriteObject(); } /** * Reads the serialized object from an input stream. The default read implementation is used. * * @param in object source stream. */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/MigratableChannelInput.java0000644000000000000000000000445011105701167022601 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import org.jcsp.net.*; import org.jcsp.util.filter.*; /** * A migratable networked input channel end. * * @author Quickstone Technologies Limited */ public interface MigratableChannelInput extends NetChannelInput, FilteredChannelInput { /** * Prepares the channel end for movement to another node. */ public void prepareToMove(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/NodeClassLoader.java0000644000000000000000000002560111105701167021224 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.util.*; import org.jcsp.lang.*; import org.jcsp.net.*; /** * Custom class loader for retrieving class files from a JFTP process on another node. Each instance * will spawn a child process that will keep running. When a class is requested from the loader, it * will synchronize with the child process which will contact a JFTP process and wait for data. When * the class arrives the original caller will resume and register the class. Using a separate thread * allows the JFTP process to push other classes to the class loader. Any classes pushed in this manner * will be registered when the next class is requested from the class loader. * * @author Quickstone Technologies Limited */ class NodeClassLoader extends ClassLoader { /* loadClass in ClassLoader is synchronized so there can only ever be one pending class * request. If further classes are pushed to the loader thread it will keep them in a collection * until another request arrives. The next request will return an array of JFTP replies for * classes to be registered. This array will include the actual one requested if it is available. */ /** * Child process to communicate with the JFTP process, issuing requests to it and waiting for * replies. */ private static class LoaderThread implements CSProcess { /** * Constructs a new LoaderThread. * * @param sourceChannelLocation location of a JFTP process request channel. * @param classRequest requests for classes will be received on this channel. * @param classResponse when classes have arrived they will be passed out on this channel. * @param deferredLoader the class loader that owns this process which will be associated with * pending classes found in a manifest response. * @param classManager the class manager for managing classes dynamically loaded by this node. */ public LoaderThread(NetChannelLocation sourceChannelLocation, AltingChannelInput classRequest, ChannelOutput classResponse, ClassLoader deferredLoader, ClassManager classManager) { this.sourceChannelLocation = sourceChannelLocation; this.classRequest = classRequest; this.classResponse = classResponse; this.deferredLoader = deferredLoader; this.classManager = classManager; } /** * Main process loop, servicing requests for classes from this node and receiving class replies * from the JFTP process of a remote node. */ public void run() { try { NetChannelOutput out = NetChannelEnd.createOne2Net(sourceChannelLocation); NetAltingChannelInput classIn = NetChannelEnd.createNet2One(); NetChannelOutput classOut = NetChannelEnd.createOne2Net(classIn.getChannelLocation()); Alternative alt = new Alternative(new Guard[] { classIn, classRequest }); LinkedList classesToRegister = new LinkedList(); String classPending = null; Node.info.log(this, "Node class loader for " + sourceChannelLocation + " started"); while (true) { if (alt.priSelect() == 0) { Object objReply = classIn.read(); if (objReply instanceof JFTP.ClassReply) { JFTP.ClassReply cr = (JFTP.ClassReply)objReply; classesToRegister.add(cr); Node.info.log(this, "Definition for " + cr.className + " has arrived"); // Notify a waiting thread if (classPending != null) { if (classPending.equals(cr.className)) { classResponse.write(classesToRegister.toArray()); classesToRegister.clear(); classPending = null; } } } else if (objReply instanceof JFTP.JarManifestReply) { // Mark classes as pending ... JFTP.JarManifestReply jmr = (JFTP.JarManifestReply)objReply; for (int i = 0; i < jmr.elements.length; i++) if (jmr.elements[i] != null) classManager.classPending(jmr.elements[i], deferredLoader, jmr); } } else { // A request to retrieve a class has arrived classPending = (String)classRequest.read(); int mode = JFTP.CR_WANT_CLASS; if (!classManager.pendingClassManifestAvailable(classPending)) mode |= JFTP.CR_WANT_MANIFEST; // Issue request to source node out.write(new JFTP.ClassRequest(classPending, classOut, mode)); } } } catch (Exception e) { Node.err.log(this, e); } finally { Node.info.log(this, "Node class loader for " + sourceChannelLocation + " terminated"); } } /** * Location of a JFTP process request channel. */ private final NetChannelLocation sourceChannelLocation; /** * Requests for classes will be received on this channel. */ private final AltingChannelInput classRequest; /** * When classes have arrived they will be passed out on this channel. */ private final ChannelOutput classResponse; /** * The class loader owning this process which should be associated with classes marked as * pending. */ private final ClassLoader deferredLoader; /** * The class manager for managing classes dynamically loaded by this node. */ private final ClassManager classManager; } /** * Constructs a new NodeClassLoader for loading classes held by a JFTP process at * another node. On construction a child thread is spawned. * * @param sourceChannelLocation location of the request channel of a remote JFTP process. * @param cm class manager responsible for dynamically loaded classes at this node. */ public NodeClassLoader(NetChannelLocation sourceChannelLocation, ClassManager cm) { new ProcessManager(new LoaderThread(sourceChannelLocation, classReq.in(), classResp.out(), this, cm)).start(); classManager = cm; } /** * Issues a request to the child process to get a class definition from the remote JFTP process. * If the JFTP process has been pushing class definitions to this node the child process may return * multiple results. One of them will be the requested class. All will be registered and a note * is taken of the one requested so that it can be returned. * * @param name name of the class to load. * @return the class instance. * @throws ClassNotFoundException if the remote node did not have the class. */ public Class findClass(String name) throws ClassNotFoundException { // Request the class from the loader thread classReq.out().write(name); Object[] replies = (Object[])classResp.in().read(); // Register all of the classes returned by the loader Class found = null; for (int i = 0; i < replies.length; i++) { JFTP.ClassReply reply = (JFTP.ClassReply)replies[i]; if (reply.fileBytes != null) { Class cls; try { cls = defineClass(reply.className, reply.fileBytes, 0, reply.fileBytes.length); classManager.registerClass(cls, reply.fileBytes); } catch (LinkageError e) { cls = loadClass(reply.className); } // Take note of the one actually requested if (reply.className.equals(name)) found = cls; } else Node.info.log(this, "Class " + reply.className + " not available at source node"); } if (found == null) throw new ClassNotFoundException("Class " + name + " not found."); return found; } /** * Channel for passing requests from the findClass method to the child process. */ private final One2OneChannel classReq = Channel.one2one(); /** * Channel for returning data from the child process to the findClass method. */ private final One2OneChannel classResp = Channel.one2one(); /** * The class manager responsible for managing dynamically loaded classes at this node. */ private final ClassManager classManager; }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/NamedMigratableChannelEndFactory.java0000644000000000000000000000674611105701167024517 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import org.jcsp.net.cns.NameAccessLevel; /** * Factory interface for creating migratable networked channel input ends using a CNS service. * * @author Quickstone Technologies Limited */ public interface NamedMigratableChannelEndFactory { /** * Creates a named migratable networked channel input end that can be used as a guard in an Alternative. * * @param name the name to use. * @return the created channel end. */ public MigratableAltingChannelInput createNet2One(String name); /** * Creates a named migratable networked channel input end that can be used as a guard in an Alternative. * * @param name the name to use. * @param nameAccessLevel the namespace to declare the name within. * @return the created channel end. */ public MigratableAltingChannelInput createNet2One(String name, NameAccessLevel nameAccessLevel); /** * Creates a networked migratable channel output end connected to the input end created with the given name. * * @param name the name the input end was created with. * @return the created channel end. */ public MigratableChannelOutput createOne2Net(String name); /** * Creates a networked migratable channel output end connected to the input end created with the given name. * * @param name the name the input end was created with. * @return the created channel end. */ public MigratableChannelOutput createOne2Net(String name, NameAccessLevel accessLevel); }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/package.html0000644000000000000000000000066710520670125017644 0ustar

Supports dynamic operations over the JCSP.NET infrastructure. These include dynamicoading of classes when objects are sent to a node that does not already hold appropriate definitions and the migration of channel ends between nodes without any loss of data.

This package cannot be compiled or run using JDK1.1.

This package is currently in a beta state and the API may be subject to changes.

jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/NamedMigratableChannelEndFactoryImpl.java0000644000000000000000000001153411105701167025330 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import org.jcsp.net.*; import org.jcsp.net.cns.*; /** * Implementation of the factory for creating named migratable networked channel ends. * * @author Quickstone Technologies Limited */ public class NamedMigratableChannelEndFactoryImpl implements NamedMigratableChannelEndFactory { /** * CNS service name to use. */ private String cnsServiceName; /** * CNS user reference. */ private CNSUser cnsUser; /** * Factory to create the underlying networked channel ends. */ private NetChannelEndFactory factoryToUse; /** * Constructs a new NamedMigratableChannelEndFactoryImpl for use with the given * CNS service name. * * @param cnsServiceName the name of the CNS service to use. */ public NamedMigratableChannelEndFactoryImpl(String cnsServiceName) { super(); factoryToUse = StandardNetChannelEndFactory.getDefaultInstance(); this.cnsServiceName = cnsServiceName; cnsUser = (CNSUser)Node.getInstance().getServiceUserObject(cnsServiceName); } /** * Constructs a new NamedMigratableChannelEndFactoryImpl using the default CNS * service name. */ public NamedMigratableChannelEndFactoryImpl() { this(CNSService.CNS_DEFAULT_SERVICE_NAME); } /** * @see org.jcsp.net.dynamic.NamedMigratableChannelEndFactory#createNet2One(String) */ public MigratableAltingChannelInput createNet2One(String name) { return createNet2One(name, null); } /** * @see org.jcsp.net.dynamic.NamedMigratableChannelEndFactory#createNet2One(String, NameAccessLevel) */ public MigratableAltingChannelInput createNet2One(String name, NameAccessLevel nameAccessLevel) { NetAltingChannelInput chanIn = factoryToUse.createNet2One(); ChannelNameKey key = (nameAccessLevel != null) ? cnsUser.register(chanIn, name, nameAccessLevel) : cnsUser.register(chanIn, name); InputReconnectionManager mgr = new InputReconnectionManagerCNSImpl(chanIn, name, nameAccessLevel, key, cnsServiceName); return new MigratableAltingChannelInputImpl(mgr); } /** * @see org.jcsp.net.dynamic.NamedMigratableChannelEndFactory#createOne2Net(String) */ public MigratableChannelOutput createOne2Net(String name) { return createOne2Net(name); } /** * @see org.jcsp.net.dynamic.NamedMigratableChannelEndFactory#createOne2Net(String, NameAccessLevel) */ public MigratableChannelOutput createOne2Net(String name, NameAccessLevel accessLevel) { NetChannelLocation loc = (accessLevel != null) ? cnsUser.resolve(name) : cnsUser.resolve(name, accessLevel); return new MigratableChannelOutputImpl(factoryToUse.createOne2Net(loc)); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/NotNameableNetChannelLocation.java0000644000000000000000000000545411105701167024044 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import org.jcsp.net.NetChannelLocation; import org.jcsp.net.cns.LocationNotCNSRegisterable; /** * Instances of this class take another NetChannelLocation * object and effectivly "clone" its attributes. The CNS will not * register channels at these locations due to this class implementing * the LocationNotCNSRegisterable interface. * * @author Quickstone Technologies Limited */ class NotNameableNetChannelLocation extends NetChannelLocation implements LocationNotCNSRegisterable { /** * Constructor which takes another NetChannelLocation * object to "copy". * * @param other * @throws IllegalArgumentException if super class constructor throws it. */ public NotNameableNetChannelLocation(NetChannelLocation other) throws IllegalArgumentException { super(other); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/DataSerializationFilter.java0000644000000000000000000000754211105701167023003 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.*; import org.jcsp.net.*; import org.jcsp.util.filter.*; /** *

A filter to be plugged into the sending end of a channel if dynamic class transfer is to be supported * over the channel. The receiving end of the channel should have a DeserializeChannelFilter * plugged in. Any objects send by this filter will be wrapped in a DynamicClassLoaderMessage * object which includes the NetChannelLocation of a channel for the local node's JFTP * service.

* *

Instances of this class will be created by the DynamicClassLoader service and should * be obtained via its getTxFilter method.

* * @author Quickstone Technologies Limited */ class DataSerializationFilter implements Filter { /** * Constructs a new DataSerializationFilter object. * * @param senderLoc the location of the JFTP service's request channel. */ //public DataSerializationFilter(ClassManager cm, NetChannelLocation senderLoc) { public DataSerializationFilter(NetChannelLocation senderLoc) { this.senderLoc = senderLoc; } /** * Wraps the object in a DynamicClassLoaderMessage complete with the JFTP channel * location passed to the filter's constructor. * * @param obj the object to wrap up * @return the wrapped object */ public Object filter(Object obj) { try { obj = new DynamicClassLoaderMessage(obj, senderLoc); } catch (NotSerializableException e) { throw new RuntimeException("Unable to serialize " + obj); } catch (IOException e) { throw new RuntimeException("IOException while trying to serialize " + obj); } return obj; } /** * Location of the JFTP service's request channel. */ private NetChannelLocation senderLoc; }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/InputReconnectionManagerCNSImpl.java0000644000000000000000000003452211105701167024353 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import org.jcsp.net.*; import org.jcsp.net.cns.*; import java.io.*; import java.lang.reflect.*; /** * Implementation of the InputReconnectionManager to work with a CNS service for resolution * of the channel's current location. * * @author Quickstone Technologies Limited */ class InputReconnectionManagerCNSImpl implements InputReconnectionManager { /** * The underlying input channel end. */ private NetAltingChannelInput chanIn; /** * The factory class used to create the channel end. */ Class channelFactoryClass = null; /** * Identification of the CNS service to use. */ private String cnsServiceNameToUse = null; /** * Name registered with the CNS. */ private String cnsRegisteredName = null; /** * NameAccessLevel used to register the name against with the CNS. */ private NameAccessLevel cnsRegisteredNameAccessLevel = null; /** * The name key allocated to the channel. */ private ChannelNameKey key = null; /** * True if the channel end has been prepared for serialization (migration). */ private transient boolean serializable = false; /** * Current location of the channel. */ private transient NetChannelLocation cnsNetChannelLocation = null; /** * Constant for representing a possible channel state. */ private static final int MSG_CHAN_SERIALIZABLE = 1; /** * Constant for representing a possible channel state. */ private static final int MSG_CHAN_NETWORKED = 2; /** * Constant for representing a possible channel state. */ private static final int MSG_TERMINATE = 3; /** * Unique prefix to use when registering channels with the CNS. It is assumed that only the * reconnection managers will be using channels with names of this form. */ static final String anonymousCnsNamePrefix = "org.jcsp.net.cns ANON"; /** * Constructs a new InputReconnectionManagerCNSImpl for use with the given input * channel. The default CNS service name will be used. * * @param chanIn the input channel end. */ public InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn) { this(chanIn, null); } /** * Constructs a new InputReconnectionManagerCNSImpl for use with the given input * channel and a specific CNS service. * * @param chanIn the input channel end. * @param cnsServiceName name of the CNS service to use. */ public InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, String cnsServiceName) { super(); this.chanIn = chanIn; this.cnsServiceNameToUse = cnsServiceName; } /** * Constructs a new InputReconnectionManagerCNSImpl for use with CNS registered * channels using NameAccessLevel application isolation. The default CNS service name * is used. * * @param chanIn the input channel end. * @param name the CNS registered name of the channel. * @param accessLevel the application isolation level. * @param key the allocated channel key. */ public InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, String name, NameAccessLevel accessLevel, ChannelNameKey key) { this(chanIn, name, accessLevel, key, null); } /** * Constructs a new InputReconnectionManagerCNSImpl for use with CNS registered * channels. * * @param chanIn the input channel end. * @param name the CNS registered name of the channel. * @param accessLevel the application isolation level. * @param key the allocated channel key. * @param cnsServiceName name of the CNS service to use. */ public InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, String name, NameAccessLevel accessLevel, ChannelNameKey key, String cnsServiceName) { this.chanIn = chanIn; this.key = key; this.cnsRegisteredName = name; this.cnsRegisteredNameAccessLevel = accessLevel; this.cnsServiceNameToUse = cnsServiceName; } /** * Obtain the NetAltingChannelInput object to use. * * After serialization, the first call to this method will reconstruct * the channel and register it with the CNS. * * If there is a problem while trying to construct a channel, * a ChannelEndContructionException will be thrown. * * @see org.jcsp.net.dynamic.InputReconnectionManager#getInputChannel() */ public NetAltingChannelInput getInputChannel() { if (chanIn == null) { try { Constructor c = channelFactoryClass.getConstructor(new Class[]{}); Method createMethod = null; Method[] createMethods = channelFactoryClass.getMethods(); for (int j=0; jgetInputChannel() has been called to resolve the channel being managed. */ public NetChannelLocation getCurrentLocation() { if (chanIn == null) throw new IllegalStateException("Input channel does not exist. Need to call getInputChannel()."); if (this.cnsRegisteredName == null) //the channel is not registered with the CNS //return the actual underlying channel location //don't want the users to then register the channel with //the CNS return new NotNameableNetChannelLocation(chanIn.getChannelLocation()); else if (cnsNetChannelLocation == null) { //channel is registered with the CNS if (cnsRegisteredNameAccessLevel == null) cnsNetChannelLocation = cnsServiceNameToUse == null ? CNS.resolve(cnsRegisteredName) : ((CNSUser)Node.getInstance().getServiceUserObject(cnsServiceNameToUse)).resolve(cnsRegisteredName); else { cnsNetChannelLocation = cnsServiceNameToUse == null ? CNS.resolve(cnsRegisteredName, cnsRegisteredNameAccessLevel) : ((CNSUser)Node.getInstance().getServiceUserObject(cnsServiceNameToUse)) .resolve(cnsRegisteredName, cnsRegisteredNameAccessLevel); } } return cnsNetChannelLocation; } /** * This method must be called before an instance of this class * is serializable. If an instance is deserialized, it can be * reserialized without calling this method if * getInputChannel() has not been called. * * @see org.jcsp.net.dynamic.InputReconnectionManager#prepareToMove() */ public void prepareToMove() { if(serializable) return; if (cnsRegisteredName == null) { //channel is anonymous or name is not known //need to register a name try { NetChannelLocation loc = chanIn.getChannelLocation(); cnsRegisteredName = anonymousCnsNamePrefix + loc.getStringID(); cnsRegisteredNameAccessLevel = NameAccessLevel.GLOBAL_ACCESS_LEVEL; key = cnsServiceNameToUse == null ? CNS.leaseChannelName(cnsRegisteredName, cnsRegisteredNameAccessLevel, null) : ((CNSUser)Node.getInstance().getServiceUserObject(cnsServiceNameToUse)) .leaseChannelName(cnsRegisteredName, cnsRegisteredNameAccessLevel, null); serializable = true; } catch (Exception e) { cnsRegisteredName = null; cnsRegisteredNameAccessLevel = null; key = null; return; } } else { //name is registered - lease it! try { key = cnsServiceNameToUse == null ? CNS.leaseChannelName(cnsRegisteredName, cnsRegisteredNameAccessLevel, key) : ((CNSUser) Node.getInstance().getServiceUserObject(cnsServiceNameToUse)) .leaseChannelName(cnsRegisteredName, cnsRegisteredNameAccessLevel, key); serializable = true; } catch (Exception e) { return; } } if (serializable) chanIn.destroyReader(); } /** * Serialization method to write this object to a stream. * * @param out destination stream to serialize to. */ private void writeObject(ObjectOutputStream out) throws IOException { if(!serializable) throw (new NotSerializableException(getClass().getName())); if(chanIn != null) { if (chanIn instanceof Serializable) { //channel is serializable so serialize it! out.writeInt(MSG_CHAN_SERIALIZABLE); out.writeObject(chanIn); } else { out.writeInt(MSG_CHAN_NETWORKED); out.writeObject(chanIn.getFactoryClass()); out.writeObject(cnsRegisteredName); out.writeObject(cnsRegisteredNameAccessLevel); out.writeObject(key); out.writeObject(cnsServiceNameToUse); } } else { out.writeInt(MSG_CHAN_NETWORKED); out.writeObject(channelFactoryClass); out.writeObject(cnsRegisteredName); out.writeObject(cnsRegisteredNameAccessLevel); out.writeObject(key); out.writeObject(cnsServiceNameToUse); } out.writeInt(MSG_TERMINATE); } /** * Serialization method to read this object from a stream. * * @param in the source stream. */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { int i = in.readInt(); if(i < MSG_TERMINATE) { switch(i) { case MSG_CHAN_SERIALIZABLE: chanIn = (NetAltingChannelInput)in.readObject(); break; case MSG_CHAN_NETWORKED: //the channel does not get constructed here //this is done in the getInputChannel() method channelFactoryClass = (Class)in.readObject(); cnsRegisteredName = (String)in.readObject(); cnsRegisteredNameAccessLevel = (NameAccessLevel)in.readObject(); key = (ChannelNameKey) in.readObject(); cnsServiceNameToUse = (String) in.readObject(); //this gets set to false in the getInputChannel() method serializable = true; break; } //read the terminate msg in.readInt(); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/ChannelEndContructionException.java0000644000000000000000000000650011105701167024325 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; /** * Thrown when a reconnection mannager is unable to recreate the underlying channel. * * @author Quickstone Technologies Limited */ public class ChannelEndContructionException extends RuntimeException { /** * Constructs a ChannelEndConstructionException without a detail message or cause. */ public ChannelEndContructionException() { super(); } /** * Constructs a ChannelEndConstructionException with a detail message. * * @param message the detail message indicating why the exception was raised. */ public ChannelEndContructionException(String message) { super(message); } /** * Constructs a ChannelEndContructionException with a detail message and underlying * cause. * * @param message the detail message. * @param cause the exception that was caught while trying to perform the construction operation. */ public ChannelEndContructionException(String message, Throwable cause) { super(message, cause); } /** * Constructs a ChannelEndConstructionException with a cause indicator. * * @param cause the exception that was caught while trying to perform the construction operation. */ public ChannelEndContructionException(Throwable cause) { super(cause); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/MigratableChannelEnd.java0000644000000000000000000001166211105701167022213 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import org.jcsp.net.*; import org.jcsp.net.cns.*; /** * Static factory for creating migratable channel ends. * * @author Quickstone Technologies Limited */ public class MigratableChannelEnd { /** * Standard factory for anonymous channel ends. */ private static MigratableChannelEndFactory FACTORY = new MigratableChannelEndFactory(); /** * Factory for named channel ends. */ private static NamedMigratableChannelEndFactory NAMED_FACTORY = new NamedMigratableChannelEndFactoryImpl(); /** * Creates a new MigratableChannelEnd object. This is private to prevent any * instances from being created. This class contains only static methods. */ private MigratableChannelEnd() { super(); } /** * Creates an anonymous migratable channel input. * * @return the created channel end. */ public static MigratableAltingChannelInput createNet2One() { return (MigratableAltingChannelInput) FACTORY.createNet2One(); } /** * Creates a migratable channel output to a given location. * * @param loc location of the input end of the channel. * @return the created channel end. */ public static MigratableChannelOutput createOne2Net(NetChannelLocation loc) { return (MigratableChannelOutput) FACTORY.createOne2Net(loc); } /** * Creates a named migratable channel input using the default namespace. * * @param name the name of the channel to register with the CNS. * @return the created channel end. */ public static MigratableAltingChannelInput createNet2One(String name) { return createNet2One(name, null); } /** * Creates a named migratable channel input within the given namespace. * * @param name the name of the channel to register with the CNS. * @param nameAccessLevel the namespace to register the name within. * @return the created channel end. */ public static MigratableAltingChannelInput createNet2One(String name, NameAccessLevel nameAccessLevel) { return NAMED_FACTORY.createNet2One(name, nameAccessLevel); } /** * Creates a migratable channel output to a named channel within the default namespace. * * @param name the name of the channel as registered with the CNS. * @return the created channel end. */ public static MigratableChannelOutput createOne2Net(String name) { return createOne2Net(name, null); } /** * Creates a migratable channel output to a named channel within a given namespace. * * @param name the name of the channel as registered with the CNS. * @param nameAccessLevel the namespace the name is registered within. * @return the created channel end. */ public static MigratableChannelOutput createOne2Net(String name, NameAccessLevel nameAccessLevel) { return NAMED_FACTORY.createOne2Net(name, nameAccessLevel); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/DynamicClassLoader.java0000644000000000000000000002063111105701167021721 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.*; import org.jcsp.util.filter.*; /** * A service implementation for supporting dynamic class transfer at a node. When started, JFTP server * and ClassMananger processes will be spawned and send/receive filters created. To support * dynamic class loading over a given channel, plug the TX filter into the sending end and the RX filter * into the receiving end. The channel can then be used normally. * * @author Quickstone Technologies Limited */ public class DynamicClassLoader implements Service { /** * Starts the dynamic loader service by spawning ClassManager and JFTP * processes. * * @return true if the service started successfully. */ public boolean start() { cm = new ClassManager(); new ProcessManager(cm).start(); channelRxFilter = new DeserializeChannelFilter(cm); NetAltingChannelInput requests = NetChannelEnd.createNet2One(); JFTP localFileService = new JFTP(ClassLoader.getSystemClassLoader(), requests, cm); new ProcessManager(localFileService).start(); this.channelTxFilter = new DataSerializationFilter(requests.getChannelLocation()); running = true; Node.info.log(this, "Dynamic Class Loading Service Started"); return running; } /** * Stops the dynamic loader service. */ public boolean stop() { return false; } /** * Initializes the dynamic loader service. */ public boolean init(ServiceSettings settings) { return true; } /** * Returns true iff the service is running. */ public boolean isRunning() { return running; } /** * Returns the service user object. */ public ServiceUserObject getUserObject() throws SecurityException { return new DynamicClassLoaderUserObject(); } /** * Returns the TX filter to be used at the sending end of a channel if dynamic class loading is to * be supported over that channel. If there is a TX filter at the sending end, there must be a RX * filter at the receiving end. */ public Filter getChannelTxFilter() { return channelTxFilter; } /** * Returns the RX filter to be used at the receiving end of a channel if dynamic class loading is to * be supported over that channel. The filter returned is safe to use if there is no TX filter at * the sending end. */ public Filter getChannelRxFilter() { return channelRxFilter; } /** * An alternative RX filter that does not support dynamic class loading but will properly * unmarshal objects wrapped up by a TX filter. */ public static Filter getNonDynamicClassLoadingRxFilter() { return nonDynamicClassLoadingRxFilter; } /** * User interface to obtain the TX and RX filters from the service once it has been started. */ public class DynamicClassLoaderUserObject implements ServiceUserObject { /** * Constructs a new DynamicClassLoaderUserObject. */ private DynamicClassLoaderUserObject() { } /** * Returns the TX filter to be used at the sending end of a channel if dynamic class laoding is * to be supported over that channel. If there is a TX filter at the sending end, there must be * a RX filter at the receiving end. */ public Filter getChannelTxFilter() { return channelTxFilter; } /** * Returns the RX filter to be used at the receiving end of a channel if dynamic class loading * is to be supported over that channel. The filter returned is safe to use if there is no * TX filter at the sending end. */ public Filter getChannelRxFilter() { return channelRxFilter; } } /** * Stores the current state of the service. */ private boolean running = false; /** * The TX filter created when the service started, returned by getChannelTxFilter. */ private DataSerializationFilter channelTxFilter = null; /** * The RX filter created when the service started, returned by getChannelRxFilter. */ private DeserializeChannelFilter channelRxFilter = null; /** * The class manager process started by the service. */ private ClassManager cm; /** * Default service name. */ public static final String name = "dynamic_class_loading"; /** * The alternative RX filter that does not support dynamic class loading, returned by * getNonDynamicClassLoadingRxFilter. */ private static Filter nonDynamicClassLoadingRxFilter = new Filter() { public Object filter(Object data) { if (data instanceof DynamicClassLoaderMessage) { try { return ((DynamicClassLoaderMessage) data).get(null); } catch (ClassNotFoundException e) { Node.err.log(this, e); } catch (IOException e) { Node.err.log(this, e); } } return data; } }; }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/InputReconnectionManager.java0000644000000000000000000000531211105701167023160 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import org.jcsp.net.*; import java.io.Serializable; /** * Receiving end of a migratable channel. The underlying channel can be obtained by the * getInputChannel method and used like any other channel. Before migrating the channel, * the prepareToMove method must be called. * * @author Quickstone Technologies Limited */ public interface InputReconnectionManager extends Serializable { /** * Returns the underlying input channel. */ public NetAltingChannelInput getInputChannel(); /** * Returns the current location of the channel. */ public NetChannelLocation getCurrentLocation(); /** * Prepares the channel for a transfer between nodes. */ public void prepareToMove(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/MigratableAltingChannelInput.java0000644000000000000000000000542511105701167023743 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.Serializable; import org.jcsp.net.*; import org.jcsp.util.filter.FilteredChannelInput; /** * A migratable input channel end that can be used as a guard within an Alternative. * * @author Quickstone Technologies Limited */ public abstract class MigratableAltingChannelInput extends NetAltingChannelInput implements MigratableChannelInput, FilteredChannelInput, Serializable { /** * Constructs a new MigratableAltingChannelInput for the underlying channel. * * @param channel the underlying channel. */ protected MigratableAltingChannelInput(NetAltingChannelInput channel) { super(channel); } /** * Constructs a new MigratableAltingChannelInput. */ protected MigratableAltingChannelInput() { super(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/MigratableChannelOutput.java0000644000000000000000000000454711105701167023011 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.Serializable; import org.jcsp.net.NetChannelOutput; import org.jcsp.util.filter.*; /** * A migratable networked channel output end. * * @author Quickstone Technologies Limited */ public interface MigratableChannelOutput extends NetChannelOutput, FilteredChannelOutput, Serializable { /** * Prepares the channel end for movement to another node. */ public void prepareToMove(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/ChannelEndNotMoveableException.java0000644000000000000000000000631511105701167024235 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; /** * Thrown when a channel end cannot be moved. * * @author Quickstone Technologies Limited */ public class ChannelEndNotMoveableException extends RuntimeException { /** * Constructs a new ChannelEndNotMoveableException without a detail message or * cause. */ public ChannelEndNotMoveableException() { super(); } /** * Constructs a new ChannelEndNotMoveableException with a detail message. * * @param message the detail message. */ public ChannelEndNotMoveableException(String message) { super(message); } /** * Constructs a new ChannelEndNotMoveableException with a detail message and * underlying cause exception. * * @param message the detail message. * @param cause the exception that caused this one to be raised. */ public ChannelEndNotMoveableException(String message, Throwable cause) { super(message, cause); } /** * Constructs a new ChannelEndNotMoveableException with a cause exception. * * @param cause the exception that caused this one to be raised. */ public ChannelEndNotMoveableException(Throwable cause) { super(cause); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/ClassManager.java0000644000000000000000000003575011105701167020570 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.util.*; import org.jcsp.lang.*; import org.jcsp.net.*; /** *

A process for retrieving and registering classes that cannot be found locally. A single instance * of this process runs, with other components in the dynamic class loading infrastructure invoking * the public methods to request the loading of a class.

* *

When a class is requested, the system class loader will be tried first. If this fails, a cache * of classes received dynamically will be tried. If this fails, and a {@link NodeClassLoader} has * already been started for communication with the remote node, it will be used to retrieve the class * file from that node. If a NodeClassLoader has not been started, one will be created * and used for all subsequent requests to be issued to the remote node.

* * @author Quickstone Technologies Limited */ class ClassManager implements CSProcess { /** * Process execution method. Requests are issued to the process by calling the other methods. These * will synchronize with the process thread and transfer information to it via internal channels. */ public void run() { Alternative alt = new Alternative(new Guard[] { classRegChan.in(), classReqs.in()}); RegisteredClass lookupReg = new RegisteredClass(); while (true) { Class regClass; switch (alt.priSelect()) { case 0 : //This registers a class. If a class already exists //with the same name and SerializedVersion number then //the existing class will be returned. try { regClass = (Class) classRegChan.in().read(); lookupReg.name = regClass.getName(); classNoLongerPending(lookupReg.name); Class classToReturn = (Class) classes.get(lookupReg); if (classToReturn == null) { classToReturn = regClass; classes.put(lookupReg.clone(), regClass); } classRegReplyChan.out().write(classToReturn); } catch (Exception e) { e.printStackTrace(); } break; case 1 : final ClassRequest cr = (ClassRequest)classReqs.in().read(); //check to see if the system class loader can get the class try { regClass = systemClassLoader.loadClass(cr.name); cr.replyChan.write(regClass); break; } catch (ClassNotFoundException e) { } lookupReg.name = cr.name; regClass = (Class) classes.get(lookupReg); if (regClass != null) { cr.replyChan.write(regClass); break; } ClassLoader cl = (ClassLoader)classLoaders.get(cr.classSourceChannelLoc); if (cl == null) { NodeClassLoader ncl = new NodeClassLoader(cr.classSourceChannelLoc, this); classLoaders.put(cr.classSourceChannelLoc, ncl); cl = ncl; } final ClassLoader clToUse = cl; new ProcessManager(new CSProcess() { public void run() { try { Class foundClass = clToUse.loadClass(cr.name); cr.replyChan.write(foundClass); } catch (ClassNotFoundException e) { cr.replyChan.write(e); } } }).start(); } } } /** *

Marks a class as scheduled for later arrival. This is called when a NodeClassLoader * receives a JarManifestReply from a remote node to indicate that requests for the * class should be directed to that class loader. If a JFTP process receives a request for a * class that is not held locally it will check the set of pending classes to determine the class * loader that it should invoke to retrieve the class.

* *

The original manifest reply is also associated with the class so that this can be forwarded to * other class loaders replicating the behaviour of the original JFTP process that loaded the class * from disk.

* * @param name the name of the class. * @param clToUse the class loader that can retrieve the class. * @param jmr the manifest reply to associate with the class. */ public void classPending(String name, ClassLoader clToUse, JFTP.JarManifestReply jmr) { synchronized (classPendings) { if (classManifests.get(name) == null) { classPendings.put(name, clToUse); classManifests.put(name, jmr); } } } /** *

Marks a class as arrived after it was previously marked as pending. This is called when a * NodeClassLoader has received a class as a result of an issued request or a JFTP * process push.

* * @param name the name of the class that has arrived. */ private void classNoLongerPending(String name) { synchronized (classPendings) { classPendings.remove(name); } } /** * Returns true iff a manifest reply has been stored for the specified class. To retrieve the * manifest reply, call checkForPendingClass which will also issue a request to load * the class from the remote node. * * @param className the name of the class to check. */ public boolean pendingClassManifestAvailable(String className) { synchronized (classPendings) { return classManifests.get(className) != null; } } /** *

Attempts to load the class from a remote node if it has previously been marked as pending. The * class loader associated with the class by a call to classPending will be used. If * there is no associated class loader, no action is taken. If there is a manifest reply associated * with the class this will be returned for possible forwarding to another node.

* *

If this method issues a call to a class loader this may block until the class has arrived. This * may take a large amount of time if the class has to be routed through a chain of JFTP processes * and class loaders.

* * @param name the name of the class to check. */ public JFTP.JarManifestReply checkForPendingClass(String name) { ClassLoader cl; synchronized (classPendings) { cl = (ClassLoader) classPendings.get(name); } if (cl != null) { try { cl.loadClass(name); } catch (ClassNotFoundException e) { } } synchronized (classPendings) { return (JFTP.JarManifestReply)classManifests.get(name); } } /** * Requests that the class manager process attempt to load the given class. This method will return * once synchronization with the main thread has occurred. The caller will be notified of completion * of the operation on the reply channel passed. * * @param name the name of the class to retrieve. * @param classSourceChannelLoc location of the channel to request from * @param replyChan reply channel to notify the caller of operation completion */ public void getClass(String name, NetChannelLocation classSourceChannelLoc, ChannelOutput replyChan) { ClassRequest cr = new ClassRequest(name, classSourceChannelLoc, replyChan); classReqs.out().write(cr); } /** * Stores the binary image for the class to optimize any further requests for the same class. * This method will synchronize with the main class manager thread which will update the * hash tables to associate the image with the class and mark the class as having arrived if it * was previously marked as pending. * * @param cls class that has been loaded. * @param fileBytes the binary image defining the class. * @return the class - typically the cls parameter but possibly a different class if * one has already been registered by another class loader. */ public Class registerClass(Class cls, byte[] fileBytes) { classRegChan.out().write(cls); Class classToReturn = (Class) classRegReplyChan.in().read(); if (cls == classToReturn && fileBytes != null) { RegisteredClass rc = new RegisteredClass(); rc.name = classToReturn.getName(); classFiles.put(rc, fileBytes); } return classToReturn; } /** * Gets the binary image for a given class. * * @param name name of the class. * @return the binary image registered by a call to registerClass. */ public byte[] getClassBytes(String name) { RegisteredClass rc = new RegisteredClass(); rc.name = name; byte[] fileBytes = (byte[]) classFiles.get(rc); return fileBytes; } /** * Used to pass requests to the main process thread from calls to the getClass method. */ private Any2OneChannel classReqs = Channel.any2one(); /** * Used to pass requests to the main process thread from calls to the registerClass * method. */ private Any2OneChannel classRegChan = Channel.any2one(); /** * Used to pass replies from the main process thread to callers of the registerClass * method. */ private One2OneChannel classRegReplyChan = Channel.one2one(); /** * A local reference to the system class loader. This is held as an attribute so that it would be * possible to change the class loader that this process tries by default when resolving classes. */ private ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); /** * Maps RegisteredClass objects to byte[] binary images. */ private Hashtable classes = new Hashtable(); /** * Maps NetChannelLocation objects to NodeClassLoader objects to use to * retrieve classes from that node. */ private Hashtable classLoaders = new Hashtable(); // source chan -> class loader /** * Maps String class names to byte[] binary images. */ private Hashtable classFiles = new Hashtable(); // name -> binary /** * Maps String class names to NodeClassLoader objects to use to retrieve * them. */ private Hashtable classPendings = new Hashtable(); // name -> class loader /** * Maps String class names to JarManifestReply objects. */ private Hashtable classManifests = new Hashtable(); // name -> manifest reply /** * Marshals a set of parameters for passing information between getClass and the * main process thread. */ private static class ClassRequest { public ClassRequest(String name, NetChannelLocation classSourceChannelLoc, ChannelOutput replyChan) { this.name = name; this.classSourceChannelLoc = classSourceChannelLoc; this.replyChan = replyChan; } //public final long serialVersionID; public final String name; public final NetChannelLocation classSourceChannelLoc; public final ChannelOutput replyChan; } /** * Used in the classes hash table to represent class names. The current implementation * just represents a class name, however it could be modified to include version numbers and * distinguish classes with the same name but different implementations. */ private static class RegisteredClass implements Cloneable { public boolean equals(Object o) { if (o == null || !(o instanceof RegisteredClass)) return false; RegisteredClass other = (RegisteredClass) o; return name.equals(other.name); } public int hashCode() { return (int) /*version +*/ name.hashCode(); } public Object clone() throws CloneNotSupportedException { return super.clone(); } public String name; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/DeserializeChannelFilter.java0000644000000000000000000001150411105701167023116 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.*; import org.jcsp.util.filter.*; import org.jcsp.net.*; /** This class is used in the dynamic class loading mechanism. * Instances of the class extract Message objects from SerializedMessage objects. * Dynamic class loading can be enabled by using the constructor which takes a ClassManager. * If dynamic class loading is enabled and a DynamicClassLoaderMessage is filtered, the ClassManager object is supplied to the Message object and the underlying message extracted. * Any classes that need loading from the remote Node are requested and loaded as necessary. * * @author Quickstone Technologies Limited */ class DeserializeChannelFilter implements Filter { /** * Constructs a new DeserializeChannelFilter with a reference to a class manager. * * @param cm the class manager to use for received classes. */ DeserializeChannelFilter(ClassManager cm) { this.cm = cm; this.dynamic = true; } /** * Constructs a new DeserializeChannelFilter with dynamic loading disabled. */ DeserializeChannelFilter() { this.dynamic = false; } /** This method takes an object and substitutes it for another object based upon the following rules: * * If the object is an instance of the DynamicClassLoaderMessage class and dynamic class loading is enabled, * then the filter will return the object returned by the supplied object's get method. A ClassManager will be * supplied to the method. * * If the object is an instance of the SerializedMessage class then the object's get * method will be called. The message being held by the SerializedMessage will be deserialized * but classes will not be dynamically loaded. * * If the object is not a SerializedMessage object, then the object itself will be returned without * modification. * @param object The object to filter. * @return the substituted object. */ public Object filter(Object object) { try { if (dynamic && object instanceof DynamicClassLoaderMessage) return ((DynamicClassLoaderMessage)object).get(cm); else return object; } catch (ClassNotFoundException e) { Node.err.log(this, e); } catch (IOException e) { Node.err.log(this, e); } //return object at the moment decide later - this is only prototype version return object; } /** * The class manger to use for classes dynamically received. */ private ClassManager cm; /** * Set to true if dynamic class loading is enabled. If false, no filtering rules are applied. */ private boolean dynamic; }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/DynamicClassLoaderMessage.java0000644000000000000000000001602711105701167023232 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.*; /** * Wraps an object when it is being sent over a channel by the DataSerializationFilter so * that it includes a NetChannelLocation referring to the JFTP request channel to service * requests for the class's binary image if it is not held at the receiving end. * * @author Quickstone Technologies Limited */ class DynamicClassLoaderMessage implements Serializable { /** * Creates a new DynamicClassLoaderMessage encapsulating the given object. * * @param data the actual user object being sent. * @param classSourceChannelLoc the request channel of the JFTP process. */ public DynamicClassLoaderMessage(Object data, NetChannelLocation classSourceChannelLoc) throws NotSerializableException, IOException { this.classSourceChannelLoc = classSourceChannelLoc; this.createTime = System.currentTimeMillis(); this.serializedData = new SerializedData(data,false); } /** * Creation timestamp. */ private long createTime; /** * Diagnostic string identifying the message by timestamp. */ public String toString() { return "DynamicClassLoaderMessage " + createTime; } /** * Public accessor to deserialize and retrieve the object using the specified * ClassManager. * * @param cm the class manager to use. * @return the user object passed in this message. */ public Object get(ClassManager cm) throws ClassNotFoundException, IOException { //JA - probably don't want to create a new factory each time if (cm != null) { Object g = serializedData.get(new AdvancedInputStreamFactory(cm)); return g; } return serializedData.get(); } /** * Sets the class loader to use when deserializing the object. * * @param classLoader the new class loader. */ public void setClassLoader(ClassLoader classLoader) { this.classLoaderToUse = classLoader; } /** * The class loader to use when deserializing the object. This is not sent as part of the message - * it is for use by methods invoked by the receiver. */ private transient ClassLoader classLoaderToUse = null; /** * The location of the request channel of the sender's JFTP process. */ private final NetChannelLocation classSourceChannelLoc; /** * The serialized form of the user object being sent. */ private SerializedData serializedData; /** * This allows a custom ClassLoader to be used to resolve the object * being deserialized. * * @author Jo Aldous */ private class AdvancedObjectInputStream extends ObjectInputStream { /** * Constructs a new AdvancedObjectInputStream. * * @param cm the class manager process at this node. * @param in the underlying input stream to read data from. */ public AdvancedObjectInputStream(ClassManager cm, InputStream in) throws IOException { super(in); this.cm = cm; } /** * Attempts to resolve the class requested using the class manager. If this fails an exception * is raised. * * @param v indicates the class to resolve. * @throws IOException if there is a problem with the underlying stream. * @throws ClassNotFoundException if the class could not be resolved. * @return the resolved class. */ protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { One2OneChannel in = Channel.one2one(); cm.getClass(v.getName(), classSourceChannelLoc, in.out()); Object reply = in.in().read(); if(reply instanceof Class) return (Class) reply; throw new ClassNotFoundException(v.getName()); } /** * The class manager to use when resolving a class. */ private ClassManager cm; } /** * Factory for creating instances of AdvancedObjectInputStream bound to a given * class manager. */ private class AdvancedInputStreamFactory implements SerializedData.InputStreamFactory { /** * Constructs a new factory for the given class manager. All streams created by this factory * will be associated with this class manager. * * @param cm class manager to associate will all created streams. */ AdvancedInputStreamFactory(ClassManager cm) { this.cm = cm; } /** * Creates a new input stream. * * @param in the underlying input stream. */ public ObjectInput create(InputStream in) throws IOException { return new AdvancedObjectInputStream(cm, in); } /** * The class manager to associate with all created input streams. */ private ClassManager cm; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/dynamic/OutputReconnectionManager.java0000644000000000000000000000515411105701167023365 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.dynamic; import java.io.Serializable; import org.jcsp.net.*; /** * Writing end of a migratable channel. The underlying channel end can be obtained by a call to * getOutputChannel and used like any other channel. Before transfering the channel end * to another node the prepareToMove() method must be called. * * @author Quickstone Technologies Limited */ public interface OutputReconnectionManager extends Serializable { /** * Returns the underlying channel output end. */ public NetChannelOutput getOutputChannel(); /** * Prepares the channel end for transfer to another node. */ public void prepareToMove(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetLabelledBufferedChannelEndFactory.java0000644000000000000000000000630411105701167023663 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.util.ChannelDataStore; /** *

* This factory constructs buffered NetChannelInput * objects which have labelled VCN's. *

*

* See {@link NetLabelledChannelEndFactory} for an explanation of * labelled VCN's. *

* * @author Quickstone Technologies Limited */ public interface NetLabelledBufferedChannelEndFactory { /** * Constructs a buffered NetAltingChannelInput which * has a VCN assigned with the specified label. * * @param label the label to apply to the channel's VCN. * @param buffer the ChannelDataStore to use. * * @return the constructed NetAltingChannelInput * object. */ public NetAltingChannelInput createNet2One(String label, ChannelDataStore buffer); /** * Constructs a buffered NetSharedChannelInput which * has a VCN assigned with the specified label. * * @param label the label to apply to the channel's VCN. * @param buffer the ChannelDataStore to use. * * @return the constructed NetSharedChannelInput * object. */ public NetSharedChannelInput createNet2Any(String label, ChannelDataStore buffer); }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetAltingChannelInput.java0000644000000000000000000000575011105701167020777 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; /** *

* An abstract class that is sub-classed by classes whose instances * should be networked channel ends that can be used as an * {@link AltingChannelInput} objects. *

*

* This class does not need to be sub-classed by JCSP users. *

* * @author Quickstone Technologies Limited */ public abstract class NetAltingChannelInput extends AltingChannelInputWrapper implements NetChannelInput { /** *

* Constructs a channel end and takes the actual channel to use * to deliver the data. *

* * @param channel the actual channel used to deliver data to the user. */ protected NetAltingChannelInput(AltingChannelInput channel) { super(channel); } /** *

* Constructs a channel end without supplying the actual channel to * use. setChannel(AltingChannelInput) should be called * before the channel end is actually used. *

*/ protected NetAltingChannelInput() { } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetSharedConnectionServer.java0000644000000000000000000000446011105701167021662 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.SharedConnectionServer; /** * Instances of classed implementing this method are * SharedConnectionServer objects which accept * connections from clients from over a JCSP.NET network. * * @author Quickstone Technologies Limited */ public interface NetSharedConnectionServer extends SharedConnectionServer, NetConnectionServer { }jcsp-1.1-rc4.orig/src/org/jcsp/net/package.html0000644000000000000000000000101111077376055016215 0ustar

This is main package for JCSP.NET.

Before any JCSP.NET constructs can be used, the JCSP Node must be initialized. See the {@link org.jcsp.net.Node} class for more information.

Networked channels can be constructed using the {@link org.jcsp.net.NetChannelEnd} class or by using {@link org.jcsp.net.StandardNetChannelEndFactory}.

See the {@link org.jcsp.net.cns} package for information on using named channels.

jcsp-1.1-rc4.orig/src/org/jcsp/net/LoopbackLink.java0000644000000000000000000001301011105701167017135 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; import java.io.*; import org.jcsp.util.filter.*; /** * * @author Quickstone Technologies Limited. */ class LoopbackLink extends Link { /** * Constructs a new loopback link for efficient network channels that are on the same JVM. */ LoopbackLink() { super(null, false, true); loopBack.outFilter().addWriteFilter(new LoopbackSerializationFilter()); loopBack.inFilter().addReadFilter(new DeserializeChannelFilter()); } protected void runTxRxLoop() { new Parallel(new CSProcess[] { new TxLoop(), new RxLoop() }).run(); } /** * Returns the other computer's ID. * * This method is safe to call while the process is running, however * it will return null if the other computer has not yet identified * itself. * * @return ID of connected computer. */ protected NodeID getRemoteNodeID() { return Node.getInstance().getNodeID(); } private final FilteredOne2OneChannel loopBack = FilteredChannel.createOne2One(); /** * The process which does transmission to the stream. */ private class TxLoop implements CSProcess { /** * The run method. */ public void run() { try { ChannelInput txIn = txChannel.in(); ChannelOutput loopbackTx = loopBack.out(); Object obj = txIn.read(); while (!(obj instanceof TxLoopPoison)) { try { loopbackTx.write(obj); } catch (Exception e) { e.printStackTrace(); } obj = txIn.read(); } } catch (Exception ex) { Node.err.log(this, "ERROR in LoopbackLink - EXCEPTION in TxLoop - this should never happen!!"); Node.err.log(this, ex); } } } /** * The process which recieves from the stream. */ private class RxLoop implements CSProcess { /** * The run method. */ public void run() { try { // Now enter demux loop ChannelInput in = loopBack.in(); while (true) deliverReceivedObject(in.read()); } catch (Exception ex) { Node.err.log(this, "ERROR in LoopbackLink - EXCEPTION in TxLoop - this should never happen!!"); Node.err.log(this, ex); } } } /** * An object of this type is used by RxLoop to poison TxLoop. */ private static class TxLoopPoison { } private class LoopbackSerializationFilter implements Filter { public Object filter(Object obj) { if(obj instanceof Message) { Message msg = (Message) obj; try { msg = new SerializedMessage(msg); } catch (NotSerializableException e) { e.printStackTrace(); throw new IllegalArgumentException("Data not Serializable"); } catch (IOException e) { e.printStackTrace(); throw new IllegalArgumentException("Error while trying to Serialize data"); } return msg; } else throw new IllegalArgumentException("Object not a message"); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net/ConnectionMessage.java0000644000000000000000000000644211105701167020204 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * A message between a Connection Client & Server. * *

This is a package-private implementation class. * * @author Quickstone Technologies Limited */ // package-private abstract class ConnectionMessage extends Message { /** * A request from client to server to open(). * *

This is a package-private implementation class. * */ // package-private static final class Open extends ConnectionMessage { /** * @serial */ Object data; } /** * A ping() from server to client. * *

This is a package-private implementation class. * */ // package-private static final class Ping extends ConnectionMessage { /** * @serial */ Object data; } /** * A pong() from client to server. * *

This is a package-private implementation class. * */ // package-private static final class Pong extends ConnectionMessage { /** * @serial */ Object data; } /** * A close() from client to server to open(). * *

This is a package-private implementation class. * */ // package-private static final class Close extends ConnectionMessage { /** * @serial */ Object data; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/SerializedObject.java0000644000000000000000000001721011105701167020015 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** * * @author Quickstone Technologies Limited. */ class SerializedObject implements Externalizable { /*-------------------Constructors---------------------------------------------*/ /** * This is the public used constructor. It takes an object and attempts * to serialize it. * * @parma obj the Object to Serialize. * @throws NotSerializableException If obj is not Serializable. * @throws IOException if an IO error occurs during Serialization, * should not happen unless there is a bug. */ public SerializedObject(Object obj, boolean storeToString) throws NotSerializableException, IOException { if(obj == null) { serializedData = null; if (storeToString) objectToString = "null"; return; } if (storeToString) objectToString = obj.toString(); AccesibleByteArrayOutputStream serializedDataDestination = new AccesibleByteArrayOutputStream(); ObjectOutputStream objOut = new ObjectOutputStream(serializedDataDestination); objOut.writeObject(obj); objOut.flush(); serializedData = serializedDataDestination.getByteArray(); try { serializedDataDestination.close(); objOut.close(); } catch(IOException e) { e.printStackTrace(); } } /** * A private constructor used during the deserialization process of this * object. Externalizable objects require a no-arg constructor so a * replacement object is serialized in this object's place. On * deserialization, this object is reconstructed using this constructor. * * @param data a byte[] containing the serialized data of the object * that this object is holding. * @param objectToString The toString value of the stored object. */ SerializedObject(byte[] data, String objectToString) { this.serializedData = data; this.objectToString = objectToString; } /*-------------------Public Methods-------------------------------------------*/ public byte[] getSerializedData() { return serializedData; } public Object get() throws ClassNotFoundException, IOException { return get(new BasicInputStreamFactory()); } public Object get(InputStreamFactory factory) throws ClassNotFoundException, IOException { if (serializedData == null) return null; ByteArrayInputStream serializedDataSource = new ByteArrayInputStream(serializedData); ObjectInput objIn = factory.create(serializedDataSource); Object obj = objIn.readObject(); try { serializedDataSource.close(); objIn.close(); } catch(IOException e) { e.printStackTrace(); } return obj; } public String getObjectToString() { if (objectToString == null) return ""; return objectToString; } public void writeExternal(ObjectOutput out) throws IOException { } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { } public Object writeReplace() throws ObjectStreamException { ExtClass e = new ExtClass(); e.serializedData = serializedData; e.objectToString = objectToString; return e; } /*-------------------Attributes-----------------------------------------------*/ private byte[] serializedData; private String objectToString = null; /*-------------------Inner Classes--------------------------------------------*/ /** * This class exists purely for performance reasons. It provides an * accessor to the internal byte[] and means that it does not need to * be copied. */ private static class AccesibleByteArrayOutputStream extends ByteArrayOutputStream { public byte[] getByteArray() { return buf; } } public interface InputStreamFactory { public ObjectInput create(InputStream in) throws IOException; } private class BasicInputStreamFactory implements InputStreamFactory { public ObjectInput create(InputStream in) throws IOException { return new ObjectInputStream(in); } } /** * This class exists because the main class cannot have a no-arg * constructor as required by externalizable. * * On serialization, this object replaces the SerializedObject. */ private static class ExtClass implements Externalizable { public ExtClass() {} public void writeExternal(ObjectOutput out) throws IOException { if(serializedData == null) out.writeInt(0); else { out.writeInt(serializedData.length); out.write(serializedData, 0, serializedData.length); } out.writeObject(objectToString); } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int arrayLength = in.readInt(); if(arrayLength > 0) { serializedData = new byte[arrayLength]; in.readFully(serializedData); } else serializedData = null; objectToString = (String)in.readObject(); } public Object readResolve() throws ObjectStreamException { return new SerializedObject(serializedData, objectToString); } public byte[] serializedData; public String objectToString = null; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/ServiceUserObject.java0000644000000000000000000000431211105701167020160 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * An Interface which does not define any methods but * is used as a way of indicating that a class is used * for accessing non-admin functionality provided by * a service. * * @author Quickstone Technologies Limited */ public interface ServiceUserObject { }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetAltingConnectionClient.java0000644000000000000000000001014011105701167021632 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.AltingConnectionClientImpl; /** *

* Instances of this class are AltingConnectionClient * objects which connect to ConnectionServer objects * over a JCSP.NET network. *

*

* Instances of this class are not guaranteed to be safe to use * by muliple concurrent processes. See * {@link NetSharedAltingConnectionClient}. *

*

* Instances can be constructed by using a * {@link NetConnectionFactory} or by * using the {@link NetConnection} class. *

* * @author Quickstone Technologies Limited */ public class NetAltingConnectionClient extends AltingConnectionClientImpl implements NetConnectionClient { static NetAltingConnectionClient create(NetChannelLocation serverLoc) { NetChannelOutput openToServer = new One2NetChannel(serverLoc, false); NetChannelOutput reqToServer = new One2NetChannel(serverLoc, false); NetAltingChannelInput fromServer = NetChannelEnd.createNet2One(); NetChannelOutput replyToClient = new One2NetChannel(fromServer.getChannelLocation(), false); return new NetAltingConnectionClient(fromServer, openToServer, reqToServer, replyToClient); } private NetAltingChannelInput fromServer; private NetConnectionLocation location; NetAltingConnectionClient(NetAltingChannelInput fromServer, NetChannelOutput openToServer, NetChannelOutput reqToServer, NetChannelOutput backToClient) { super(fromServer, openToServer, reqToServer, backToClient); this.fromServer = fromServer; this.location = new NetConnectionLocation(openToServer.getChannelLocation(), reqToServer.getChannelLocation()); } /** * Returns the location of the server. * * @return the server's NetChannelLocation * object. */ public NetChannelLocation getChannelLocation() { return this.location; } /** * Destroys the client and frees any resources used * in the JCSP.NET infrastructure. * */ public void destroyClient() { fromServer.destroyReader(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Link.java0000644000000000000000000011440111105701167015470 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.settings.*; import org.jcsp.util.filter.*; import org.jcsp.net.security.*; import java.util.*; // package-private /** *

* This class is an abstract class that all JCSP.NET protocol implementations * must implement. Concrete implementations of the Link class * must provide the mechanism for sending data to remote Nodes and receiving * data back. When a concrete implementation of link is initiated by calling * the run() method, it must inititate a handshaking procedure * and call certain protected methods in this abstract class. *

*

* During handshaking, the * runTests(ChannelInput, ChannelOutput, boolean) should be called. * See the documentation for this method for a full explanation. *

*

* When a Link receives an object from over the network * it should deliver the object to its destination by calling the * deliverReceivedObject(Object) method. *

*

* Link implementations obtain objects to send to the remote * Node by reading from the protected txChannel object. *

* * @author Quickstone Technologies Limited */ public abstract class Link implements CSProcess { /*----------------------Constructors------------------------------------------*/ /** *

* A constructor that must be called by sub-classes. *

* @param protocolID A ProtocolID object for identifying the protocol that is implementing the Link. * @param client Indicates whether this is the client (true) or server (false) end of the connection. * @param connected true if a connection is already established; otherwise connect() will later be called */ public Link(ProtocolID protocolID, boolean client, boolean connected) { this.protocolID = protocolID; this.client = client; this.connected = connected; Service svc = Node.getInstance().getServiceManager().getService("security"); if (svc != null) securityAuthority = (SecurityAuthority)svc.getUserObject(); } /*----------------------Abstract Methods--------------------------------------*/ /** *

* Establishes a connection to the peer node. Called when the process is started unless * connected was true in the constructor. This is called internally from this * class' run method - do not call it. *

* * @return true on success, false on failure */ protected boolean connect() throws Exception { throw new NoSuchMethodException("connect"); } /** *

* Allocates the resources necessary for the actual connection. Called as the first part * of the handshaking process. This is called internally from the class' handshake * method - do not call it. *

* * @return true on success, false on failure */ protected boolean createResources() throws Exception { throw new NoSuchMethodException("createResources"); } /** *

* Deallocates any resources allocated by createResources. Called in the event of * an error during handshaking or when the link is dropped. An implementation of this method * must cope with being called multiple times without an intervening call to createResources. *

*/ protected void destroyResources() throws Exception { throw new NoSuchMethodException("destroyResources"); } /** *

* Sends the ID of this node to the peer process and receives its ID. It is only necessary to * send this node's ID if sendNodeID is true. The remoteNodeID * attribute should be set to the ID of the remote node if received. This is called internally * during handshaking - do not call it. *

* * @return true on success, false on failure. */ protected boolean exchangeNodeIDs() throws Exception { throw new NoSuchMethodException("exchangeNodeIDs"); } /** * Performs send and receive actions for the link exchanging data with the peer node. This is * called from this class' run method - do not call it directly. * * */ protected void runTxRxLoop() throws Exception { throw new NoSuchMethodException("runTxRxLoop"); } /** * Waits for numRepliesOutstanding instances of LinkLost * to arrive from the txChannel. This is called internally from this class' * run method - do not call it directly. * * @param numRepliesOutstanding LinkLost instances to wait for. */ protected void waitForReplies(int numAcknowledgements) throws Exception { throw new NoSuchMethodException("waitForReplies"); } /** * Writes a test object to the underlying connection. Called internally during handshaking * - do not call it directly. The value written must be delivered by readTestObject * at the remote node. * * @param obj object to be written */ protected void writeTestObject(Object obj) throws Exception { throw new NoSuchMethodException("writeTestObject"); } /** * Reads a test object from the underlying connection. Called internally during handshaking * - do not call it directly. It must deliver the value passed to writeTestObject * at the peer node. * * @return the object received. */ protected Object readTestObject() throws Exception { throw new NoSuchMethodException("readTestObject"); } /** * Writes a boolean link decision as to whether the other node has the option to keep or discard * the link. Called internally during handshaking - do not call it directly. The value written * must be delivered by readLinkDecision at the peer node. * * @param use decision result */ protected void writeLinkDecision(boolean use) throws Exception { throw new NoSuchMethodException("writeLinkDecision"); } /** * Reads a boolean link decision as to whether this node can keep or discard the link. Called * internally during handshaking - do not call it directly. It must return the value passed to * writeLinkDecision at the peer node. * * @return decision result */ protected boolean readLinkDecision() throws Exception { throw new NoSuchMethodException("readLinkDecision"); } /*----------------------Concrete Methods--------------------------------------*/ /** * Adds a transmission filter. This filter will run in the thread that is * trying to send something over this Link. * * @param filter the filter. * @param index the index position of the filter. */ void addTxFilter(Filter filter, int index) { txChannel.outFilter().addWriteFilter(filter, index); } /** * Removes a transmission filter. * * @param filter the filter to remove. */ void removeTxFilter(Filter filter) { txChannel.outFilter().removeWriteFilter(filter); } /** * Gets the number of installed transmission filters. * * @return the number of transmission filters installed. */ int getTxFilterCount() { return txChannel.outFilter().getWriteFilterCount(); } /** * Returns the other computer's ID. * * This method is safe to call while the process is running, however * it will return null if the other computer has not yet identified * itself. * * @return ID of connected computer. */ // package-private protected NodeID getRemoteNodeID() { return this.remoteNodeID; } /** A protected accessor for obtaining the identifier of the protocol implementing this Link object. * @return the ProtocolID of the protocol implementing this Link. */ protected ProtocolID getProtocolID() { return this.protocolID; } void setProfile(Profile profile) { this.profile = profile; } Profile getProfile() { return this.profile; } /** * Returns channel to use for transmitting. * * This method is safe to call while the process is running. May block * for if handshaking is still in progress. * * When written to, if the object supplied is not Serializable then an * IllegalArgumentException Runtime exception. * * @return Channel you should send data to if you want to transmit on * this Connection. */ // protected - to be used by this package and sub-classes protected ChannelOutput getTxChannel() { return txChannel.out(); } /** * A protected method for concrete implementations of this class to call when they received a an object from the remote Node. This method delivers the message to its destination (a Channel, Connection etc.). * @param obj the object to deliver. */ protected void deliverReceivedObject(Object obj) { if (!(obj instanceof Message)) { if (obj instanceof Challenge) // the other end is using security and we aren't txChannel.out().write(null); else Node.err.log(this, "call to deliverReceivedObject without a valid Message"); return; } Message msg = (Message) obj; if (msg instanceof Message.PingMessage) txChannel.out().write(Message.PING_REPLY_MESSAGE); else if (msg instanceof Message.PingReplyMessage) pingReplyChan.out().write(msg); else { // this is a little hack so that LoopbackLinks deliver the correct node IDs if ((msg.sourceID = remoteNodeID) == null) msg.sourceID = remoteNodeID = getRemoteNodeID(); msg.txReplyChannel = txChannel.out(); ChannelOutput out = null; if (IndexManager.checkIndexIsValid(msg.destIndex)) out = im.getRxChannel(msg.destIndex); else if (msg.destVCNLabel != null) out = im.getRxChannel(msg.destVCNLabel); if (out != null) { try { out.write(msg); } catch (PoisonException e) { Node.info.log(this, "BOUNCING Message"); msg.bounce(getTxChannel()); //log this properly Node.info.log(this, "Unable to deliver message " + msg + " Channel was poisoned: " + e); } } else if (!(msg instanceof Message.BounceMessage)) { Node.info.log(this, "BOUNCING Message"); //Do not do this if recieved an InvalidChannelIndexMessage //there could be continually bounced back replies msg.bounce(getTxChannel()); } else Node.err.log(this, "BOUNCED message with invalid destination index"); } } Specification[] getSpecifications() { return specifications; } void setSpecifications(Specification[] specifications) { Comparator c = new Comparator() { public int compare(Object o1, Object o2) { Specification s1 = (Specification) o1; Specification s2 = (Specification) o2; return s1.name.compareTo(s2.name); } }; Arrays.sort(specifications, c); this.specifications = specifications; } /** * A public accessor for obtaining the ping time between the local Node and this Link's remote Node. * @return the ping time as a long. */ public long getPingTime() { return pingTime; } /** * Performs a ping on the link. * * @return the ping time in ms. */ public synchronized long ping() { long startTime = System.currentTimeMillis(); txChannel.out().write(Message.PING_MESSAGE); pingReplyChan.in().read(); long endTime = System.currentTimeMillis(); this.pingTime = endTime - startTime; return pingTime; } /** *

* A public accessor for enquiring as to whether this Link object has performed a ping test. *

* * @return true iff a ping test has been performed. */ public boolean performedPingTest() { return performedPingTest; } /** *

* This is used by concrete Link implementations before calling the runTests method. * When tests are run, a series of messages are exchanged between both sides of the link. This allows * the link to perform its tests using a single thread. *

* * @param client a boolean indicating whether this Link object is the client side of the link. * If this object is the client then the parameter should be true. * @return an array of boolean values indicating the sequence of when to read and when to transmit. */ protected boolean[] getReadSequence(boolean client) { if (client) return new boolean[] { false, true, false, true, false }; return new boolean[] { true, false, true, false, true }; } /** *

* This should be called during the handshaking process. The in parameter should be * a ChannelInput that reads from a process that receives object from the remote Node. * The out parameter is a ChannelOutput that, when written * to, will transmit the object to the remote Node. The client parameter should be true * iff the current Link is acting as a client side link (if it establishes the initial connection). *

*

* The method will start a testing process and then return. The concrete implementation * of Link that calls this method should call the getReadSequence(boolean) method * before calling this method. Once this method has returned, the calling process should loop through the * returned array of boolean values. If the value is true, the process should wait to recieve * an object from over the network and then send it down the channel supplied as the in parameter. * If the value is false, the process should read from the channel supplied as the out * parameter and then send the object it receives over the network. *

*

* Once the calling process has finished looping through the array, it should perform a read from the channel * supplied as the out channel. * This is some example code for what concrete implementations of Link need to do: *

*
    *    One2OneChannel fromTestProcess = Channel.one2one();
    *    One2OneChannel toTestProcess = Channel.one2one();
    *    boolean[] readSequence = super.getReadSequence(client);
    *    super.runTests(toTestProcess.in(), fromTestProcess.out(), client);
    *    try {
    *        for(int i=0; i
    *
    * @param in a ChannelInput that the test process can use
    * to receive objects from over the network.
    * @param out a ChannelOutput that the test process
    * should use to send objects over the network.
    * @param client a boolean that is true iff this Link object
    * is the object that established the connection to the remote Node.
    */
   private void runTestProcess(final ChannelInput in, final ChannelOutput out, final boolean client)
   {
      new ProcessManager(new CSProcess()
                        {
                           public void run()
                           {
                              if (client)
                              {
                                 //check other side is ready
                                 out.write(new LinkTest());
                                 LinkTest returned = (LinkTest) in.read();
                                 if ((returned != null) && (returned.counter == 1))
                                 {
                                    returned.counter++;
                                    long txTime = System.currentTimeMillis();
                                    out.write(returned);
                                    returned = (LinkTest) in.read();
                                    long rxTime = System.currentTimeMillis();
                                    if ((returned != null) && (returned.counter == 3))
                                    {
                                       returned.counter++;
                                       out.write(returned);
                                       performedPingTest = true;
                                       pingTime = rxTime - txTime;
                                    }
                                 }
                              }
                              else
                              {
                                 LinkTest received = (LinkTest) in.read();
                                 if ((received != null) && (received.counter == 0))
                                 {
                                    received.counter++;
                                    out.write(received);
                                    //both sides at this stage - now perform test
                                    received = (LinkTest) in.read();
                                    if ((received != null) && (received.counter == 2))
                                    {
                                       received.counter++;
                                       //reply straight away
                                       long txTime = System.currentTimeMillis();
                                       out.write(received);
                                       received = (LinkTest) in.read();
                                       long rxTime = System.currentTimeMillis();
                                       if ((received != null)
                                       && (received.counter == 4))
                                       {
                                          performedPingTest = true;
                                          pingTime = rxTime - txTime;
                                       }
                                    }
                                 }
                              }
                              out.write(null);
                           }
                        }).start();
   }
   
   /**
    * 

* This is called during handshaking in order to * register the link with the local LinkManager. It returns true * if the link is successfully registered. *

* @return true iff the link is successfully registered. */ private boolean registerLink() { Specification[] specifications = ProtocolManager.getInstance().getProtocolSpecifications(protocolID); if (specifications != null) { Specification[] specificationsClone = (Specification[])specifications.clone(); //update the ping value for (int i = 0; i < specificationsClone.length; i++) { if (specificationsClone[i].name.equals(XMLConfigConstants.SPEC_NAME_PING)) { specificationsClone[i] = new Specification(specificationsClone[i].name, (int)getPingTime()); break; } } setSpecifications(specificationsClone); } return LinkManager.getInstance().registerLink(this); } /** *

* Called to inform the local LinkManager that * this link has failed. *

*

* Currently, this should be called if the link fails once * it has been registered but before the handshaking is complete. *

*/ private void registerFailure() { LinkManager.getInstance().registerFailure(this); } /** *

* This should be called once to notify users of the link that the link has been dropped. * The method returns the number of channels that are using the link that has been dropped. * Implementations should read from txChannel the number of times returned * by this method. *

*

* This is an example: *

*
    *    int numRepliesOutstanding = super.lostLink();
    *    while (numRepliesOutstanding > 0) {
    *        Object obj = txChannel.read();
    *        if (obj instanceof LinkLost) {
    *            numRepliesOutstanding--;
    *        }
    *    }
    * 
* @return an int indicating the number of channels that are using the link. */ private int lostLink() { return LinkManager.getInstance().lostLink(this); } /** *

* Compares another object with this object. This implementation * returns true iff the supplied object is the same * instance object as this object. *

* @param o an object to compare with this object. * @return true iff the parameter equals this object. */ public final boolean equals(Object o) { return o == this; } /** *

* Returns an int hash code for this Link. * The current implementation just uses the instance from Object. *

* * @return an int hash code. */ public final int hashCode() { return super.hashCode(); } /** *

* Main process for the link, containing generic code that makes calls on * the abstract methods that should be implemented by a concrete subclass. * The subclass will be required to connect() if it hasn't * done so, perform handshaking, runTxRxLoop() and then * waitForReplies() to acknowledge link termination. *

*/ public final void run() { if (!connected) { boolean result; try { result = connect(); } catch (Exception e) { e.printStackTrace(); result = false; } if (!result) { // error. Node.err.log(this, "Connect Error"); registerFailure(); return; } connected = true; } if (protocolID != null) { switch (handshake()) { case HS_OK : break; default : case HS_ERROR : // Print an error message // Negotiated that since we have another link we'll not use // this duplicate. (Or there was an error & we gave up). Node.err.log(this, "Handshake Error"); registerFailure(); // Fall through case HS_TEMPORARY : try { destroyResources(); } catch (Exception e) { Node.err.log(this, e); } return; } Node.info.log(this, "Link handshaking finished"); // Security ... if (securityAuthority != null) { final boolean okay[] = new boolean[2]; final One2OneChannelInt sync = Channel.one2oneInt(); Parallel par = new Parallel (new CSProcess[] { new CSProcess() { public void run() { boolean read = false; try { Challenge ch = securityAuthority.createChallenge(); writeTestObject(ch); sync.in().read(); read = true; Response r = (Response)readTestObject(); if (securityAuthority.validateResponse(ch, r)) okay[0] = true; } catch (Exception e) { Node.err.log(this, "error in making challenge - " + e.toString()); } finally { if (!read) sync.in().read(); } } }, new CSProcess() { public void run() { boolean written = false; try { Challenge ch = (Challenge)readTestObject(); sync.out().write(1); written = true; Response r = securityAuthority.createResponse(ch); writeTestObject(r); okay[1] = true; } catch (Exception e) { Node.info.log(this, "error in responding to challenge - " + e.toString()); } finally { if (!written) sync.out().write(0); } } } }); par.run(); par.releaseAllThreads(); if ((!okay[0]) || (!okay[1])) { Node.info.log(this, "link rejected by security manager"); try { destroyResources(); } catch (Exception e) { Node.err.log(this, e); } return; } } } try { runTxRxLoop(); } catch (Exception e) { e.printStackTrace(); } if (protocolID != null) { try { waitForReplies(lostLink()); } catch (Exception e) { Node.err.log(this, e); } } } /** *

* Does handshaking. Checks that the other side is a JCSP.net server * of the same version, then decides whether or not this link is a * duplicate of an existing link. If the versions match and there is * no link to the other server, then the link is registered with the * LinkManager, true is returned, and the link is ready for real * data. Otherwise, the link is closed and false is returned. *

*

* This method contains generic code. Calls are made on abstract methods * that a concrete subclass must implement to provide link functionality. *

* @return HS_ERROR if a problem occurs, HS_REMPORARY if the link is to be discarded or * HS_OK for a permanent link. */ private int handshake() { // Establish the connecting resources try { if (!createResources()) return HS_ERROR; } catch (Exception e) { Node.err.log(this, e); return HS_ERROR; } // Exchange node IDs try { if (!exchangeNodeIDs()) return HS_ERROR; } catch (Exception e) { Node.err.log(this, e); return HS_ERROR; } // Verify the result and abort if just exchanging IDs if (remoteNodeID == null && sendNodeID) { //The other side was not trying to establish a full link //they just wanted our NodeID Node.info.log(this, "Request for NodeID received"); return HS_TEMPORARY; } else if (remoteNodeID != null && !sendNodeID) { //We just wanted to obtain the other side's NodeID //Didn't want a permenent connection return HS_TEMPORARY; } else if (remoteNodeID == null && !sendNodeID) { //An error - we just wanted the other side's NodeID but they didn't //send it return HS_ERROR; } // Run the tests One2OneChannel fromTestProcess = Channel.one2one(); One2OneChannel toTestProcess = Channel.one2one(); boolean[] readSequence = getReadSequence(client); runTestProcess(toTestProcess.in(), fromTestProcess.out(), client); boolean testStatus = true, recvNull = false; for (int i = 0; testStatus && (i < readSequence.length); i++) { Object obj = null; if (readSequence[i]) { //test process is going to do a read first try { obj = readTestObject(); toTestProcess.out().write(obj); } catch (Exception e) { testStatus = false; toTestProcess.out().write(null); } } else { //test process is going to do a write first obj = fromTestProcess.in().read(); if (obj == null) { recvNull = true; testStatus = false; } else { try { writeTestObject(obj); } catch (Exception e) { testStatus = false; toTestProcess.out().write(null); } } } } if (!recvNull) fromTestProcess.in().read(); if (!testStatus) return HS_ERROR; // Decide whether to use the link or not int nodeCompare = getRemoteNodeID().compareToLocalNode(); if (nodeCompare == 0) { Node.err.log(this, "Error: Should be using Loopback"); //should be using LoopBackLink //Networking.getInstance().log("ERROR in Link handshaking: loopback error"); return HS_ERROR; } else if (nodeCompare < 0) { // We decide whether we want to keep this link. boolean use = registerLink(); try { writeLinkDecision(use); } catch (Exception e) { Node.err.log(this, "Error during handshaking whilst writing link decision."); return HS_ERROR; } if (use) return HS_OK; else return HS_ERROR; } else { // other side can choose to drop the link. boolean use; try { use = readLinkDecision(); } catch (Exception ex) { Node.err.log(this, "Error during handshaking whilst reading link decision."); return HS_ERROR; } if (use) { // Other side wants to use this. if (!registerLink()) { // This is *NOT GOOD*. // In fact, this should *never* happen. // I think I've already got a link to another computer, // but that other computer doesn't seem to know about it! Node.err.log(this, "ERROR in Link handshaking: Remote and local link lists " + "are\ndifferent! Try resetting everything..."); return HS_ERROR; } return HS_OK; } else { // Other side does not want to use this. Node.err.log(this, "Other side does not want to use this"); return HS_ERROR; } } } /** *

* This returns the NodeID of the remote Node to which this * link is connected. If a connection has not already been established, * this method may connect to the remote Node and request its * NodeID and then drop the connection. *

* * @return the remote Node's NodeID object. */ public final NodeID obtainNodeID() { if (getRemoteNodeID() != null) return getRemoteNodeID(); if (client) { sendNodeID = false; try { run(); } catch (Exception e) { /*ignored*/ } //set sendNodeID back to true just in case this Link is later used //in the normal way sendNodeID = true; return remoteNodeID; } return null; } /*----------------------Attributes--------------------------------------------*/ /** Handshake result code - a problem occurred */ private static final int HS_ERROR = -1; /** Handshake result code - temporary link */ private static final int HS_TEMPORARY = 0; /** Handshake result code - permanant link ok */ private static final int HS_OK = 1; /** True if connect() has been called or the underlying connection is already * open. False otherwise. */ private boolean connected = false; /** True if this is a client during handshaking, false if it is the server. */ private boolean client; private IndexManager im = IndexManager.getInstance(); /** * The channel used for TX over the link. * * In the future, this might be made private. * It is recommended that implementations use the * getTxChannel() to obtain the channel. * * Protocol implementations should NOT alter any of the * filters on this channel. */ protected FilteredAny2OneChannel txChannel = FilteredChannel.createAny2One(); /** * This indicates whether to send the local Node's address during the * handshaking process. If not then the link is only for obtaining the * remote Node's NodeID and will be shutdown. */ //private boolean sendNodeID = true; /** * The remote NodeID. The subclass must set this during exchangeNodeIDs. */ protected NodeID remoteNodeID; /** * True if the subclass must pass the ID of this node to the peer node. */ protected boolean sendNodeID = true; private ProtocolID protocolID; private Specification[] specifications; private boolean performedPingTest = false; private long pingTime = -1; private Profile profile = null; private One2OneChannel pingReplyChan = Channel.one2one(); private SecurityAuthority securityAuthority = null; private static class LinkTest implements Serializable { int counter = 0; private byte[] bytes = new byte[4096]; } } jcsp-1.1-rc4.orig/src/org/jcsp/net/UIFactory.java0000644000000000000000000000531711105701167016445 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* This class is a Factory that construct a unique identify * for this Node. There is only ever one Node per JVM. *

*

* This class can subclassed and the subclass can be set to be * used in place of this class. See the documentation for the * Node class. *

* * @author Quickstone Technologies Limited */ public class UIFactory { /** *

* Returns a Serializable object that is a unique identifier for this * Node. The object returned should support the * equals(Object) and hashCode() methods * of Object. *

* * @return a Serializable unique identifier for this JVM */ public NodeUI getUIForThisJVM() { return new NodeUIImpl(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Utils.java0000644000000000000000000001345411105701167015701 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * This class provides some utility methods that developers * might find useful when implementing JCSP.NET communication protocol * drivers. * * @author Quickstone Technologies Limited */ public class Utils { /*-----------------Array - String Utils---------------------------------------*/ /** *

* This takes a String[] and returns a String that can be converted * back into an identical String[] using the stringToArray method. *

*

* The intended purpose of this is to possibly aid in implementing the * getStringForm() method of the abstract NodeAddressID class. *

* @param array the String[] to convert into a String. * @return the converted array as a String. */ public static String arrayToString(String[] array) { StringBuffer sb = new StringBuffer(); for(int i=0; i -1 && foundIndex1 < foundIndex2) foundIndex = foundIndex1; else foundIndex = foundIndex2; while(foundIndex > -1) { sb.insert(foundIndex + charsInserted, "\\"); charsInserted = charsInserted + 1; foundIndex1 = str.indexOf("\"", ++foundIndex); foundIndex2 = str.indexOf("\\", foundIndex); if(foundIndex1 > -1 && (foundIndex1 < foundIndex2 || foundIndex2 == -1)) foundIndex = foundIndex1; else foundIndex = foundIndex2; } return sb.toString(); } /** *

* This takes a String in the form of that returned from the * arrayToString method and returns a String[]. *

*

* The intended purpose of this is to possibly aid in implementing the * getAddressIDFromString() method of the abstract NodeAddressID class. *

* @param str the String to convert back into a String[]. * @return the converted String as a String[]. */ public static String[] stringToArray(String str) { int count = 1; String delim = "\"\\\""; int pos = str.indexOf(delim,0); while(pos > -1) { count++; pos = str.indexOf(delim, pos+1); } String[] strings = new String[count]; int lastPos = 0; for(int i = 0; i -1 && foundIndex1 < foundIndex2) foundIndex = foundIndex1; else foundIndex = foundIndex2; while(foundIndex > -1) { sb.deleteCharAt(foundIndex - charsRemoved); charsRemoved = charsRemoved + 1; foundIndex1 = str.indexOf("\\\"", foundIndex + 2); foundIndex2 = str.indexOf("\\\\", foundIndex + 2); if(foundIndex1 > -1 && (foundIndex1 < foundIndex2 || foundIndex2 == -1) ) foundIndex = foundIndex1; else foundIndex = foundIndex2; } return sb.toString(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Logger.java0000644000000000000000000003516511105701167016023 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; import java.util.*; /** *

Manages the output of diagnostic messages to one or more devices. Instances of this class represent * a log output device to which diagnostic or error messages can be written. The instance can be tied to * an actual device such as a file or the standard I/O streams provided by the System class.

* *

All messages must be signed by an application class and may also contain a severity level. The higher * the number the less severe the problem. The output generated can be controlled by setting the maximum level * that should be reported. Thus, essential output should be written at level 1. Less severe and verbose * output should be written at higher levels depending on the granularity of information required when * testing a program.

* *

The default logging level is 5. That is, for all classes only messages up to level 5 by default will * be displayed.

* *

Messages from the infrastructure classes are written to the loggers Node.info and * Node.err which are by default connected to System.out and System.in * respectively.

* *

Alternative implementations of this class may instead write to a system event log or format the * information in manners tailored to particular debugging environments.

* * @author Quickstone Technologies Limited */ public class Logger { //------------------------- Constructors -----------------------------------------------// /** *

Creates a new Logger with a given name. The name assigned is arbitrary but allows the * logger to be uniquely identified by name. For example instead of assigning a static reference * somewhere to always refer to a logger, one can be named and resolved dynamically:

* *
    * public static void main (String[] args) {
    *   new Logger ("errors", "stderr");
    * }
    * 
* *

This will allocate a logger with the name errors connected to System.err. * Elsewhere in the program one can write:

* *
    * Logger.getLogger ("errors")
    * 
* *

To obtain a reference to this logger.

* *

The default device can take one of three reserved values:

*
    *
  • null - no output device; all logged events are discarded.
  • *
  • stdout - write to System.out.
  • *
  • stderr - write to System.err.
  • *
* *

If none of these values match it is assumed to be a filename.

* * @param name the system unique name of the logger. * @param defaultDevice the output device to use. */ public Logger(String name, String defaultDevice) { this.name = name; synchronized (all) { all.put(name, this); } // code to get device settings from preferences or system properties perhaps setDevice(defaultDevice); // load the default logging levels from somewhere setLevel("java.lang.Object", DEFAULT_LOGGING_LEVEL); } //------------------------- Public Methods ---------------------------------------------// /** *

Returns a named logger within the system. Refer to the constructor for an example of its use.

* * @param name the name of the logger * @return the logger * @throws InvalidLoggerException if the logger specified doesn't exist. */ public static Logger getLogger(String name) { synchronized (all) { Logger s = (Logger)all.get(name); if (s == null) throw new InvalidLoggerException(name); return s; } } /** *

Sets the current output device for this logger. For example, to suppress infrastructure messages:

* *
    *   Node.info.setDevice (null);
    * 
* * @param device the new device to use. */ public void setDevice(String device) { output = null; if (device == null) output = null; else if (device.equals("stderr")) output = System.err; else if (device.equals("stdout")) output = System.out; else try { output = new PrintStream(new FileOutputStream(device)); } catch (IOException e) { // Not really appropriate if the error log fails :( Node.err.log(this, "Unable to open device '" + device + "' for " + name + " log - " + e.getMessage()); } } /** *

Sets the current logging level for a given class (and its subclasses). Only messages generated by * that class (or its subclasses) with a lesser level will be output.

* * @param clazz the name of the class. * @param level the maximum level to display. */ public synchronized void setLevel(String clazz, int level) { // clear cached data (i.e. anything with a positive value) if (levelsCached) { Hashtable temp = new Hashtable(); for (Enumeration e = levels.keys(); e.hasMoreElements(); ) { Object key = e.nextElement(); Integer i = (Integer)levels.get(key); if (i.intValue() < 0) temp.put(key, i); } levels = temp; levelsCached = false; } // set the actual data if (level <= 0) levels.remove(clazz); else levels.put(clazz, new Integer(-level)); } //------------------------- Logging constants ------------------------------------------// /** The logging level for really important messages. */ public static final int MAX_LOGGING = 1; /** The default logging level (currently 5) */ public static final int DEFAULT_LOGGING_LEVEL = 5; /** The default string if the class name is omitted. */ public static final String DEFAULT_CLASS_NAME = "Application"; //------------------------- Methods to do the logging ----------------------------------// /* TODO: * * Need to get settings from somewhere * Need to configure what gets displayed; eg show class names ? * Need to configure calls throughout the infrastructure */ /** * Log a message at the default level with the default class name. * * @param message the message to output. */ public void log(Object message) { if (output == null) return; log(DEFAULT_LOGGING_LEVEL, message); } /** * Log a message at a specific level with the default class name. * * @param level the logging level. * @param message the message. */ public void log(int level, Object message) { if (output == null) return; log(DEFAULT_CLASS_NAME, level, message); } private synchronized void logImpl(String className, int level, Object message) { if (output == null) return; if (message instanceof String) { String lineEnd = ""; if (!lastClass.equals(className)) { lastClass = className; output.println(className); } String str = (String)message + lineEnd; if (str.indexOf('\n') >= 0) { output.print('\t'); for (int i = 0; i < str.length(); i++) { if (str.charAt(i) == '\n') output.print("\n\t"); else output.print(str.charAt(i)); } output.println(); } else output.println("\t" + message + lineEnd); } else if (message instanceof Exception) { Exception e = (Exception)message; output.println("(" + level + ")\tException caught in " + className); e.printStackTrace(output); } else { logImpl(className, level, message.toString()); } } /** * Log a message at the specified level with the specific class name. Note that this does not have to * match a real class name so could be used to describe the subsystem generating the message more * meaningfully. * * @param className the class or component name. * @param level the logging level. * @param message the message. */ public void log(String className, int level, Object message) { if (output == null) return; try { log(Class.forName(className), level, message); } catch (ClassNotFoundException e) { // see if logging is enabled or disabled for the name ... int maxLevel; Integer lvl = (Integer)levels.get(className); if (lvl == null) maxLevel = DEFAULT_LOGGING_LEVEL; else maxLevel = lvl.intValue(); if (level <= maxLevel) logImpl(className, level, message); } } // Find level this class private synchronized int findMaxLevel(Class clazz) { int l, max = 0; // Check if there is an entry for this class (and use it) Integer lvl = (Integer)levels.get(clazz.getName()); if (lvl != null) { l = lvl.intValue(); return (l < 0) ? -l : l; } // Check the interfaces Class[] ifaces = clazz.getInterfaces(); for (int i = 0; i < ifaces.length; i++) { l = findMaxLevel(ifaces[i]); if (l > max) max = l; } // Check the superclass Class sup = clazz.getSuperclass(); if (sup != null) { l = findMaxLevel(sup); if (l > max) max = l; } // Update the entry for this class to speed up subsequent operations if (max > 0) { //System.out.println("Updating " + clazz.getName() + " from hierarchy to " + max); levelsCached = true; levels.put(clazz.getName(), new Integer(max)); } return max; } /** * Log a message at the specified level with the specific class. * * @param class the class generating the message. * @param level the logging level. * @param message the message. */ public void log(Class clazz, int level, Object message) { if (output == null) return; // go through the classes to determine the maximum level if (level <= findMaxLevel(clazz)) logImpl(clazz.getName(), level, message.toString()); } /** * Log a message at the specified level with the class of the given object. * * @param class the object whose class has generated the message. * @param level the logging level. * @param message the message. */ public void log(Object object, int level, Object message) { if (output == null) return; log(object.getClass(), level, message); } /** * Log a message with the specific class. * * @param class the class generating the message. * @param message the message. */ public void log(String className, Object message) { if (output == null) return; log(className, DEFAULT_LOGGING_LEVEL, message); } /** * Log a message with the specific class. * * @param class the class generating the message. * @param message the message. */ public void log(Class clazz, Object message) { if (output == null) return; log(clazz, DEFAULT_LOGGING_LEVEL, message); } /** * Log a message with the specific class. * * @param class the class generating the message. * @param message the message. */ public void log(Object object, Object message) { if (output == null) return; log(object, DEFAULT_LOGGING_LEVEL, message); } //------------------------- Attributes -------------------------------------------------// private String name; private PrintStream output = null; // underlying output stream private String lastClass = ""; private Hashtable levels = new Hashtable(); private boolean levelsCached = false; private static final Hashtable all = new Hashtable(); //------------------------- Inner Classes ----------------------------------------------// private static class InvalidLoggerException extends RuntimeException { public InvalidLoggerException(String name) { super("Invalid logger - " + name); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/security/0000755000000000000000000000000011410045050015565 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net/security/SimpleSecurityAuthority.java0000644000000000000000000004511511105701167023341 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.security; import org.jcsp.net.*; import java.util.*; import java.util.prefs.*; /** *

Provides a basic security authority based on unique names. No passwords are used - a user is * identified by a name which is guarded by a minimal protection scheme. This class is supplied as * an example of implementing a security authority and not a robust implementation suitable for long * term use.

* * @author Quickstone Technologies Limited */ public class SimpleSecurityAuthority implements SecurityService { // Constants ////////////////////////////////////////////////////////////////////////////// /** * Sets the length of the challenge packet. */ private static final int CHALLENGE_LENGTH = 80; // Local data ///////////////////////////////////////////////////////////////////////////// /** The token of the current user. */ private UserToken currentUser = null; /** A random number generater for creating challenges. */ private static final Random rnd = new Random(); /** Set of permitted users. */ private Vector allowedUsers = new Vector(); /** Flag indicating if the service is running or not. */ private boolean serviceRunning = false; /** The user control object that avoids giving out the full administrative interface. */ private SecurityAuthority userObject = null; // Constructors /////////////////////////////////////////////////////////////////////////// /** * Creates a new simple authority. The current username will be found from the preferences if * available under the "user" variable. The system property "org.jcsp.net.security.user" * will be checked first and take preference. If no user is found the name "default_user" is assumed. */ public SimpleSecurityAuthority() { try { String userName = System.getProperty("org.jcsp.net.security.user"); if (userName == null) { try { if (Class.forName("java.util.prefs.Preferences") != null) userName = getUserFromPrefs(); } catch (ClassNotFoundException e) { } } if (userName == null) userName = "default_user"; UserID uID = createUserID(userName); UserToken uTk = createUserToken(uID); logonUser(uTk); } catch (AccessDeniedException e) { } } // Methods from SecurityAuthority ///////////////////////////////////////////////////////// /** * Creates a new challenge packet containing a timestamp and some random data. The response must be * returned within around 1 minute for the response to be considered valid so don't keep it too long. * * @return the new challenge packet. */ public synchronized Challenge createChallenge() { SimpleChallenge c = new SimpleChallenge(); c.fillRandom(); Node.info.log(this, "creating challenge " + c.hashCode()); return c; } /** * Checks if the generated response corresponds to one expected from a permitted user. The response must * have come within a minute of the challenge being generated. * * @param c the challenge returned by createChallenge. * @param r the response generated by the other authority. * @return true if the response is permitted. */ public synchronized boolean validateResponse(Challenge c, Response r) { Node.info.log(this, "validating response to " + c.hashCode()); if ((c == null) || (r == null) || (!(c instanceof SimpleChallenge)) || (!(r instanceof SimpleResponse))) { Node.info.log(this, "not a valid response/challenge object (null)"); return false; } SimpleChallenge _c = (SimpleChallenge)c; SimpleResponse _r = (SimpleResponse)r; // Check the length is correct if ((_c.data.length != CHALLENGE_LENGTH) || (_r.data.length != CHALLENGE_LENGTH)) { Node.info.log(this, "not a valid response/challenge object (length invalid)"); return false; } // Check it is recent (allow 1 minute earlier; no future time) long tNow = System.currentTimeMillis(); if ((_c.timestamp < tNow - 60000) || (_c.timestamp > tNow)) { Node.info.log(this, "timestamp invalid"); return false; } // Look up the users permitted to access this node (ie connect to it) byte[] data = new byte[CHALLENGE_LENGTH]; for (Enumeration e = allowedUsers.elements(); e.hasMoreElements(); ) { SimpleUserID uID = (SimpleUserID)e.nextElement(); createResponse(_c, uID, data); boolean match = true; for (int i = 0; i < CHALLENGE_LENGTH; i++) { if (data[i] != _r.data[i]) { match = false; break; } } if (match) return true; } return false; } /** * Creates a response to the challenge based on the currently logged in user. * * @param c the challenge to respond to. * @return the response. */ public synchronized Response createResponse(Challenge c) { Node.info.log(this, "creating response to challenge " + c.hashCode()); if (currentUser == null) throw new RuntimeException("No user is currently logged in"); if ((c == null) || (!(c instanceof SimpleChallenge))) throw new RuntimeException("Invalid challenge for this security authority"); SimpleChallenge _c = (SimpleChallenge)c; if (_c.data.length != CHALLENGE_LENGTH) throw new RuntimeException("Invalid challenge for this security authority"); byte[] data = new byte[CHALLENGE_LENGTH]; createResponse(_c, (SimpleUserID)currentUser.getUserID(), data); return new SimpleResponse(data); } /** * Sets the currently logged on user. If there is already a user logged in, they are logged off. * * @param u the user's token. */ public synchronized void logonUser(UserToken u) throws AccessDeniedException { if (currentUser != null) logoffUser(); if ((u == null) || (!(u instanceof SimpleUserToken))) throw accessDenied("invalid user token"); currentUser = u; permitUserAccess(u.getUserID()); } /** * Clears the currently logged on user. After this call the createResponse method will * fail until another user is logged in. */ public synchronized void logoffUser() { if (currentUser == null) throw new RuntimeException("There is no current user"); try { denyUserAccess(currentUser.getUserID()); } catch (AccessDeniedException e) { // no action } currentUser = null; } /** * Adds a user to the set of permitted users. * * @param u the user ID to add. * @throws AccessDeniedException if the ID was not allocated by this authority. */ public synchronized void permitUserAccess(UserID u) throws AccessDeniedException { if ((u == null) || (!(u instanceof SimpleUserID))) throw accessDenied("invalid user ID"); allowedUsers.addElement(u); } /** * Removes a user from the set of permitted users. * * @param u the user ID to remove. * @throws AccessDeniedException if the ID was not allocated by this authority. */ public synchronized void denyUserAccess(UserID u) throws AccessDeniedException { if ((u == null) || (!(u instanceof SimpleUserID))) throw accessDenied("invalid user ID"); allowedUsers.removeElement(u); } // Methods from Service /////////////////////////////////////////////////////////////////// /** * Sets the service running. * * @return true - this service can always start. */ public boolean start() { Node.info.log(this, "service starting"); serviceRunning = true; return true; } /** * Stops the service. * * @return true - this service can always stop. */ public boolean stop() { Node.info.log(this, "service stopping"); serviceRunning = false; return true; } /** * Returns true iff the service is running. */ public boolean isRunning() { return serviceRunning; } /** *

Initializes the service, setting a current user and the list of permitted users from the XML * configuration file. For example:

* *
    *        <SERVICE ...>
    *           <SETTING name="logonUser" value="foo@bar.com"/>
    *           <SETTING name="permitUser0" value="a"/>
    *           <SETTING name="permitUser1" value="b"/>
    *        </SETTING>
    * 
* *

This sets the current user to be "foo@bar.com" but will allow responses from users "a" and "b".

*/ public boolean init(ServiceSettings s) { if (s != null) { String user = s.getSetting("logonUser"); if (user != null) { try { logonUser(createUserToken(createUserID(user))); } catch (AccessDeniedException e) { return false; } } for (int i = 0; ; i++) { user = (String)s.getSetting("permitUser" + i); if (user == null) break; try { permitUserAccess(createUserID(user)); } catch (AccessDeniedException e) { return false; } } } return true; } /** * Returns the authority interface for this service. A seperate user object is returned to avoid * giving away the service control interface also. */ public ServiceUserObject getUserObject() { if (userObject == null) { final SimpleSecurityAuthority lsa = this; userObject = new SecurityAuthority() { public Challenge createChallenge() { return lsa.createChallenge(); } public boolean validateResponse(Challenge c, Response r) { return lsa.validateResponse(c, r); } public Response createResponse(Challenge c) { return lsa.createResponse(c); } public void logonUser(UserToken u) throws AccessDeniedException { lsa.logonUser(u); } public void logoffUser() { lsa.logoffUser(); } public void permitUserAccess(UserID u) throws AccessDeniedException { lsa.permitUserAccess(u); } public void denyUserAccess(UserID u) throws AccessDeniedException { lsa.denyUserAccess(u); } }; } return userObject; } // Other methods ////////////////////////////////////////////////////////////////////////// /** * Creates and returns a user ID valid for this authority that represents the given user name. * * @param username the unique user name. * @return the user ID. */ public UserID createUserID(String username) { return new SimpleUserID(username); } /** * Creates and returns an authentication token valid for this authority that represents the given * user name. Note that no additional credentials are supplied because this authority does not support * passwords or anything more secure (hence the word 'Simple' in its name :). * * @param user the user ID to authenticate. * @return the authentication token. * @throws AccessDeniedException if the user ID is not valid for this authority. */ public UserToken createUserToken(UserID user) throws AccessDeniedException { // Discard a user ID not from this security authority if ((user == null) || (!(user instanceof SimpleUserID))) throw accessDenied("invalid user token"); // Assume user ID is permitted to use this node return new SimpleUserToken(user); } /** * Returns a string description of this authority. */ public String toString() { return getClass().getName(); } /** * Creates a response for the given challenge using a given user ID. This is used to create an actual * response and also to create the expected response for a given user. * * @param c the challenge request. * @param u the user ID to create a response for. * @param b the array to place the response in. */ private void createResponse(SimpleChallenge c, SimpleUserID u, byte[] b) { long tScroll = c.timestamp; int nx = 0; for (int i = 0; i < b.length; i++) { byte m = 0; if (tScroll > 0) { m = (byte)(tScroll & 0xff); tScroll = (tScroll >> 1); } m += (byte)u.name.charAt(nx); if (m == 0) m = 1; b[i] = (byte)(c.data[i] % m); nx = (nx + 1) % u.name.length(); } } /** * Creates and returns an exception associated with this authority. * * @param reason the reason field of the exception. */ private AccessDeniedException accessDenied(String reason) { return new AccessDeniedException(this, reason); } /** * Returns the initial username if one is specified in the preferences. The user preferences take * precedence over the system preferences. * * @return the user name or null if none is found. */ ////#1.4+ private String getUserFromPrefs() { String user = Preferences.userNodeForPackage(getClass()).get("user", null); if (user == null) user = Preferences.systemNodeForPackage(getClass()).get("user", null); return user; } ////#+ // Private classes //////////////////////////////////////////////////////////////////////// /** * Represents the user ID for this authority. * * @author Quickstone Technologies Limited */ private static final class SimpleUserID implements UserID { public final String name; public SimpleUserID(String name) { this.name = name; } public String toString() { return "UserID:" + name; } } /** * Represents the authenticated user token for this authority. * * @author Quickstone Technologies Limited */ private static final class SimpleUserToken implements UserToken { private UserID uID; public SimpleUserToken(UserID uID) { this.uID = uID; } public UserID getUserID() { return uID; } public String toString() { return "UserToken:" + ((SimpleUserID)uID).name; } } /** * The challenge for this authority containing a timestamp and block of random data. * * @author Quickstone Technologies Limited */ private static final class SimpleChallenge implements Challenge { public long timestamp; public byte[] data; public SimpleChallenge() { } public void fillRandom() { timestamp = System.currentTimeMillis(); data = new byte[CHALLENGE_LENGTH]; rnd.nextBytes(data); } } /** * The response for this authority, consisting of a block of data which has been mangled based on the * timestamp and ID of the user creating the response. * * @author Quickstone Technologies Limited */ private static final class SimpleResponse implements Response { public final byte[] data; public SimpleResponse(byte[] data) { this.data = data; } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/security/Response.java0000644000000000000000000000420211105701167020235 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.security; /** * Abstract representation of a response as part of the security negotiation. * * @author Quickstone Technologies Limited */ public interface Response extends java.io.Serializable { }jcsp-1.1-rc4.orig/src/org/jcsp/net/security/package.html0000644000000000000000000000035611077376055020077 0ustar

This package contains the files specifically for link security implementing various authentication schemes.

See {@link org.jcsp.net.security.SecurityAuthority} for information on the service.

jcsp-1.1-rc4.orig/src/org/jcsp/net/security/SecurityService.java0000644000000000000000000000426611105701167021601 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.security; import org.jcsp.net.*; /** * Defines the actual interface combining service administration and user control methods. * * @author Quickstone Technologies Limited */ public interface SecurityService extends SecurityAuthority, Service { }jcsp-1.1-rc4.orig/src/org/jcsp/net/security/AccessDeniedException.java0000644000000000000000000000567611105701167022650 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.security; /** *

Thrown by the security authority implementations if the credentials supplied are not correct or * another error occurs as a result of user parameters.

* * @author Quickstone Technologies Limited */ public class AccessDeniedException extends Exception { /** * The reason the exception was raised. */ private final String reason; /** * The security authority raising the exception. */ private final SecurityAuthority auth; /** * Creates a new exeception. * * @param auth the authority raising the exception. * @param reason the reason the exception was raised. */ public AccessDeniedException(SecurityAuthority auth, String reason) { super("Access Denied"); this.reason = reason; this.auth = auth; } /** * Returns a printable string describing the exception. */ public String toString() { return "Access denied by " + auth.toString() + " - " + reason; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/security/UserToken.java0000644000000000000000000000502611105701167020363 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.security; /** *

Uniquely identifies an authenticated user. An instance of a SecurityAuthority will be * able to create a user token from a user ID. To do so may require additional information such as passwords * or other authentication details. It is the responsibility of the authority to do the authentication and * only supply a token instance if the credentials are okay.

* * @author Quickstone Technologies Limited */ public interface UserToken extends java.io.Serializable { /** * Returns the ID of the logged on user. */ public UserID getUserID(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/security/UserID.java0000644000000000000000000000454311105701167017602 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.security; /** *

Uniquely identifies a user. Instances of user IDs are specific to a given authority which is responsible * for allocating them. No methods are defined because the way in which IDs are specified may vary. For * example not all systems may identify users with a unique string based user name.

* * @author Quickstone Technologies Limited */ public interface UserID extends java.io.Serializable { }jcsp-1.1-rc4.orig/src/org/jcsp/net/security/Challenge.java0000644000000000000000000000420411105701167020323 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.security; /** * Abstract representation of a challenge as part of the security negotiation. * * @author Quickstone Technologies Limited */ public interface Challenge extends java.io.Serializable { }jcsp-1.1-rc4.orig/src/org/jcsp/net/security/SecurityAuthority.java0000644000000000000000000001577311105701167022176 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.security; import org.jcsp.net.*; /** *

Defines the service for dealing with authenticating users via a challenge/response scheme. Currently * only one user may be logged onto the security authority at any one time. The currently logged on user * will be used for creating the responses to challenges. Any number of users may be regarded as 'permitted' * and any response from one of these will be considered valid.

* *

An instance of the security authority service can be used to generate concrete user IDs and tokens * when users log on. This might be a purely internally resolved scheme or perhaps be linked to information * from a system level domain (eg the user's logon account).

* *

To negotiate starting a link, the security authorities at each end should create challenges to send. * The peer nodes will create responses from these challenges which indicate the log in of the user at that * node. The security authority creating the challenge can then be used to validate the response determining * whether the user generating the response is permitted to connect to this node.

* *

For example:

* *
 *        // Node 1                                           // Node 2
 * SecurityAuthority sa = ...;                         SecurityAuthority sa = ...;
 *
 * Challenge c = sa.createChallenge ();                // receive a challenge 'c' and send the response
 * // send 'c' to the other node and receive 'r'       Challenge c = ...;
 * Response r = ...;                                   Response r = sa.createResponse (c);
 *
 * if (sa.validateResponse (c, r)) {
 *   // access is permitted
 * } else {
 *   // access is denied
 * }
 * 
* *

To set the current user, ie the one which will create the response, use the logonUser * method. Obtaining a concrete user token is the responsibility of the concrete implementation. Similarly * creating the user IDs is the responsibility of the concrete implementation. No methods are defined in * this interface for these purposes because the number of parameters may vary depending on how users * authenticate. For example they may supply a username/password pair, just a username string * in a weaker system, or perhaps other, non-string credentials.

* *

To set the users which are currently permitted, ie will be considered to have generated a valid * response the permitUserAccess method must be used. To remove a user from this set the * denyUserAccess method should be used.

* * @author Quickstone Technologies Limited */ public interface SecurityAuthority extends ServiceUserObject, java.io.Serializable { /** *

Creates and returns a new challenge object. The challenge should be used as soon as possible and * only once as it may be logged by the authority, timestamped or protected in some other way. The * caller should retain a copy for use in the validateResponse method.

* * @return the challenge object. */ public Challenge createChallenge(); /** *

Determines if a response is valid for the given challenge. The challenge must have been generated * by a call to createChallenge. This should be called as soon as the response is * available and only once as there may be timestamping or other protection schemes in place.

* * @param c the challenge as returned by createChallenge and as passed to createResponse. * @param r the response from createResponse. * @return true if the response is valid and the user permitted. False otherwise. */ public boolean validateResponse(Challenge c, Response r); /** * Create a response for the given challenge coded with the currently logged on user. * * @param c the challenge created by createChallenge. * @return the response to be returned to the originator authority. */ public Response createResponse(Challenge c); /** * Sets the currently logged on user. * * @param u the token identifying an authenticated user. * @throws AccessDeniedException if the user token is not valid for this authority. */ public void logonUser(UserToken u) throws AccessDeniedException; /** * Clears the currently logged on user. */ public void logoffUser(); /** * Adds a user ID to the set of users considered by this authority to create valid responses to * challenges. * * @param u the user ID to add. * @throws AccessDeniedException if the user ID is not valid for this authority. */ public void permitUserAccess(UserID u) throws AccessDeniedException; /** * Removes a user ID from the set of users considered by this authority to create valid responses to * challenges. * * @param u the user ID to remove. * @throws AccessDeniedException if the user ID is not valid for this authority. */ public void denyUserAccess(UserID u) throws AccessDeniedException; }jcsp-1.1-rc4.orig/src/org/jcsp/net/ServiceSettings.java0000644000000000000000000001351211105701167017715 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.util.*; /** *

* This class is used to hold settings that can be passed to * services when they are initialized. Two types of settings can * be held. The basic type of settings that can be held are * String name,value pairs. Only one setting can exist per name. * The other type of settings that can be held are address settings. Each * address settings can hold a list of NodeAddressID objects * against a String name. *

*

* The class also has a field for storing the name of the Service. This can * be obtained by calling the getServiceName() method. *

* * @author Quickstone Technologies Limited */ public class ServiceSettings { /** * Constructor which takes the name of the serive for which this object * holds settings. * @param name the name of the service. */ public ServiceSettings(String name) { this.name = name; } /** * An accessor for obtaining the name of the service for which this object * holds settings. * @return the String name of the service. */ public String getServiceName() { return name; } /** * Adds a named address setting. * @param name the name of the setting to add. * @param address the address to add to the setting. */ public void addAddress(String name, NodeAddressID address) { Object o = addresses.get(name); if(o != null) { if(o instanceof Vector) ((Vector) o).add(address); else { Vector v = new Vector(); v.add(o); v.add(address); addresses.put(name, v); } } else addresses.put(name, address); } /** * Gets the addresses held in a setting of a specified name. * @param name the name of the setting * @return an array of NodeAddressID objects held in the setting. */ public NodeAddressID[] getAddresses(String name) { Object o = addresses.get(name); if(o == null) return new NodeAddressID[] {}; else if(o instanceof NodeAddressID) return new NodeAddressID[] {(NodeAddressID) o}; else { Vector v = (Vector) o; return (NodeAddressID[]) v.toArray(new NodeAddressID[v.size()]); } } /** * Returns an array of String objects containing the names of all * address settings held in this object. * @return a String array of all the address setting names. */ public String[] getAddressNames() { return (String[])addresses.keySet().toArray(new String[addresses.size()]); } /** * Returns an array of String objects containing the names of all * String name, value settings held in this object. * @return a String array of all the String name, value setting names. */ public String[] getSettingNames() { return (String[]) settings.keySet().toArray(new String[settings.size()]); } /** * Adds a String name, value setting to this object. * @param name the name of the setting to add. * @param value the value of the setting. */ public void addSetting(String name, String value) { settings.put(name, value); } /** * Gets the String value held in named * String name, value pair setting. * @param name the name of the setting of which to obtain the value. * @return the value of the setting. */ public String getSetting(String name) { return (String) settings.get(name); } private Hashtable addresses = new Hashtable(); private Hashtable settings = new Hashtable(); private String name; }jcsp-1.1-rc4.orig/src/org/jcsp/net/Node.java0000644000000000000000000006173011105701167015466 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; import java.util.*; /** *

* This class that is used for initializing and * managing the local JCSP.NET Node. A JCSP Node is a Java Virtual Machine * that has been initialized to form part of a JCSP.NET network. By this * definition, only one instance of this class is ever required on any * JVM. Therefore this class is a singleton class.To obtain the instance * of this class, use the {@link #getInstance()} method. *

*

*

Node Initialization

*

*

* Before any JCSP.NET constructs can be used, the Node must be initialized. * There are several init() methods for initializing the Node * in different ways. *

*

* In order for a Node to be initialized, there are various settings that are * required and others which are useful to have. A key facility of a Node is to * be able to communicate with other Nodes. This requires at least one * communications protocol to be installed and also ideally an address on which * to listen for incoming connections. As well as protocols, there are various * services that a user might want to start when ever the Node is initialized. * Technically the Node could be initialized and have its protocols, addresses and * services set up manually by the user. This would, however, be rather cumbersome. *

*

* The JCSP.NET infrastructure is not dependent upon any one network protocol. The * org.jcsp.net.tcpip package is provided but could easily * be replaced by an alternate protocol implementation. In the real world, TCP/IP is * likely to suit many uses and so this class assumes this as a default protocol. * With this assumption, it is possible to initialize the Node without any further * information. A Node can be initialized which installs TCP/IP as a protocol and * listens on all local IP addresses. This is precisely the bahaviour of the * {@link #init()} method with no parameters. *

*

* One of the facilities that most JCSP.NET users are likely to use is the * Channel Name Server. This requires a server process to be running on a * JCSP.NET Node and client services on all Nodes that wish to use the server. * Assuming that a Channel Name Server is running, then at the time of * Node initialization, the knowledge of this server's address is required. *

*

* The {@link org.jcsp.net.tcpip.TCPIPNodeFactory} has * knowledge of the Channel Name Server and has code for starting the client * service on a Node. It provides a constructor which takes the address of the * channel name server. An instance of the class can be created with this * constructor and passed to the {@link #init(NodeFactory)} method. * If the parameterless {@link #init()} is used, then an instance * of the factory is created using its instantiate method which takes no settings. * This tries to determine the address of the Channel Name Service through other * means (including system properties and the preferences API etc.). See * {@link org.jcsp.net.tcpip.TCPIPNodeFactory} for * more information on this. *

*

* Another NodeFactory class provided with JCSP.NET is the * {@link XMLNodeFactory}. This reads its settings from an * XML-like config file. This is not a full XML file as JCSP.NET provides * its own parser. This saves pre Java 1.4 users from obtaining an XML * parsing package. See {@link XMLNodeFactory} for full * documentation on how to use this. *

*

* As well as initialization methods which take NodeFactory * objects, there are also methods which take protocol settings * directly. See the {@link #init(NodeAddressID)}, {@link #init(NodeAddressID[])} * and {@link #init(NodeAddressID[], Hashtable[])} methods. *

*

* All of the Node init methods return a NodeKey object which * is required for Node management methods. *

*

*

Node Management

*

*

* Once initialized, JCSP Nodes can have their settings altered. There are two * manager classes of which each Node has an instance; * {@link ServiceManager} and {@link ProtocolManager}. * These instances can be obtained from the local Node object by * calling their respective accessors ({@link #getServiceManager} * and {@link #getProtocolManager}). Each of these accessors takes * a {@link NodeKey} object as a parameter. This is for security * reasons. Any process can obtain a reference to the local Node object. Without * this key parameter, any process could therefore perform Node management * operations. This key allows gives control of access to these methods to the * process which initialized the Node. This process can decide who it trusts. *

*

* See {@link ServiceManager} and * {@link ProtocolManager} for more information. *

*

*

Logging

*

*

* The Node class provides two static {@link Logger} objects for * programs to log information. {@link Node#info} provides * facilities for logging information messages. {@link Node#err} * provides facilities for logging error messages. The output from these * logging objects can be enabled or disabled. See {@link Logger} * for more information. *

* * @author Quickstone Technologies Limited */ public class Node { /*-------------------Attributes-----------------------------------------------*/ private NodeID nodeID; private Specification[] specifications = null; private UIFactory uiFactory; private boolean initialized = false; private ProtocolManager protocolManager = ProtocolManager.getInstance(); private ServiceManager serviceManager = new ServiceManager(); private NodeKey nodeKey = new NodeKey(); private int appIDCounter = 0; /*-------------------Singleton Class Instance--------------------------------*/ private static Node instance = new Node(); /*-------------------Private Constructor-------------------------------------*/ private Node() { } /*-------------------Static Methods------------------------------------------*/ /** * Returns the instance of this singleton class. * * @return the instance of Node. */ public static Node getInstance() { return instance; } private static NodeFactory factory = org.jcsp.net.tcpip.TCPIPNodeFactory.instantiate(); public static void setNodeFactory(NodeFactory fac) { factory = fac; } /** * A {@link Logger} for logging information messages.. */ public static final Logger info = new Logger("info", "stdout"); /** * A {@link Logger} for logging error messages. */ public static final Logger err = new Logger("err", "stderr"); /*-------------------Init Methods--------------------------------------------*/ /** *

* This method functions the same as calling * init(NodeAddressID[]) with a single element in the * array. *

* @param localAddress an address on which to start a LinkServer process. * @throws IllegalStateException if the local Node has already been initialized. * @throws IllegalArgumentException if no addresses are supplied. * @throws NodeInitFailedException if the Node is not able to initialize. * @return the NodeKey required for Node management. */ public NodeKey init(NodeAddressID localAddress) throws IllegalStateException, IllegalArgumentException, NodeInitFailedException { if (localAddress == null) throw new IllegalArgumentException("Null address"); return init(new NodeAddressID[] { localAddress }); } /** *

* This method is functionally equivalent to calling * init(NodeAddressID[], HashTable) with the HashTable * parameter being supplied as null. *

* @param localAddresses the addresses on which to start LinkServer processes. * @throws IllegalStateException if the local Node has already been initialized. * @throws IllegalArgumentException if no addresses are supplied. * @throws NodeInitFailedException if the Node is not able to initialize. * @return the NodeKey required for Node management. */ public NodeKey init(NodeAddressID[] localAddresses) throws IllegalStateException, IllegalArgumentException, NodeInitFailedException { return init(localAddresses, null); } /** *

* Initializes the local Node and starts LinkServer listening * on each of the supplied NodeAddressID objects. The * protocols that match each address are also installed in the local * protocol manager. If protocol settings are supplied, then these are * used when the protocols are installed. *

*

* A key is returned that needs to be supplied to certain management methods. *

* * @param localAddresses the addresses on which to start * LinkServer processes. * @param protocolSettings an array of HashTable objects each * containing settings for the protocols to be * installed. * Each HashTable is passed to the * protocol's ProtocolID object's * getLinkBuilder(HashTable) method. * No restriction is placed on protocol * implementations as to how this * HashTable object be used. See the * documentation for whatever protocol * implementation is being used. * @throws IllegalStateException if the local Node has already been initialized. * @throws IllegalArgumentException if no addresses are supplied. * @throws NodeInitFailedException if the Node is not able to initialize. * @return the NodeKey required for Node management. */ public NodeKey init(NodeAddressID[] localAddresses, Hashtable[] protocolSettings) throws IllegalStateException, IllegalArgumentException, NodeInitFailedException { if (localAddresses == null || localAddresses.length == 0) throw new IllegalArgumentException("Null argument"); if (protocolSettings != null && protocolSettings.length != localAddresses.length) throw new IllegalArgumentException("Wrong number of protocol settings"); for (int i = 0; i < localAddresses.length; i++) { if (localAddresses[i] == null) throw new IllegalArgumentException("Null address"); } // Only call this once or else... if (initialized) throw new IllegalStateException("Attempted to initialize org.jcsp.net.Node twice!"); //start Link Manager LinkManager.getInstance().start(); //Look to see if a System property has been set to set a //different UIFactory to be used. String uiFactoryClassName = System.getProperty("JCSP.UIFactoryClass"); if (uiFactoryClassName != null) { try { Class uiFactoryClass = Class.forName(uiFactoryClassName); uiFactory = (UIFactory) uiFactoryClass.newInstance(); } catch (Exception e) { Node.err.log(this, "Error trying to load UIFactory: " + uiFactoryClassName); throw new NodeInitFailedException("Error trying to load UIFactory: " + uiFactoryClassName); } } else uiFactory = new UIFactory(); nodeID = new NodeID(uiFactory.getUIForThisJVM()); for (int i = 0; i < localAddresses.length; i++) { if (!protocolManager.installProtocolServer(localAddresses[i], null)) throw new NodeInitFailedException("Unable to start LinkServer on " + localAddresses[i]); Hashtable hs = null; if (protocolSettings != null) hs = protocolSettings[i]; if (!protocolManager.installProtocolClient(localAddresses[i].getProtocolID(), null, hs)) throw new NodeInitFailedException("Unable to install protocol " + localAddresses[i].getProtocolID()); } initialized = true; return nodeKey; } /** *

* Initializes the Node with the current static NodeFactory. * This can be set by calling the * {@link #setNodeFactory(NodeFactory)} method. *

*

* This default factory is currently the * {@link org.jcsp.net.tcpip.TCPIPNodeFactory}. * This is instantiated with its instantiate() method. *

* * @return the NodeKey required for Node management. * @throws NodeInitFailedException if the Node is not able to initialize. * @see #init(NodeFactory) */ public NodeKey init() throws NodeInitFailedException { return init(factory); } /** *

* Initializes the Node with the specified * {@link NodeFactory} object. *

*

* This invokes the factory's initNode(Node, Node.Attributes) * method to actually perform the initialization. *

*

* This package provides an {@link XMLNodeFactory} which * instantiates the Node from settings read from an XML-like config file. *

* @return the NodeKey required for Node management. * @throws NodeInitFailedException if the Node is not able to initialize. */ public NodeKey init(NodeFactory factory) throws NodeInitFailedException { if (initialized) throw new IllegalStateException("Attempted to initialize org.jcsp.net.Node twice!"); NodeKey nk = factory.initNode(this, new AttributesAccess()); if (nk == null) { initialized = false; throw new NodeInitFailedException(); } return nk; } /*-------------------Other Public Methods-------------------------------------*/ /** *

* This method allows a NodeID to be checked to see whether it * represents the local Node. It is provided as a more efficient way of * performing this check than obtaining the local node and checking manually. * This would result in the local NodeID object being cloned. *

* * @return boolean indicating whether the address supplied is local. * @param nodeID a NodeID to check against the local Node's NodeID. * @throws IllegalStateException if the local Node has not been initialized. */ public boolean isThisNode(NodeID nodeID) throws IllegalStateException { checkInitialized(); synchronized (this.nodeID) { return this.nodeID.equals(nodeID); } } /** *

* Checks that the Node has been initialized. If so, returns normally, * otherwise throws an IllegalStateException. *

* * @throws IllegalStateException If init() has not been called. */ void checkInitialized() throws IllegalStateException { if (!initialized) throw new IllegalStateException("org.jcsp.net.Node not initialized."); } /** *

* Returns true if the node has already been initialized, * false otherwise. *

* * @return a true iff Node has been initialized. */ public boolean isInitialized() { return initialized; } /** *

* Method for obtaining a clone of this Node's NodeID. *

*

* This method does not expose the actual underlying object as it is not * immutable. *

* * @return this Node's NodeID. A clone of the one held by this class. * @throws IllegalStateException if this Node has not been initialized. */ public NodeID getNodeID() throws IllegalStateException { checkInitialized(); try { synchronized (this.nodeID) { return (NodeID) nodeID.clone(); } } catch (CloneNotSupportedException e) { //should never be called return null; } } synchronized NodeID getActualNode() { return nodeID; } public synchronized ApplicationID getNewApplicationID() { return new ApplicationID(this.nodeID, this.appIDCounter++); } /** *

* Accessor for obtaining a reference to the local Node's * ProtocolManager object. The local Node's key must * be supplied in order to obtain this reference. This prevents * any unauthorized code from managing the local Node's communication protocols. *

* @param nodeKey the local Node's NodeKey. * @return the local Node's ProtocolManager or null> if * an incorrect key is supplied. */ public ProtocolManager getProtocolManager(NodeKey nodeKey) { if (nodeKey == this.nodeKey) return protocolManager; return null; } /** *

* Accessor for obtaining a reference to the local Node's * ServiceManager object. The local Node's key must * be supplied in order to obtain this reference. This prevents * any unauthorized code from managing the local Node's services. *

* * @param nodeKey the local Node's NodeKey. * @return the local Node's ServiceManager or null> if * an incorrect key is supplied. */ public ServiceManager getServiceManager(NodeKey nodeKey) { if (nodeKey == this.nodeKey) return getServiceManager(); return null; } ServiceManager getServiceManager() { return serviceManager; } /** *

* Obtains a ServiceUserObject from a named Service and * returns a reference to it. This method calls * getService(String) on a Service object and * will therefore obey the rules implemented in the requested Service. *

*

* Generally, services are expected to check whether the requesting * process has permission to access the user object and throw a * SecurityException if access is denied. *

* @return a ServiceUserObject object. * */ public ServiceUserObject getServiceUserObject(String name) { return serviceManager.getService(name).getUserObject(); } /** *

* Verifies that the supplied key matches the local Node's key. *

* @param nodeKey a NodeKey to check against that of the local Node's. * @return true iff the supplied key matches the local * Node's key. */ public boolean verifyKey(NodeKey nodeKey) { return this.nodeKey == nodeKey; } /** *

* Returns an array of Specification objects to which this * Node conforms. *

* @return the set of defined Specification objects for this Node. */ public Specification[] getNodeSpecifications() { return (Specification[]) specifications.clone(); } /** *

* This method tests whether a link currently exists to * a specified remote Node. *

* * @param otherNode The NodeID of a remote Node to check * the existance * @return true iff a link currently exists to * the specified remote Node. */ public boolean linkExists(NodeID otherNode) { return LinkManager.getInstance().linkExists(otherNode); } /** *

* This method allows users to obtain notification of link failure. *

*

* The API surrounding these events is new and will possibly change. Users * should be aware of this and only use if stricly necessary. *

*

* This returns an AltingChannelInput which will receive * events signifying that a link to a particular Node has be been dropped. * This will receive NodeID objects which signigy the remote * Nodes at the other end of links which have been dropped. *

* * @return the AltingChannelInput event channel. */ public AltingChannelInput getLinkLostEventChannel() { return LinkManager.getInstance().getLinkLostEventChannel(); } /*-------------------Package Private Methods----------------------------------*/ /*-------------------Inner Classes--------------------------------------------*/ /** * An interface for exposing access to the private attributes. This is public. */ public interface Attributes { public void setSpecifications(Specification[] specs); public NodeID setUIFactory(UIFactory factory); public void setInitialized(); public ProtocolManager getProtocolManager(); public ServiceManager getServiceManager(); public NodeKey getNodeKey(); public NodeInitFailedException exception(String msg); public void startLinkManager(); } /** * A class for exposing access to the private attributes. This is private so that only * this class can create an instance. The interface (Attributes) is public to allow it * to be used once created. */ private class AttributesAccess implements Attributes { public void setSpecifications(Specification[] specs) { specifications = specs; } public NodeID setUIFactory(UIFactory factory) { uiFactory = factory; nodeID = new NodeID(uiFactory.getUIForThisJVM()); return nodeID; } public void setInitialized() { initialized = true; } public ProtocolManager getProtocolManager() { return protocolManager; } public ServiceManager getServiceManager() { return serviceManager; } public NodeKey getNodeKey() { return nodeKey; } public NodeInitFailedException exception(String msg) { return new NodeInitFailedException(msg); } public void startLinkManager() { LinkManager.getInstance().start(); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/LinkServer.java0000644000000000000000000001072611105701167016664 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * An abstract class that must be implemented by communication * protocol implementations. LinkServer objects are * processes which listen on a certain address for connection * requests. When a request is received, a Link should be spawned in * server mode. * * @author Quickstone Technologies Limited */ public abstract class LinkServer { /** * Constructor. A LinkServer must have an associated protocolID. * @param protocolID The ProtocolID for the protocol that the concrete implementation of LinkServer supports. * @param linkServerAddressID the NodeAddressID for this LinkServer to listen on. */ protected LinkServer(ProtocolID protocolID, NodeAddressID linkServerAddressID) { if (protocolID == null || linkServerAddressID == null) throw new IllegalArgumentException("ProtocolID cannot be null"); this.protocolID = protocolID; this.linkServerAddressID = linkServerAddressID; } /** * Create a server on a specifiedNodeAddressID, and start it. The server * is spawned off in parallel, so this call returns immediately. This needs * to be implemented by the concrete implementation of this class. This is * not enforced by the compiler due to this being a static method. * * This NEEDS to be overridden. * * @param addressID The NodeAddressID to accept from * @return the instance of LinkServer. */ protected static LinkServer create(NodeAddressID addressID) { throw new UnsupportedOperationException(); } /** * Stops the LinkServer. * * This NEEDS to be overridden. * @return true iff the LinkServer has stopped. */ protected boolean stop() { throw new UnsupportedOperationException(); } /** * Gets the protocol that this LinkServer supports. * * @return the ProtocolID representing this LinkServers protocol. */ protected final ProtocolID getProtocolID() { return protocolID; } /** * Protected accessor for obtaining the NodeAddressID on which * this server is listening. * @return the NodeAddressID on which this server is listening. */ protected final NodeAddressID getLinkServerAddressID() { return linkServerAddressID; } private final ProtocolID protocolID; private final NodeAddressID linkServerAddressID; }jcsp-1.1-rc4.orig/src/org/jcsp/net/ProtocolManager.java0000644000000000000000000002221611105701167017671 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.util.*; /** *

* The ProtocolManager class is a singleton class. * See the documentation for the Node class * for information on how to obtain a reference to its instance. *

*

* A reference to a Node's ProtocolManager allows the Nodes installed * protocols to be managed. Installing a protocol server creates a * LinkServer that listens on a specified NodeAddressID. * In order to connect to a Node's LinkServer, a Node must have * a matching protocol client installed in its local ProtocolManager. *

*

* When protocol clients and servers are installed, an array of * Specification objects can be supplied. These are * specifications that the client or server meets. The specifications for * a given protocol can be obtained and then used to test whether a set of * specifications match a given Profile. *

* @author Quickstone Technologies Limited */ public class ProtocolManager { /*-------------------Singleton Class Instance---------------------------------*/ private static ProtocolManager instance = new ProtocolManager(); /*-------------------Private Constructor--------------------------------------*/ private ProtocolManager() { } /*----------------------Methods-----------------------------------------------*/ static ProtocolManager getInstance() { return instance; } /** Returns an array of Specification objects that are held for * a specified protocol. * @param protocolID the ProtocolID of a protocol * @return the specifications of the supplied protocol. */ public Specification[] getProtocolSpecifications(ProtocolID protocolID) { return (Specification[]) protocolSpecifications.get(protocolID); } /** Returns an array of Specification objects that are held for * a specified local address. * @param addressID a NodeAddressID that should match an address on which a local * LinkServer is listening. * @return the set of specifications that are held against * the specified address. */ public Specification[] getAddressSpecifications(NodeAddressID addressID) { return (Specification[]) addressSpecifications.get(addressID); } /** Installs a LinkServer listening on a specified * NodeAddressID and holds the specified set of * Specification objects against the address. * @param addressID the address on which the LinkServer should be started. * @param specifications the specifications to hold against the address. * @return true iff the server is successfully installed. */ public boolean installProtocolServer(NodeAddressID addressID, Specification[] specifications) { if(addressID == null) return false; synchronized(linkServers) { if(!linkServers.contains(addressID)) { ProtocolID pID = addressID.getProtocolID(); LinkServer ls = pID.startLinkServer(addressID); if(ls != null) { linkServers.put(addressID, ls); if(specifications != null) addressSpecifications.put(addressID, specifications); //update Node with new address NodeID thisNode = Node.getInstance().getActualNode(); synchronized(thisNode) { //add the address taken from LinkServer in case it //has been modified thisNode.addAddress(ls.getLinkServerAddressID()); } return true; } } } return false; } /** Stops the LinkServer that is listening on the specified address. * @param addressID the NodeAddressID on which the LinkServer to * stop is listening. * @return true if, after returning, no LinkServer is listening * on the specified adddress. */ public boolean stopProtocolServer(NodeAddressID addressID) { if(addressID == null) return false; if(linkServers.contains(addressID)) { LinkServer ls = (LinkServer)linkServers.get(addressID); if(ls != null) { if(ls.stop()) { linkServers.remove(addressID); addressSpecifications.remove(addressID); return true; } } } else return true; return false; } /** Installs a protocol client so that links can be established to Nodes with * LinkServer processes listening on the specified protocol. * @param protocolID The ProtocolID of the protocol to install. * @param specifications The specification of the protocol being installed. * @param settings a HashTable that can contain settings that are passed * to the protocol's Builder. * @return true iff the protocol client is successfully installed or * has already been installed. */ public boolean installProtocolClient(ProtocolID protocolID, Specification[] specifications, Hashtable settings) { if(protocolID == null) return false; if(protocolClients.get(protocolID) != null) return true; LinkFactory.Builder builder = protocolID.getLinkBuilder(settings); if(LinkFactory.getInstance().installBuilder(builder)) { protocolClients.put(protocolID, builder); if(specifications != null) protocolSpecifications.put(protocolID, specifications); return true; } return false; } /** Removes the installed protocol client for a specified protocol. * @param protocolID the ProtocolID of the protocol client to remove. * @return true iff a matching protocol client has been successfully removed. */ public boolean removeProtocolClient(ProtocolID protocolID) { if(protocolID == null) return false; LinkFactory.Builder builder = (LinkFactory.Builder)protocolClients.get(protocolID); if(builder == null) return false; if(LinkFactory.getInstance().removeBuilder(protocolID, builder)) { protocolClients.remove(protocolID); protocolSpecifications.remove(protocolID); return true; } return false; } /*----------------------Attributes--------------------------------------------*/ private Hashtable linkServers = new Hashtable(); /** * This Hashtable contains protocolID's as the keys which map to * builders that build the links for that protocol. */ private Hashtable protocolClients = new Hashtable(); private Hashtable addressSpecifications = new Hashtable(); private Hashtable protocolSpecifications = new Hashtable(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetLabelledChannelEndFactory.java0000644000000000000000000000745011105701167022223 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* This factory constructs NetChannelInput objects * which have labelled VCN's. *

*

* JCSP.NET network channel addresses (signified by * {@link NetChannelLocation} objects) have a * Virtual Channel Number (VCN). This number is not exposed * to JCSP users but is an integral part of channel addressing. *

*

* If two Nodes have no means of communication, there is no * way that one can pass a {@link NetChannelLocation} * object to the other. This means that a channel cannot be * established using convential means. JCSP.NET solves this * problem by allowing VCN's to be labelled by the user. * If the address of a Node hosting a ChannelInput * with a known labelled VCN is known by a process in another Node, * then a ChannelOutput can be established by * constructing with a NetChannelLocation object constrcuted * using the {@link * NetChannelLocation#NetChannelLocation(NodeAddressID, String) * } constructor. *

* * @author Quickstone Technologies Limited */ public interface NetLabelledChannelEndFactory { /** * Constructs a NetAltingChannelInput which * has a VCN assigned with the specified label. * * @param label the label to apply to the channel's VCN. * * @return the constructed NetAltingChannelInput * object. */ public NetAltingChannelInput createNet2One(String label); /** * Constructs a NetSharedChannelInput which * has a VCN assigned with the specified label. * * @param label the label to apply to the channel's VCN. * * @return the constructed NetSharedChannelInput * object. */ public NetSharedChannelInput createNet2Any(String label); }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetSharedChannelOutput.java0000644000000000000000000000443711105701167021171 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.SharedChannelOutput; /** * This interface should be implemented by classes that * wish to act as NetChannelOutput objects * which can be used by muliple concurrent processes. * * @author Quickstone Technologies Limited */ public interface NetSharedChannelOutput extends NetChannelOutput, SharedChannelOutput { }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetConnectionClient.java0000644000000000000000000000464211105701167020505 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.ConnectionClient; /** * This interface should be implemented by classes that wish to act * as Networked ConnectionClient objects. * * @author Quickstone Technologies Limited */ public interface NetConnectionClient extends Networked, ConnectionClient { /** * Destroys the NetConnectionClient object and frees * any resources created within the JCSP.NET infrastructure. * */ public void destroyClient(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/GlobalID.java0000644000000000000000000001022711105701167016211 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** *

* A Class whose instances represent the global domain. * There is only ever a need to have one instance of this class * per JVM so a static instance is supplied. *

*

* The GlobalID object is the parent * AbstractID to all top level DomainID objects. *

*

* See {@link AbstractID} for a fully explanation of * this class. *

* * @author Quickstone Technologies Limited */ public final class GlobalID extends AbstractID implements Serializable { /** *

* Returns null as there is no parent * AbstractID of instances of this class. *

* @return null. */ public AbstractID getParentID() { return null; } /** *

* Compares another object with this GlobalID object. *

* @param o an object to compare with object. * @return true iff the other object is a GlobalID. */ public boolean equals(Object o) { if (o == null || !(o instanceof GlobalID)) return false; //o is an instance of GlobalID, therefore equal return true; } /** *

* Returns an int hash code for this object. *

* @return an int hash code. */ public int hashCode() { return ("GlobalID").hashCode(); } /** *

* Returns a human readable string representation of a * GlobalID. *

* * @return The human readable String - currently "Global". */ public String toString() { return "Global"; } boolean onSameBranch(AbstractID abstractID) { if (abstractID != null && abstractID instanceof GlobalID) return true; return false; } /** *

* A static instance of GlobalID. * Instead of creating GlobalID objects, it * is better to use this instance as only once instance is * ever required. *

* */ public static final GlobalID instance = new GlobalID(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/AcknowledgementsBuffer.java0000644000000000000000000002040411105701167021216 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.util.ChannelDataStore; import java.io.Serializable; /** * This is used to create a buffered object channel that always accepts and * never loses any input. *

Description

* AcknowledgementsBuffer is an implementation of ChannelDataStore that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * However, its capacity is infinite (expanding to whatever is needed so far as * the underlying memory system will permit). So, it never gets full and blocks * a writer. * See the static * {@link org.jcsp.lang.One2OneChannel#create(org.jcsp.util.ChannelDataStore) create} * methods of {@link org.jcsp.lang.One2OneChannel} etc. *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. *

* An initial size for the buffer can be specified during construction. *

* This buffer will save memory by changing multiple ChannelMessage.Ack messages into * AcknowledgementsBuffer.Acks. * * @see org.jcsp.util.InfiniteBuffer * @author Quickstone Technologies Limited */ //package-private class AcknowledgementsBuffer implements ChannelDataStore, Serializable { /** * The default size of the buffer */ private static final int DEFAULT_SIZE = 8; /** * The initial size of the buffer */ private int initialSize; /** * The storage for the buffered Objects */ private Object[] buffer; /** * The number of Objects stored in the InfiniteBuffer */ private int counter = 0; /** * The index of the first element */ private int firstIndex = 0; /** * The index of the last element */ private int lastIndex = 0; /** * The Acks which is currently in the buffer. */ private Acks acks = null; /** * Compressed form of one or more acknowledgements. */ //package-private static class Acks { /** * Count of acknowledgements */ //package-private int count = 1; long vcn = -1; NodeID sourceNodeID = null; /** * Default Constructor. */ //package-private Acks() { } } /** * Construct a new InfiniteBuffer with the default size (of 8). */ //package-private AcknowledgementsBuffer() { this(DEFAULT_SIZE); } /** * Construct a new AcknowledgementsBuffer with the specified initial size. * * @param initialSize the number of Objects * the AcknowledgementsBuffer can initially store */ //package-private AcknowledgementsBuffer(int initialSize) { this.initialSize = initialSize; buffer = new Object[initialSize + 1]; } /** * Returns the oldest Object from the InfiniteBuffer and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the InfiniteBuffer */ public Object get() { Object value = buffer[firstIndex]; buffer[firstIndex] = null; firstIndex = (++firstIndex) % buffer.length; counter--; if (value == acks) acks = null; return value; } public Object startGet() { Object value = buffer[firstIndex]; if (value == acks) acks = null; return value; } public void endGet() { buffer[firstIndex] = null; firstIndex = (++firstIndex) % buffer.length; counter--; } /** * Puts a new Object into the InfiniteBuffer. *

* Implementation note: if InfiniteBuffer is full, a new internal * buffer with double the capacity is constructed and the old data copied across. * * @param value the Object to put into the InfiniteBuffer */ public void put(Object value) { if (value instanceof ChannelMessage.Ack) { if (acks == null) { // Add new Acks entry to array. acks = new Acks(); /* This was put in so that a channel which used a label instead of a vcn could obtain the destination's actual vcn. This only really needs to be done once so perhaps this should be changed. */ acks.vcn = ((ChannelMessage.Ack)value).sourceIndex; acks.sourceNodeID = ((ChannelMessage.Ack)value).sourceID; value = acks; } else { // Just increment Acks counter. // Don't add anything to array. acks.count++; return; } } // Add value to array if (counter == buffer.length) { Object[] temp = buffer; buffer = new Object[buffer.length * 2]; System.arraycopy(temp, firstIndex, buffer, 0, temp.length - firstIndex); System.arraycopy(temp, 0, buffer, temp.length - firstIndex, firstIndex); firstIndex = 0; lastIndex = temp.length; } buffer[lastIndex] = value; lastIndex = (++lastIndex) % buffer.length; counter++; } /** * Returns the current state of the AcknowledgementsBuffer. * * @return the current state of the AcknowledgementsBuffer (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) AcknowledgementsBuffer with the same * creation parameters as this one. *

* Note: Only the initial size and structure of the AcknowledgementsBuffer * is cloned, not any stored data. * * @return the cloned instance of this AcknowledgementsBuffer. */ public Object clone() { return new AcknowledgementsBuffer(initialSize); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; acks = null; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/One2NetChannel.java0000644000000000000000000004777011105701167017354 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; import org.jcsp.util.InfiniteBuffer; import java.io.*; /** * A channel for network output (TX). This is a "One2Net" channel, * which can only be safely used by one writer. * * @author Quickstone Technologies Limited */ class One2NetChannel implements NetChannelOutput, Serializable { /***********Constructors******************************************************/ /** * Constructor which takes the location of a Networked * ChannelInput to which to send data. * The channel constructed will block after any data is sent * until an acknowledgement is returned. * * A Link to the ChannelInput object's Node will * be established if necessary. This Link may be established over any * available protocol implementation. * * This constructor is equivalent to using the * (NetChannelLocation, boolean, Profile) constructor with * the boolean set to true and * the Profile set to null. * */ public One2NetChannel(NetChannelLocation channelLocation) { this(channelLocation, true, null); } /** * Constructor which takes the location of a Networked * ChannelInput to which to send data and a * Profile that any Link used should match. * * The channel constructed will block after any data is sent * until an acknowledgement is returned. * * A Link to the ChannelInput object's Node will * be established if necessary. This Link will match the specified * Profile. A RuntimeException will be thrown if a * a matching Link cannot be established. * * This constructor is equivalent to using the * (NetChannelLocation, boolean, Profile) constructor with * the boolean set to true. * */ public One2NetChannel(NetChannelLocation channelLocation, Profile linkProfile) { this(channelLocation, true, linkProfile); } /** * Constructor which takes the location of a Networked * ChannelInput to which to send data and a * boolean indicating whether or not to obtain * acknowledgements. * * If the acknowledged parameter is true, then the channel * constructed will block after any data is sent * until an acknowledgement is returned. Otherwise, the channel should not * block, however, some flow control may be implemented which may result * in blocking. * * A Link to the ChannelInput object's Node will * be established if necessary. This Link may be established over any * available protocol implementation. * * This constructor is equivalent to using the * (NetChannelLocation, boolean, Profile) constructor with * the Profile set to null. * */ public One2NetChannel(NetChannelLocation channelLocation, boolean acknowledged) { this(channelLocation, acknowledged, null); } /** * Constructor which takes the location of a Networked * ChannelInput to which to send data and a * boolean indicating whether or not to obtain * acknowledgements. * * If the acknowledged parameter is true, then the channel * constructed will block after any data is sent * until an acknowledgement is returned. Otherwise, the channel should not * block, however, some flow control may be implemented which may result * in blocking. * * A Link to the ChannelInput object's Node will * be established if necessary. This Link will match the specified * Profile. A RuntimeException will be thrown if a * a matching Link cannot be established. * */ public One2NetChannel(NetChannelLocation channelLocation, boolean acknowledged, Profile linkProfile) { this.acknowledged = acknowledged; this.channelLocation = channelLocation; this.channelID = new ChannelID(channelLocation.getChannelNodeID(), channelLocation.getVCN()); this.linkProfile = linkProfile; this.maxUnacknowledged = 0; if (acknowledged) { IndexManager.ChannelAndIndex chanAndIndex = IndexManager.getInstance().getNewReplyChannel(this); fromNetIn = chanAndIndex.channel.in(); fromNetOut = chanAndIndex.channel.out(); channelIndex = chanAndIndex.index; } else channelIndex = -1; } /***********Private fields****************************************************/ /** * The channel ID of the remote computer. * Not valid unless we are connected. */ private transient ChannelID channelID; /** * Our channel index. (On the local computer, for acknowlegements). */ private transient long channelIndex; /** * The channel we use for recieving from the demuxes. */ private transient AltingChannelInput fromNetIn; private transient SharedChannelOutput fromNetOut; /** * The channel we use for sending to the network TX. * Not valid unless we are connected. */ private transient ChannelOutput toNet; /** * True iff the link's been dropped. */ private transient boolean broken; /** * True iff we're connected to the remote computer. */ private transient boolean connected; private transient ChannelMessage.Data messageA = new ChannelMessage.Data(); private transient ChannelMessage.Data messageB = new ChannelMessage.Data(); private transient boolean sendMessageA = true; /** * The channel name. * * @serial */ private NetChannelLocation channelLocation; /** * The Profile that the link used by this channel should match. */ private final Profile linkProfile; /** * The maximum number of data items "in flight" when a call to write() * returns. The default setting of zero gives standard unbuffered * channel semantics. * * 5/Jun/2002 * This is not currently used nor exposed to the user. * Streaming has been changed so that acknowledgements are * either on or off. Flow control really needs to be * controlled from the receiving end but this functionality * has not yet been implemented. * * @serial */ private final int maxUnacknowledged; /** * The number of data items currently unacknowledged ("in flight"). * Always <= maxUnacknowledged + 1. If it is > maxUnacknowledged, * then we must be blocked in write(). */ private transient int numUnacknowledged; /** * Indicates whether this channel requires acknowledgements to be * returned from the receiver. * */ private boolean acknowledged = true; /***********Public Methods****************************************************/ /** * Output data to this channel. The data must be Serializable. *

* For a normal channel (numUnacknowledged == 0), the contract of this * method is as follows: When the method returns, the data has been sent * to the remote computer, and the process (or user-supplied buffer) at * the other end has accepted it. It is safe to modify data * after the call. Transmission is guaranteed unless a * LinkLostException is thrown, in which case it is impossible to * determine whether or not the remote computer recieved the data * before the link dropped. *

* For a streaming channel (numUnacknowledged > 0), the contract of * this method is slightly different. When the method returns, the data * has started it's trip to the remote computer, but the link may go down * so there is no guarantee that it will get there. Also, since it may * not have left this computer yet (the actual transmission is done in * parallel with the return from this method), it is *NOT* safe to modify * the passed data object. After the next call to this * method, then you may assume that the data object has been * transmitted, and re-use it or let the Java garbage collector deal with * it as appropriate. You must wait a total of numUnacknowledged * calls to this method before you can assume that the data was recieved * - and if any of those calls throw a LinkLostException, then you * cannot find out how much of the stream of data was recieved by the * remote computer before the link broke. *

* A LinkLostException is thrown if the TCP/IP link is dropped. * This could be due to a network problem, but more often it is caused * when the remote Java VM crashes or is shut down. It can also be * caused if there is a serialization problem with the TCP/IP link - e.g. * an attempt to send a non-serializable object, or an attempt to send a * class which doesn't exist or isn't the same version at the recieving * end. Note that LinkLostException is a permanent error - if it * is thrown, then any further call to this method will cause it to be * thrown again. * * @param data an object to send over the channel. This should be Serializable. */ public synchronized void write(Object data) { if (broken) // Oops. throw new LinkLostException(this, /*name*/"FILL IN"); if (!connected) { if (channelID == null) channelID = new ChannelID(channelLocation.getChannelNodeID(), channelLocation.getVCN()); if (channelLocation.getChannelNodeID() == null) toNet = LinkManager.getInstance().getTxChannel(channelLocation.getChannelAddress()); else toNet = LinkManager.getInstance().getTxChannel(channelID.getNodeID(), linkProfile); connected = true; } // Now we're set up, do the output. // Create a Message object to hold the message ChannelMessage.Data message = null; if (acknowledged) { if(sendMessageA) message = messageA; else message = messageB; sendMessageA = !sendMessageA; } else //if not acknowledge too dangerous to use message pool message = new ChannelMessage.Data(); message.destIndex = channelID.getIndex(); message.sourceIndex = channelIndex; message.data = data; message.acknowledged = acknowledged; if (message.destIndex == IndexManager.getInvalidVCN()) message.destVCNLabel = channelLocation.getChannelLabel(); else message.destVCNLabel = null; // Transmit the message toNet.write(message); // One more acknowldgement we should get back. if (acknowledged) { numUnacknowledged++; // Loop around recieving messages. We can't continue if the number // of acks pending is over the limit. Otherwise, we just loop // until we've read the Acks _or_ we've run out of things to read. // // (Claim: This is a _fair_ system - i.e. similar to fair ALTing // between acks and data to send. This is because there are // never two sends in a row without an attempt to read acks, and // this thread never reads two acks in a row without a send. // What's more, since the special buffer is merging acks, all // pending acks are processed in a single read each time we send). boolean gotAcks = false; while ((numUnacknowledged > maxUnacknowledged) || ((!gotAcks) && fromNetIn.pending())) { Object obj = fromNetIn.read(); if (obj instanceof AcknowledgementsBuffer.Acks) { numUnacknowledged -= ((AcknowledgementsBuffer.Acks)obj).count; // Could (should?) check that numUnacknowledged >= 0 here, // but I'm going to assume that the other side isn't that // broken. Besides, even if numUnacknowledged < 0, what can // we do about it? gotAcks = true; if (message.destVCNLabel != null) { channelID = new ChannelID(((AcknowledgementsBuffer.Acks)obj).sourceNodeID, ((AcknowledgementsBuffer.Acks)obj).vcn); channelLocation.setLocationDetails(channelID.getNodeID(), channelID.getIndex()); } } else if (obj instanceof LinkLost) { LinkLost cl = (LinkLost)obj; cl.txChannel.write(cl); // acknowlegement. if (cl.txChannel == toNet) { broken = true; toNet = null; throw new LinkLostException(this, "Lost Link to " + ((LinkLost) obj).address); } } else if(obj instanceof Message.BounceMessage) throw new ReaderIndexException(); else if(obj instanceof ChannelMessage.WriteRejected) throw new ChannelDataRejectedException(); else { Node.err.log(this, "One2NetChannel, write: Received unexpected message type: " + ((obj == null) ? null : obj.getClass())); throw new NetChannelError("One2NetChannel received invalid " + "message over acknowledgement channel. This could be " + "caused by using a Non-shared NetChannelOutput object " + "between multiple processes!"); } } } // Done! } /** * Returns a clone of the NetChannelLocation object * held by the instance of this class which contains information * about the location of the networked ChannelInput * object to which this ChannelOutput is connected. * * @return the NetChannelLocation of the destination * ChannelInput. * */ public NetChannelLocation getChannelLocation() { try { return (NetChannelLocation) channelLocation.clone(); } catch (CloneNotSupportedException e) { return null; } } static Any2OneChannel failedLinks = Channel.any2one(new InfiniteBuffer()); static { new ProcessManager(new CSProcess() { public void run() { while (true) { One2NetChannel c = (One2NetChannel)failedLinks.in().read(); c.destroyWriter(); } } }).start(); } void linkFailed(NodeID remoteID) { if (channelLocation.getChannelNodeID().equals(remoteID)) failedLinks.out().write(this); // asynchronously destroy to avoid deadlock } /** * This destroys this write end of the channel and frees any resources * in the JCSP.NET infrastructure. * */ public synchronized void destroyWriter() { if (channelIndex != IndexManager.getInvalidVCN()) IndexManager.getInstance().removeChannel(channelIndex, fromNetOut); broken = true; } /** * Requests that the channel recreates itself and reconnects to the * other end of the channel. * * This method will call refresh() on the * NetChannelLocation it holds for its destination. * If the instance held is an instance of a sub-class of * NetChannelLocation then this provides an oportunity * for the instance to refresh its information. This could, for example, * be from a naming service. * */ public void recreate() { connected = false; channelID = null; numUnacknowledged = 0; broken = false; this.channelLocation.refresh(); } /** * Requests that the channel recreates itself and reconnects to the * other end of the channel. A new location of the read end can be * supplied. * * @param newLoc the new location of the read end of the channel. */ public void recreate(NetChannelLocation newLoc) { connected = false; channelID = null; numUnacknowledged = 0; broken = false; this.channelLocation = newLoc; } public Class getFactoryClass() { return StandardNetChannelEndFactory.class; } /** * Currently, network channels are unpoisonable so this method has no effect. */ public void poison(int strength) { } /***********Private Methods***************************************************/ /** * Handles deserialization. This is responsible for starting up the * process which handles output, and for creating the internal channel. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { // read non-transient fields. stream.defaultReadObject(); connected = false; broken = false; // Sanity check. if (maxUnacknowledged < 0) throw new InvalidObjectException("One2NetChannel: maxUnacknowledged < 0"); if (acknowledged) { IndexManager.ChannelAndIndex chanAndIndex = IndexManager.getInstance().getNewReplyChannel(this); fromNetIn = chanAndIndex.channel.in(); fromNetOut = chanAndIndex.channel.out(); channelIndex = chanAndIndex.index; messageA = new ChannelMessage.Data(); messageB = new ChannelMessage.Data(); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/PingRequirement.java0000644000000000000000000000616611105701167017721 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.net.settings.*; /** * * @author Quickstone Technologies Limited. */ class PingRequirement extends Requirement { PingRequirement(int intValue, int acceptableDifference) { super(XMLConfigConstants.REQ_NAME_MAXPING, XMLConfigConstants.SPEC_NAME_PING, XMLConfigConstants.REQ_COMPARATOR_LESS, intValue); if(intValue < 0 || acceptableDifference < 0) throw new IllegalArgumentException("Illegal arguments - a value is less than zero."); this.acceptableDifference = acceptableDifference; } public boolean matches(Specification spec) { if(this.specName.equals(spec.name) && this.type.equals(spec.type)) { if(intValue > spec.intValue) //This object is greater than the other object - i.e. the other //object is less than this object return true; else if(spec.intValue - intValue <= acceptableDifference) //This object is less than the other object - i.e. the other //object is greater than this object return true; } return false; } final int acceptableDifference; }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetSharedConnectionClient.java0000644000000000000000000000453611105701167021636 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.SharedConnectionClient; /** * This interface should be implemented by classes that * wish to act as SharedConnectionClient * objects which accept connections from * ConnectionClient objects from over a JCSP.NET * network. * * @author Quickstone Technologies Limited */ public interface NetSharedConnectionClient extends Networked, SharedConnectionClient { }jcsp-1.1-rc4.orig/src/org/jcsp/net/DuplicateChannelLabelException.java0000644000000000000000000000500011105701167022607 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * This Exception is thrown if there is an attempt to label * a channel's VCN with a label that already exists at the * same Node. * * @author Quickstone Technologies Limited */ public class DuplicateChannelLabelException extends RuntimeException { /** * Constructor for DuplicateChannelLabelException. */ DuplicateChannelLabelException() { super(); } /** * Constructor for DuplicateChannelLabelException. * @param message */ DuplicateChannelLabelException(String message) { super(message); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/XMLNodeFactory.java0000644000000000000000000006075211105701167017402 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.net.*; import java.io.*; import java.util.*; import java.lang.reflect.*; import org.jcsp.net.settings.*; /** *

* Factory for node instantiation based on an XML-like file. *

*

* The factory uses its own XML parser that supports a sub-set of * XML. The current implementation will parse a file compatible * with jcsp-config.dtd. The parser does not current test conformance * to this DTD. It does not currently support XML comments. *

*

* An example of using this class can be seen in * {@link org.jcsp.net.cns.CNS}. *

* * @author Quickstone Technologies Limited */ public class XMLNodeFactory implements NodeFactory { private final JCSPConfig config; /** * Constructs an XMLNodeFactory that uses the * specified file. * * @param filename the file name of the config file to use. */ public XMLNodeFactory(String filename) throws IOException { this(new File(filename)); } /** * Constructs an XMLNodeFactory that uses the * specified file. * * @param xmlFile a File object pointing to the * XML file to use. * */ public XMLNodeFactory(File xmlFile) throws IOException { config = new ConfigReader(new FileInputStream(xmlFile)).getConfig(); } /** * Constructs an XMLNodeFactory that uses the * specified file. * * @param xmlFile a URL object pointing to the * XML file to use. */ public XMLNodeFactory(URL xmlFile) throws IOException { config = new ConfigReader(xmlFile.openStream()).getConfig(); } /** * This is called by the Node class. * * @param node the Node object calling the method. * @param attribs the attributes that need to be set by the method. * @throws NodeInitFailedException if initialization failed. */ public NodeKey initNode(Node node, Node.Attributes attribs) throws NodeInitFailedException { //setup the plugins - only UIFactory at the moment Plugins plugins = config.getPlugins(); Plugin uiFactPlugin = plugins.getPlugin("UIFactory"); if (uiFactPlugin != null) { try { Class uiFactoryClass = uiFactPlugin.getPluginClass(); attribs.setUIFactory((UIFactory) uiFactoryClass.newInstance()); } catch (Exception e) { Node.err.log(this, "Error trying to load UIFactory: " + uiFactPlugin.getName()); throw attribs.exception("Error trying to load UIFactory: " + uiFactPlugin.getName()); } } else attribs.setUIFactory(new UIFactory()); //Setup protocols Hashtable protocolIDMap = new Hashtable(); Protocol[] protocols = config.getProtocols().getProtocols(); for (int i = 0; i < protocols.length; i++) { if (protocols[i] != null) { Protocol p = protocols[i]; try { //Get the protocol id Class idClass = p.getIDClass(); ProtocolID pID = (ProtocolID) idClass.newInstance(); //set the order of preference of this protocol pID.setPosition(p.getPosition()); //get any settings that are needed Setting[] settingsFromConfig = p.getSettings(); Hashtable settings = new Hashtable(); for (int j = 0; j < settingsFromConfig.length; j++) settings.put(settingsFromConfig[j].getName(), settingsFromConfig[j].getValue()); //Setup specs Spec[] specs = p.getSpecs(); Specification[] specifications = new Specification[specs.length + 2]; //Have an extra specification for protocolID specifications[specifications.length - 1] = new Specification(XMLConfigConstants.SPEC_NAME_PROTOCOL,idClass.toString()); specifications[specifications.length - 2] = new Specification(XMLConfigConstants.SPEC_NAME_PING, 0); for (int j = 0; j < specs.length; j++) { int intVal = -1; double dblValue = -1; boolean booValue = false; String strValue = ""; Class type = null; if (specs[j] instanceof OtherSpec) { OtherSpec otherSpec = (OtherSpec) specs[j]; type = otherSpec.getType(); if (type.equals(String.class)) strValue = otherSpec.getStringValue(); else if (type.equals(Integer.TYPE)) intVal = otherSpec.getIntValue(); else if (type.equals(Double.TYPE)) dblValue = otherSpec.getDoubleValue(); else if (type.equals(Boolean.TYPE)) booValue = otherSpec.getBooleanValue(); } else { Class specClass = specs[j].getClass(); try { Method valueMethod = specClass.getMethod("getValue", null); type = valueMethod.getReturnType(); Object returned = valueMethod.invoke(specs[j], new Object[0]); if (type.equals(String.class)) strValue = (String) returned; else if (type.equals(Integer.TYPE)) intVal = ((Integer) returned).intValue(); else if (type.equals(Double.TYPE)) dblValue = ((Double) returned).doubleValue(); else if (type.equals(Boolean.TYPE)) booValue = ((Boolean) returned).booleanValue(); else throw attribs.exception("Specification's value is of an unsupported type: " + type); } catch (NoSuchMethodException e) { Node.err.log(this, "Spec does not have a getValue() method."); throw attribs.exception("Cannot load protcol specification: " + specs[j].getName()); } catch (IllegalAccessException e) { throw attribs.exception("Unable to access specification's value: " + specs[j].getName()); } catch (InvocationTargetException e) { throw attribs.exception("An exception was thrown while trying to access specification's value: " + e.getTargetException()); } } if (type.equals(String.class)) specifications[j] = new Specification(specs[j].getName(), strValue); else if (type.equals(Integer.TYPE)) specifications[j] = new Specification(specs[j].getName(), intVal); else if (type.equals(Double.TYPE)) specifications[j] = new Specification(specs[j].getName(), dblValue); else if (type.equals(Boolean.TYPE)) specifications[j] = new Specification(specs[j].getName(), booValue); } //install the protocol attribs.getProtocolManager().installProtocolClient(pID, specifications, settings); protocolIDMap.put(p.getProtocolID(), pID); } catch (Exception e) { throw attribs.exception("Unable to instantiate protocol: " + p.getName() + "\n" + e.getMessage()); } } else { Node.err.log(this, "Null protocol specified."); throw attribs.exception("Null protocol specified."); } } //Setup local addresses Address[] addresses = config.getAddresses().getAddresses(); for (int i = 0; i < addresses.length; i++) { if (addresses[i] != null) { Address a = addresses[i]; String xmlProtocolID = a.getProtocolID(); ProtocolID pID = (ProtocolID) protocolIDMap.get(xmlProtocolID); if (pID != null) { NodeAddressID add; try { add = pID.createAddressID(a.getValue(), a.isUnique()); } catch (IllegalArgumentException e) { throw attribs.exception("Address specified in invalid format: " + a.getValue()); } //Setup specs Spec[] specs = a.getSpecs(); Specification[] specifications = new Specification[specs.length]; for (int j = 0; j < specs.length; j++) { int intVal = -1; double dblValue = -1; boolean booValue = false; String strValue = ""; Class type = null; if (specs[j] instanceof OtherSpec) { OtherSpec otherSpec = (OtherSpec) specs[j]; type = otherSpec.getType(); if (type.equals(String.class)) strValue = otherSpec.getStringValue(); else if (type.equals(Integer.TYPE)) intVal = otherSpec.getIntValue(); else if (type.equals(Double.TYPE)) dblValue = otherSpec.getDoubleValue(); else if (type.equals(Boolean.TYPE)) booValue = otherSpec.getBooleanValue(); } else { Class specClass = specs[j].getClass(); try { Method valueMethod = specClass.getMethod("getValue", null); type = valueMethod.getReturnType(); Object returned = valueMethod.invoke(specs[j], new Object[0]); if (type.equals(String.class)) strValue = (String) returned; else if (type.equals(Integer.TYPE)) intVal = ((Integer) returned).intValue(); else if (type.equals(Double.TYPE)) dblValue = ((Double) returned).doubleValue(); else if (type.equals(Boolean.TYPE)) booValue = ((Boolean) returned).booleanValue(); else throw attribs.exception("Specification's value is of an unsupported type: " + type); } catch (NoSuchMethodException e) { Node.err.log(this, "Spec does not have a getValue() method."); throw attribs.exception("Cannot load protcol specification: " + specs[j].getName()); } catch (IllegalAccessException e) { throw attribs.exception("Unable to access specification's value: " + specs[j].getName()); } catch (InvocationTargetException e) { throw attribs.exception("An exception was thrown while trying to access specification's value: " + e.getTargetException()); } } if (type.equals(String.class)) specifications[j] = new Specification(specs[j].getName(), strValue); else if (type.equals(Integer.TYPE)) specifications[j] = new Specification(specs[j].getName(), intVal); else if (type.equals(Double.TYPE)) specifications[j] = new Specification(specs[j].getName(), dblValue); else if (type.equals(Boolean.TYPE)) specifications[j] = new Specification(specs[j].getName(), booValue); } attribs.getProtocolManager().installProtocolServer(add, specifications); } else throw attribs.exception("Unable to set address " + a.getValue() + ", " + "unknown protocol specified."); } else { Node.err.log(this, "Null address specified."); throw attribs.exception("Null address specified."); } } //Setup Node specifications Spec[] nodeSpecs = config.getNodeSpecs().getSpecs(); Specification[] specifications = new Specification[nodeSpecs.length]; for (int j = 0; j < nodeSpecs.length; j++) { int intVal = -1; double dblValue = -1; boolean booValue = false; String strValue = ""; Class type = null; if (nodeSpecs[j] instanceof OtherSpec) { OtherSpec otherSpec = (OtherSpec) nodeSpecs[j]; type = otherSpec.getType(); if (type.equals(String.class)) strValue = otherSpec.getStringValue(); else if (type.equals(Integer.TYPE)) intVal = otherSpec.getIntValue(); else if (type.equals(Double.TYPE)) dblValue = otherSpec.getDoubleValue(); else if (type.equals(Boolean.TYPE)) booValue = otherSpec.getBooleanValue(); } else { Class specClass = nodeSpecs[j].getClass(); try { Method valueMethod = specClass.getMethod("getValue", null); type = valueMethod.getReturnType(); Object returned = valueMethod.invoke(nodeSpecs[j], new Object[0]); if (type.equals(String.class)) strValue = (String) returned; else if (type.equals(Integer.TYPE)) intVal = ((Integer) returned).intValue(); else if (type.equals(Double.TYPE)) dblValue = ((Double) returned).doubleValue(); else if (type.equals(Boolean.TYPE)) booValue = ((Boolean) returned).booleanValue(); else throw attribs.exception("Specification's value is of an unsupported type: " + type); } catch (NoSuchMethodException e) { Node.err.log(this, "Spec does not have a getValue() method."); throw attribs.exception("Cannot load protcol specification: " + nodeSpecs[j].getName()); } catch (IllegalAccessException e) { throw attribs.exception("Unable to access specification's value: " + nodeSpecs[j].getName()); } catch (InvocationTargetException e) { throw attribs.exception("An exception was thrown while trying to access specification's value: " + e.getTargetException()); } } if (type.equals(String.class)) specifications[j] = new Specification(nodeSpecs[j].getName(), strValue); else if (type.equals(Integer.TYPE)) specifications[j] = new Specification(nodeSpecs[j].getName(), intVal); else if (type.equals(Double.TYPE)) specifications[j] = new Specification(nodeSpecs[j].getName(), dblValue); else if (type.equals(Boolean.TYPE)) specifications[j] = new Specification(nodeSpecs[j].getName(), booValue); } attribs.setSpecifications(specifications); //Setup profiles LinkProfile[] linkProfiles = config.getLinkProfiles().getProfiles(); for (int i = 0; i < linkProfiles.length; i++) { //Setup reqs Req[] reqs = linkProfiles[i].getReqs(); Requirement[] requirements = new Requirement[reqs.length]; for (int j = 0; j < reqs.length; j++) { String matchingSpecName = reqs[j].getName(); String value = null; if (matchingSpecName.equals(XMLConfigConstants.REQ_NAME_MINSPEED)) matchingSpecName = XMLConfigConstants.SPEC_NAME_MAXSPEED; else if (matchingSpecName.equals(XMLConfigConstants.REQ_NAME_PROTOCOL)) { matchingSpecName = XMLConfigConstants.SPEC_NAME_PROTOCOL; value = protocolIDMap.get(reqs[j].getStringValue()).getClass().toString(); } else if (matchingSpecName.equals(XMLConfigConstants.REQ_NAME_MAXPING)) matchingSpecName = XMLConfigConstants.SPEC_NAME_PING; if (reqs[j] instanceof MaxPing) requirements[j] = new PingRequirement(reqs[j].getIntValue(), 50); else if (reqs[j].getType().equals(String.class)) { if (value == null) value = reqs[j].getStringValue(); requirements[j] = new Requirement(reqs[j].getName(), matchingSpecName, reqs[j].getComparator(), value); } else if (reqs[j].getType().equals(Integer.TYPE)) requirements[j] = new Requirement(reqs[j].getName(), matchingSpecName, reqs[j].getComparator(), reqs[j].getIntValue()); else if (reqs[j].getType().equals(Double.TYPE)) requirements[j] = new Requirement(reqs[j].getName(), matchingSpecName, reqs[j].getComparator(), reqs[j].getDoubleValue()); else if (reqs[j].getType().equals(Boolean.TYPE)) requirements[j] = new Requirement(reqs[j].getName(), matchingSpecName, reqs[j].getComparator(), reqs[j].getBooleanValue()); } Profile.createNewLinkProfile(linkProfiles[i].getName(), requirements, linkProfiles[i].getExactMatchRequired()); } //Node Profiles NodeProfile[] nodeProfiles = config.getNodeProfiles().getProfiles(); for (int i = 0; i < nodeProfiles.length; i++) { //Setup reqs Req[] reqs = nodeProfiles[i].getReqs(); Requirement[] requirements = new Requirement[reqs.length]; for (int j = 0; j < reqs.length; j++) { String matchingSpecName = reqs[j].getName(); if (matchingSpecName.equals(XMLConfigConstants.REQ_NAME_MINSPEED)) matchingSpecName = XMLConfigConstants.SPEC_NAME_MAXSPEED; else if (matchingSpecName.equals(XMLConfigConstants.REQ_NAME_MINMEMORY)) matchingSpecName = XMLConfigConstants.SPEC_NAME_MEMORY; else if (matchingSpecName.equals(XMLConfigConstants.REQ_NAME_MAXPING)) matchingSpecName = XMLConfigConstants.SPEC_NAME_PING; if (reqs[j].getType().equals(String.class)) requirements[j] = new Requirement(reqs[j].getName(), matchingSpecName, reqs[j].getComparator(), reqs[j].getStringValue()); else if (reqs[j].getType().equals(Integer.TYPE)) requirements[j] = new Requirement(reqs[j].getName(), matchingSpecName, reqs[j].getComparator(), reqs[j].getIntValue()); else if (reqs[j].getType().equals(Double.TYPE)) requirements[j] = new Requirement(reqs[j].getName(), matchingSpecName, reqs[j].getComparator(), reqs[j].getDoubleValue()); else if (reqs[j].getType().equals(Boolean.TYPE)) requirements[j] = new Requirement(reqs[j].getName(), matchingSpecName, reqs[j].getComparator(), reqs[j].getBooleanValue()); } Profile.createNewNodeProfile(nodeProfiles[i].getName(), requirements, nodeProfiles[i].getExactMatchRequired()); } //start Link Manager LinkManager.getInstance().start(); attribs.setInitialized(); //Setup CNS ServiceManager sm = attribs.getServiceManager(); org.jcsp.net.settings.Service[] services = config.getServices().getServices(); //shouldn't be that many services so just loop through array each time int servicePos = 0; for (int i = 0; i < services.length; i++) { int actualPos = -1; for (int j = 0; j < services.length && actualPos < 0; j++) if (services[j].getPosition() == servicePos) actualPos = j; ServiceSettings serviceSettings = new ServiceSettings(services[actualPos].getName()); //get the array of addresses for each setting name AddressSetting[] addressSettings = services[actualPos].getAddressSettings(); for (int j = 0; j < addressSettings.length; j++) { //loop through the alternate addresses for the setting name AddressSetting addrSetting = addressSettings[j]; while (addrSetting != null) { ProtocolID pID = (ProtocolID) protocolIDMap.get(addrSetting.getProtocolID()); NodeAddressID addID = pID.createAddressID(addrSetting.getValue(), false); //add the address to the ServiceSettings object serviceSettings.addAddress(addrSetting.getName(), addID); //get the next alternate address for the current name addrSetting = addrSetting.getAlternate(); } } Setting[] otherSettings = services[actualPos].getSettings(); for (int j = 0; j < otherSettings.length; j++) serviceSettings.addSetting(otherSettings[j].getName(), otherSettings[j].getValue()); if (sm.installService(serviceSettings, services[actualPos].getServiceClass())) //service has installed if (services[actualPos].getRun()) if (!sm.startService(services[actualPos].getName())) Node.info.log(this, "Service " + services[actualPos].getName() + " failed to start."); servicePos++; } return attribs.getNodeKey(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/ServiceInstallationException.java0000644000000000000000000000467511105701167022447 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * An excpetion that is thrown if a service installation fails. * * @author Quickstone Technologies Limited */ public class ServiceInstallationException extends RuntimeException { /** * Constructor for ServiceInstallationException. */ public ServiceInstallationException() { super(); } /** * Constructor for ServiceInstallationException. * @param message */ public ServiceInstallationException(String message) { super(message); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/SerializedMessage.java0000644000000000000000000000677311105701167020207 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** * * @author Quickstone Technologies Limited. */ class SerializedMessage extends Message implements Serializable { public SerializedMessage(Message msg) throws NotSerializableException, IOException { serializedObject = new SerializedObject(msg, false); destIndex = msg.destIndex; sourceIndex = msg.sourceIndex; } SerializedMessage(SerializedObject serializedObject, long destIndex, long sourceIndex) { this.serializedObject = serializedObject; this.destIndex = destIndex; this.sourceIndex = sourceIndex; } public byte[] getSerializedData() { return serializedObject.getSerializedData(); } /*--------------------------*/ public Object get() throws ClassNotFoundException, IOException { return get(null); } public Object get(SerializedObject.InputStreamFactory factory) throws ClassNotFoundException, IOException { Object o = null; if(factory == null) o = serializedObject.get(); else o = serializedObject.get(factory); if(o instanceof Message) { Message msg = (Message) o; msg.sourceID = sourceID; msg.txReplyChannel = txReplyChannel; } return o; } private SerializedObject serializedObject; private boolean isInternalClass; private static class AccesibleByteArrayOutputStream extends ByteArrayOutputStream { public byte[] getByteArray() { return buf; } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NodeAddressID.java0000644000000000000000000001650511105701167017211 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** *

* JCSP.NET communication protocol implementations must provide a concrete * implementation of this class. The instances of the class implementations * should hold address information for JCSP Node LinkServer * processes. For example, a TCP/IP implementation would most likely hold * an IP address and port number. *

*

* There is no defined way in this class as to how NodeAddressID * objects should be created. The JCSP infrastructure never looks at the * underlying address information, it simply needs to be able compare one address * with another. The equals(Object) should be implemented in such a * way that this can be achieved. *

*

* Implementations of the ProtocolID class should implement the * createAddressID(String, boolean) method so that * NodeAddressID objects for that protocol can be created from a * String. The boolean parameter indicates whether or * not the address is globally unique. *

* * @author Quickstone Technologies Limited */ public abstract class NodeAddressID implements Serializable, Cloneable { /** *

* Compares the instance of the class implementing this interface * with another object. This should return true if the other * object represents the same address. *

* @param obj another object that should be another NodeAddressID. * @return true if the other object is another NodeAddressID representing * the same address. */ public abstract boolean equals(Object obj); /** *

* Returns a hash code for this object. Two NodeAddressID objects * should return the same hash code if they equal as governed by the rules * for the equals(Object) method. *

* @return an int hash code. */ public abstract int hashCode(); /** *

* Returns a clone of the instance of the class implementing this interface. *

* @throws CloneNotSupportedException if the implementation * class does not support the clone method. * @return a clone of the object that this is being called on. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Returns the ProtocolID for the protocol that is * associated with this NodeAddressID. * @return this NodeAddressID object's ProtocolID. */ public abstract ProtocolID getProtocolID(); /** *

* Returns true if this NodeAddressID is known to be * unique within the global org.jcsp.net domain. *

*

* A Node may have several addresses. If a Node is on an internal network that * is connected to the Internet, it may have one local address and one address * that is accessible from the Internet. The Internet address may be globally * unique whereas the local address may be duplicated in other internal networks. * The NodeAddressID object representing the Internet address should * return true when this method is called whereas the * NodeAddressID representing the local address should return * false. *

* @return true iff this NodeAddressID is globally unique. */ public abstract boolean isGloballyUnique(); /** *

* Returns a String that contains all information necessary for * reconstucting this object from a String. The object is * reconstructed by calling the static getAddressIDFromString(String) * method. *

* @return a String that can be passed to the static getAddressIDFromString(String) * method in order to reconstuct the object. * @deprecated This is going to be removed from the API. * The purpose of this mechanism was so that channel * information could be encoded into anonymous channels' * channel names. */ protected abstract String getStringForm(); /** *

* This is is a static method that should be overriden by concrete implementations * of this class. Ideally this method would be abstract but the language does * not allow abstract static methods. *

*

* The method constructs a NodeAddressID object from a * String that is in the form of that returned by the * getStringForm() method. The object returned by this method * should equal the object that returned the String when its * getStringForm() methdo was called. *

* * @param stringForm the String used to construct the NodeAddressID. * @throws IllegalArgumentException if the String supplied is invalid. * @return a newly constructed NodeAddressID object. */ protected static NodeAddressID getAddressIDFromString(String stringForm) throws IllegalArgumentException { //have made this protected 17/04/2002 - not sure why it wasn't. return null; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetConnectionServer.java0000644000000000000000000000457611105701167020543 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.ConnectionServer; /** * This interface should be implemented by classes that wish to act * as Networked ConnectionServer objects. * * @author Quickstone Technologies Limited */ public interface NetConnectionServer extends ConnectionServer, Networked { /** * Destroys the server and frees any resources used * within the JCSP.NET infrastructure. * */ public void destroyServer(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetSharedChannelInput.java0000644000000000000000000000443211105701167020763 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.SharedChannelInput; /** * This interface should be implemented by classes that * wish to act as NetChannelInput objects * which can be used by muliple concurrent processes. * * @author Quickstone Technologies Limited */ public interface NetSharedChannelInput extends SharedChannelInput, NetChannelInput { }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetSharedAltingConnectionClient.java0000644000000000000000000001320111105701167022762 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; import org.jcsp.util.Buffer; /** *

* Defines a class whose instances should be * {@link org.jcsp.lang.SharedAltingConnectionClient} * that connect to a ConnectionServer over a JCSP.NET * network. *

*

* Individual instances may not be used by multiple processes but * duplicate clients can be obtained by invoking * {@link #duplicate()}. These duplicates work over the * same connection and each one may be used by a different process. *

* * @author Quickstone Technologies Limited */ public class NetSharedAltingConnectionClient extends SharedAltingConnectionClient implements NetSharedConnectionClient { static NetSharedAltingConnectionClient create(NetChannelLocation serverLoc) { Any2OneChannel synchChan = Channel.any2one(new Buffer(1)); NetChannelOutput openToServer = NetChannelEnd.createOne2Net(serverLoc); NetChannelOutput reqToServer = NetChannelEnd.createOne2Net(serverLoc); NetAltingChannelInput fromServer = NetChannelEnd.createNet2One(new Buffer(1)); NetChannelOutput replyToClient = NetChannelEnd.createOne2Net(fromServer.getChannelLocation()); return new NetSharedAltingConnectionClient(synchChan, fromServer, openToServer, reqToServer, replyToClient); } private Any2OneChannel synchChan; private NetAltingChannelInput fromServer; private NetChannelOutput openToServer; private NetChannelOutput reqToServer; private NetChannelOutput backToClient; private NetConnectionLocation serverLocation; /** *

* Constructor for NetSharedAltingConnectionClient. *

* * @param fromServer * @param synchIn * @param toServer * @param synchOut * @param backToClient * @param parent */ protected NetSharedAltingConnectionClient( Any2OneChannel synchChan, NetAltingChannelInput fromServer, NetChannelOutput openToServer, NetChannelOutput reqToServer, NetChannelOutput backToClient) { super(fromServer, synchChan.in(), openToServer, reqToServer, synchChan.out(), backToClient, null); this.synchChan = synchChan; this.fromServer = fromServer; this.openToServer = openToServer; this.reqToServer = reqToServer; this.backToClient = backToClient; this.serverLocation = new NetConnectionLocation(openToServer.getChannelLocation(), reqToServer.getChannelLocation()); } /** * Returns the address location of the connection server. * * @return the NetChannelLocation object. * * @see org.jcsp.net.Networked#getChannelLocation() */ public NetChannelLocation getChannelLocation() { return this.serverLocation; } /** *

* Produces a duplicate * NetSharedAltingConnectionClient object which * may be used by another process. *

* @return a new duplicate SharedConnectionClient * object. */ public SharedConnectionClient duplicate() { return new NetSharedAltingConnectionClient(synchChan, fromServer, openToServer, reqToServer, backToClient); } /** *

* Destroys this networked client object. *

*

* This frees any resources used within the JCSP.NET * infrastructure. *

* */ public void destroyClient() { synchChan.out().write(null); fromServer.destroyReader(); synchChan.in().read(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/0000755000000000000000000000000011410045046015563 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Settings.java0000644000000000000000000000743111105701167020237 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; /** * Used internally within the JCSP network infrastructure to represent a set of system settings. * * @author Quickstone Technologies Limited */ public class Settings { public Settings() { name = "Settings"; } public Settings(String name) { this.name = name; } public void addSetting(Setting s) { if(s != null) { if(!settings.contains(s) && !settingNameMap.containsKey(s.getName())) { settings.put(s, s); settingNameMap.put(s.getName(), s); } } else throw new SettingAlreadyExistsException("Already have a setting named " + s.getName()); } public void removeSetting(Setting s) { if(settings.contains(s)) { settings.remove(s); settingNameMap.remove(s.getName()); } } public Setting getSetting(String name) { return (Setting) settingNameMap.get(name); } public Setting[] getSettings() { Setting[] toReturn = new Setting[settings.size()]; return (Setting[])settings.keySet().toArray(toReturn); } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("<" + this.name + ">\n"); Setting[] settings = getSettings(); for(int i=0; i"); return sb.toString(); } private Hashtable settings = new Hashtable(); private Hashtable settingNameMap = new Hashtable(); String name; static class SettingAlreadyExistsException extends RuntimeException { private SettingAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Protocol.java0000644000000000000000000001051211105701167020232 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a single protocol. * * @author Quickstone Technologies Limited */ public class Protocol { public Protocol(String protocolID, String protocolName, Class idClass, int position) { this.protocolID = protocolID; this.protocolName = protocolName; this.idClass = idClass; this.position = position; } public void addSpec(Spec spec) { specs.addSpec(spec); } public void removeSpec(Spec spec) { specs.removeSpec(spec); } public Spec[] getSpecs() { return specs.getSpecs(); } public void addSetting(Setting setting) { settings.addSetting(setting); } public void removeSetting(Setting setting) { settings.removeSetting(setting); } public Setting[] getSettings() { return settings.getSettings(); } public Setting getSetting(String name) { return settings.getSetting(name); } public String getProtocolID() { return protocolID; } public String getName() { return protocolName; } public Class getIDClass() { return idClass; } public int getPosition() { return position; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n"); sb.append(JCSPConfig.tabIn(settings.toString())).append("\n"); sb.append(JCSPConfig.tabIn(specs.toString())).append("\n"); sb.append(""); return sb.toString(); } public boolean equals(Object o) { if(o instanceof Protocol) { Protocol other = (Protocol) o; return protocolID.equals(other.protocolID) && protocolName.equals(other.protocolName) && idClass.equals(other.idClass) && specs.equals(other.specs); } return false; } public int hashCode() { return protocolName.hashCode(); } private String protocolID; private String protocolName; private Class idClass; private int position; private Specs specs = new Specs(); private Settings settings = new Settings(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Service.java0000644000000000000000000001126611105701167020040 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a service. * * @author Quickstone Technologies Limited */ public class Service { public Service(String name, Class serviceClass, boolean run, int position) { this.name = name; this.serviceClass = serviceClass; this.run = run; this.position = position; } public void addSetting(Setting setting) { settings.addSetting(setting); } public void removeSetting(Setting setting) { settings.removeSetting(setting); } public Setting[] getSettings() { return settings.getSettings(); } public Setting getSetting(String name) { return settings.getSetting(name); } public void addAddressSetting(AddressSetting setting) { addressSettings.addSetting(setting); } public void removeAddressSetting(AddressSetting setting) { addressSettings.removeSetting(setting); } public AddressSetting[] getAddressSettings() { Setting[] settings = addressSettings.getSettings(); AddressSetting[] toReturn = new AddressSetting[settings.length]; for(int i=0; i\n"); sb.append(JCSPConfig.tabIn(settings.toString())).append("\n"); sb.append(JCSPConfig.tabIn(addressSettings.toString())).append("\n"); sb.append(""); return sb.toString(); } public boolean equals(Object o) { if(o instanceof Service) { Service other = (Service) o; return name.equals(other.name) && run == other.run && settings.equals(other.settings) && addressSettings.equals(other.addressSettings); } return false; } public int hashCode() { return name.hashCode(); } private String name; private Class serviceClass; private boolean run; private int position; private Settings settings = new Settings(); private Settings addressSettings = new Settings("AddressSettings"); }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/LinkProfile.java0000644000000000000000000001633011105701167020653 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; /** * Used internally within the JCSP network infrastructure to represent a single link profile. * * @author Quickstone Technologies Limited */ public class LinkProfile { public LinkProfile(String name, boolean exactMatchRequired) { this.name = name; this.exactMatchRequired = exactMatchRequired; } public void addReq(Req req) { if(req instanceof MinSpeed && minSpeed == null) minSpeed = (MinSpeed) req; else if(req instanceof Wireless && wireless == null) { } else if(req instanceof ReqProtocol && reqProtocol == null) reqProtocol = (ReqProtocol) req; else if(req instanceof Reliable && reliable == null) reliable = (Reliable) req; else if(req instanceof ConnectionOriented && connectionOriented == null) connectionOriented = (ConnectionOriented) req; else if(req instanceof MaxPing && maxPing == null) maxPing = (MaxPing) req; else if(req instanceof OtherReq && !reqs.contains(req)) reqs.put(req, req); else throw new ReqAlreadyExistsException("Already have a req named " + req.getName()); } public void removeReq(Req req) { if(minSpeed == req) minSpeed = null; else if(reqProtocol == req) reqProtocol = null; else if(wireless == req) wireless = null; else if(reliable == req) reliable = null; else if(connectionOriented == req) connectionOriented = null; else if(maxPing == req) maxPing = null; else if(req instanceof OtherReq && reqs.contains(req)) reqs.remove(req); } public Req[] getReqs() { int count=0; if (minSpeed != null) count++; if (reqProtocol != null) count++; if (wireless != null) count++; if (reliable != null) count++; if (maxPing != null) count++; if (connectionOriented != null) count++; count += reqs.size(); Req[] toReturn = new Req[count]; int pos = 0; if(minSpeed != null) { toReturn[pos] = minSpeed; pos++; } if(reqProtocol != null) { toReturn[pos] = reqProtocol; pos++; } if(wireless != null) { toReturn[pos] = wireless; pos++; } if(reliable != null) { toReturn[pos] = reliable; pos++; } if(connectionOriented != null) { toReturn[pos] = connectionOriented; pos++; } if(maxPing != null) { toReturn[pos] = maxPing; pos++; } for (Enumeration it = reqs.keys(); it.hasMoreElements(); ) { toReturn[pos] = (Req) it.nextElement(); pos++; } return toReturn; } public String getName() { return name; } public boolean getExactMatchRequired() { return exactMatchRequired; } public boolean equals(Object o) { if(o!= null && o instanceof LinkProfile) { LinkProfile other = (LinkProfile) o; if((minSpeed == other.minSpeed || (minSpeed != null && minSpeed.equals(other.minSpeed))) && (reqProtocol == other.reqProtocol || (reqProtocol != null && reqProtocol.equals(other.reqProtocol))) && (wireless == other.wireless || (wireless != null && wireless.equals(other.wireless))) && (reliable == other.reliable || (reliable != null && reliable.equals(other.reliable))) && (connectionOriented == other.connectionOriented || (connectionOriented != null && connectionOriented.equals(other.connectionOriented))) && (maxPing == other.maxPing || (maxPing != null && maxPing.equals(other.maxPing))) && reqs.equals(other.reqs)) { return true; } } return false; } public String toString() { StringBuffer sb = new StringBuffer(); Req[] reqs = getReqs(); sb.append("\n"); if(reqs.length > 0) sb.append(JCSPConfig.tabIn("")).append("\n"); for(int i=0; i 0) sb.append(JCSPConfig.tabIn("")).append("\n"); sb.append(""); return sb.toString(); } public int hashCode() { return reqs.hashCode(); } private MinSpeed minSpeed = null; private ReqProtocol reqProtocol = null; private Wireless wireless = null; private Reliable reliable = null; private ConnectionOriented connectionOriented = null; private MaxPing maxPing = null; private Hashtable reqs = new Hashtable(); private String name; private boolean exactMatchRequired; static class ReqAlreadyExistsException extends RuntimeException { private ReqAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/MinMemory.java0000644000000000000000000000630011105701167020345 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a minimum memory setting. * * @author Quickstone Technologies Limited */ public class MinMemory extends Spec implements Req, XMLConfigConstants { MinMemory(int minMemory) { super(REQ_NAME_MINMEMORY, true); this.minMemory = minMemory - 1; } public String getStringValue() { return "" + minMemory; } public String getComparator() { return REQ_COMPARATOR_GREATER; } public int getIntValue() { return getValue(); } public double getDoubleValue() { throw new UnsupportedOperationException("Type is int"); } public boolean getBooleanValue() { throw new UnsupportedOperationException("Type is int"); } public Class getType() { return Integer.TYPE; } public int getValue() { return minMemory; } public boolean equals(Object o) { if(o instanceof MinMemory) { MinMemory other = (MinMemory) o; return minMemory == other.minMemory; } return false; } public int hashCode() { return minMemory; } private int minMemory; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/LinkProfiles.java0000644000000000000000000000763411105701167021045 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; import org.jcsp.net.*; /** * Used internally within the JCSP network infrastructure to represent a set of link profiles. * * @author Quickstone Technologies Limited */ public class LinkProfiles { public void addProfile(LinkProfile p) { if(p != null) { if(!profiles.contains(p) && !profileNameMap.containsKey(p.getName())) { profiles.put(p, p); profileNameMap.put(p.getName(), p); lastProfile = p; } else throw new LinkProfileAlreadyExistsException("Already have a profile named " + p.getName()); } else Node.err.log(this, "Error: Null profile"); } public void removeProfile(LinkProfile p) { if(profiles.contains(p)) { profiles.remove(p); profileNameMap.remove(p.getName()); } } public LinkProfile getProfile(String name) { return (LinkProfile) profileNameMap.get(name); } public LinkProfile[] getProfiles() { LinkProfile[] toReturn = new LinkProfile[profiles.size()]; return (LinkProfile[])profiles.keySet().toArray(toReturn); } public LinkProfile getLastProfile() { return lastProfile; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n"); LinkProfile[] profiles = getProfiles(); for(int i=0; i"); return sb.toString(); } private Hashtable profiles = new Hashtable(); private Hashtable profileNameMap = new Hashtable(); private LinkProfile lastProfile = null; static class LinkProfileAlreadyExistsException extends RuntimeException { private LinkProfileAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/OtherReq.java0000644000000000000000000000752111105701167020170 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent miscellaneous requirements. * * @author Quickstone Technologies Limited */ class OtherReq extends OtherSpec implements Req { OtherReq(String name, int value, String comparator) { super(name, value, true); this.comparator = comparator; } OtherReq(String name, double value, String comparator) { super(name, value, true); this.comparator = comparator; } OtherReq(String name, boolean value, String comparator) { super(name, value, true); this.comparator = comparator; } OtherReq(String name, String value, String comparator) { super(name, value, true); this.comparator = comparator; } public String getComparator() { return comparator; } public boolean equals(Object o) { if(o instanceof OtherReq) { OtherReq other = (OtherReq) o; if (getName().equals(other.getName()) && getType().equals(other.getType()) && comparator.equals(other.comparator)) { if (getType().equals(Integer.TYPE)) return getIntValue() == other.getIntValue(); else if (getType().equals(Double.TYPE)) return getDoubleValue() == other.getDoubleValue(); else if (getType().equals(Boolean.TYPE)) return getBooleanValue() == other.getBooleanValue(); else if (getType().equals(String.class)) return getStringValue() == other.getStringValue(); } } return false; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append(""); return sb.toString(); } private String comparator; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Plugin.java0000644000000000000000000000567411105701167017704 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a plug-in. * * @author Quickstone Technologies Limited */ public class Plugin { public Plugin(String name, Class pluginClass) { this.name = name; this.pluginClass = pluginClass; } public String getName() { return name; } public Class getPluginClass() { return pluginClass; } public boolean equals(Object o) { if(o instanceof Plugin) { Plugin other = (Plugin) o; return name.equals(other.name) && pluginClass.equals(other.pluginClass); } return false; } public int hashCode() { return name.hashCode(); } public String toString() { StringBuffer sb = new StringBuffer(); sb.append(""); return sb.toString(); } private String name; private Class pluginClass; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Plugins.java0000644000000000000000000000725311105701167020062 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; /** * Used internally within the JCSP network infrastructure to represent a set of plug-ins. * * @author Quickstone Technologies Limited */ public class Plugins { public void addPlugin(Plugin p) { if(p != null) { if(!plugins.contains(p) && !pluginNameMap.containsKey(p.getName())) { plugins.put(p, p); pluginNameMap.put(p.getName(), p); } } else throw new PluginAlreadyExistsException("Already have a plugin named " + p.getName()); } public void removePlugin(Plugin p) { if(plugins.contains(p)) { plugins.remove(p); pluginNameMap.remove(p.getName()); } } public Plugin getPlugin(String pluginName) { return (Plugin) pluginNameMap.get(pluginName); } public Plugin[] getPlugins() { Plugin[] toReturn = new Plugin[plugins.size()]; int i = 0; for (Enumeration e = plugins.keys(); e.hasMoreElements(); ) toReturn[i++] = (Plugin)e.nextElement(); return toReturn; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n"); Plugin[] plugins = getPlugins(); for (int i=0; i"); return sb.toString(); } private Hashtable plugins = new Hashtable(); private Hashtable pluginNameMap = new Hashtable(); static class PluginAlreadyExistsException extends RuntimeException { private PluginAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/ConfigReader.java0000644000000000000000000010332611105701167020767 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.io.*; /** *

Used internally by the JCSP network infrastructure to load a configuration from an XML file.

* *

This is not a full XML reader, and is capable of reading only a subset of XML.

* * @author Quickstone Technologies Limited */ public class ConfigReader implements XMLConfigConstants { /** * Diagnostic routine. This can load an XML configuration file and then display the configuration * structure constructed. Specify the name of the file as the first command line parameter. */ static public void main(String[] args) { // Parse arguments if (args.length != 1) System.err.println("Usage: XMLReader "); else { String filename = args[0]; try { ConfigReader cr = new ConfigReader(new FileInputStream(filename)); JCSPConfig config = cr.getConfig(); System.out.println(config); } catch (Exception e) { System.err.println("Error while reading config."); e.printStackTrace(); } } } /** The config built up. */ private JCSPConfig config = new JCSPConfig(); /** * Constructs a new configuration from the given source stream. This will attempt to parse the file * using recursive-descent approach. * * @param instream source of the XML configuration. * @throws IOException if there is a problem with the stream or the file is improperly formatted. * @throws XMLValidationException if there is a symantic problem with the configuration. */ public ConfigReader(InputStream instream) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(instream)); Tag t; while ((t = nextTag(in)) != null) { if (t.name.equals("JCSP-CONFIG")) { doJCSP_Config(in); continue; } if (t.name.equals("?xml")) continue; t.bad(); } } private void do_template(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ""))) // put clauses here t.bad(); } private void doJCSP_Config(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/JCSP-CONFIG"))) { if (t.name.equals(ELEMENT_SETTINGS)) { if (!t.terminated) doSettings(in); continue; } if (t.name.equals(ELEMENT_SERVICES)) { if (!t.terminated) doServices(in); continue; } if (t.name.equals(ELEMENT_PLUGINS)) { if (!t.terminated) doPlugins(in); continue; } if (t.name.equals(ELEMENT_PROTOCOLS)) { if (!t.terminated) doProtocols(in); continue; } if (t.name.equals(ELEMENT_ADDRESSES)) { if (!t.terminated) doAddresses(in); continue; } if (t.name.equals(ELEMENT_NODE_SPECS)) { if (!t.terminated) doNodeSpecs(in); continue; } if (t.name.equals(ELEMENT_LINK_PROFILES)) { if (!t.terminated) doLinkProfiles(in); continue; } if (t.name.equals(ELEMENT_NODE_PROFILES)) { if (!t.terminated) doNodeProfiles(in); continue; } t.bad(); } } private void doSettings(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_SETTINGS))) { if (t.name.equals(ELEMENT_SETTING)) { String name = t.getAttrib("name"); String value = t.getAttrib("value"); Setting setting = config.getSettings().getSetting(name); if (setting == null) { setting = new Setting(name, value); config.getSettings().addSetting(setting); } else throw new XMLValidationException("Setting \"" + name + "\" already exists with value " + setting.getValue()); continue; } t.bad(); } } private int servicePos = 0; private int protocolPos = 0; private void doServices(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_SERVICES))) { if (t.name.equals(ELEMENT_SERVICE)) { String name = t.getAttrib("name"); String className = t.getAttrib("class"); boolean run = Tag.getBooleanValue(t.getAttrib("run")); try { Class serviceClass = Class.forName(className); config.getServices().addService(new Service(name, serviceClass, run, servicePos++)); } catch (ClassNotFoundException e) { throw new XMLValidationException("Unable to load class " + className); } if (!t.terminated) doService(in); continue; } t.bad(); } } private void doService(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_SERVICE))) { if (t.name.equals(ELEMENT_ADDRESS_SETTING)) { String name = t.getAttrib("name"); String value = t.getAttrib("value"); String pID = t.getAttrib("protocolid"); Service current = config.getServices().getLastService(); AddressSetting addrSetting = (AddressSetting) current.getAddressSetting(name); if (addrSetting == null) { addrSetting = new AddressSetting(name, value, pID); current.addAddressSetting(addrSetting); } else addrSetting.addAlternate(new AddressSetting(name, value, pID)); continue; } if (t.name.equals(ELEMENT_SETTING)) { String name = t.getAttrib("name"); String value = t.getAttrib("value"); Setting setting = config.getServices().getLastService().getSetting(name); if (setting == null) { setting = new Setting(name, value); config.getServices().getLastService().addSetting(setting); } else throw new XMLValidationException("Setting \"" + name + "\" already exists with value " + setting.getValue()); continue; } t.bad(); } } private void doPlugins(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_PLUGINS))) { if (t.name.equals(ELEMENT_PLUGIN)) { String name = t.getAttrib("name"); String className = t.getAttrib("classname"); try { Class classToUse = Class.forName(className); Plugin plugin = new Plugin(name, classToUse); config.getPlugins().addPlugin(plugin); } catch (Exception e) { throw new XMLValidationException("Unable to load class " + className); } if (!t.terminated) doPlugin(in); continue; } t.bad(); } } private void doPlugin(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_PLUGIN))) // put clauses here t.bad(); } private void doProtocols(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_PROTOCOLS))) { if (t.name.equals(ELEMENT_PROTOCOL)) { String id = t.getAttrib("id"); String name = t.getAttrib("name"); String idClass = t.getAttrib("idclass"); try { Class classToUse = Class.forName(idClass); Protocol protocol = new Protocol(id, name, classToUse, protocolPos++); config.getProtocols().addProtocol(protocol); } catch (ClassNotFoundException e) { throw new XMLValidationException("Unable to load class " + idClass); } if (!t.terminated) doProtocol(in); continue; } t.bad(); } } private void doProtocol(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_PROTOCOL))) { if (t.name.equals(ELEMENT_SPECS)) { if (!t.terminated) doProtocolSpecs(in); continue; } if (t.name.equals(ELEMENT_PROTOCOL_SETTINGS)) { if (!t.terminated) doProtocolSettings(in); continue; } t.bad(); } } private void doProtocolSpecs(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_SPECS))) { if (t.name.equals(ELEMENT_MAXSPEED)) { int value = Tag.getIntValue(t.getAttrib("value")); MaxSpeed m = new MaxSpeed(value); Protocol p = config.getProtocols().getLastProtocol(); p.addSpec(m); continue; } if (t.name.equals(ELEMENT_WIRELESS)) { String value = t.getAttrib("value"); Wireless w = null; if (value.equals(XML_TRISTATE_TRUE)) w = new Wireless(1, false); else if (value.equals(XML_TRISTATE_FALSE)) w = new Wireless(-1, false); else if (value.equals(XML_TRISTATE_CANBE)) w = new Wireless(0, false); else //this validation should be done by the DTD throw new XMLValidationException("Invalid Wireless value " + "\"" + value + "\"" + "\nUse either \"" + XML_TRISTATE_TRUE + "\", \"" + XML_TRISTATE_FALSE + "\" or \"" + XML_TRISTATE_CANBE + "\"."); Protocol p = config.getProtocols().getLastProtocol(); p.addSpec(w); continue; } if (t.name.equals(ELEMENT_RELIABLE)) { boolean value = Tag.getBooleanValue(t.getAttrib("value")); Reliable r = new Reliable(value, false); Protocol p = config.getProtocols().getLastProtocol(); p.addSpec(r); continue; } if (t.name.equals(ELEMENT_CONNECTION_ORIENTED)) { boolean value = Tag.getBooleanValue(t.getAttrib("value")); ConnectionOriented co = new ConnectionOriented(value, false); Protocol p = config.getProtocols().getLastProtocol(); p.addSpec(co); continue; } if (t.name.equals(ELEMENT_OTHERSPEC)) { String name = t.getAttrib("name"); String value = t.getAttrib("value"); String type = t.getAttrib("type"); OtherSpec os = null; if (type.equals(DATA_TYPE_INDICATOR_INT)) { int intVal = Tag.getIntValue(value); os = new OtherSpec(name, intVal, false); } else if (type.equals(DATA_TYPE_INDICATOR_DOUBLE)) { double dblVal = Tag.getDoubleValue(value); os = new OtherSpec(name, dblVal, false); } else if (type.equals(DATA_TYPE_INDICATOR_STRING)) os = new OtherSpec(name, value, false); else if (type.equals(DATA_TYPE_INDICATOR_BOOLEAN)) { boolean booVal = Tag.getBooleanValue(value); os = new OtherSpec(name, booVal, false); } Protocol p = config.getProtocols().getLastProtocol(); p.addSpec(os); continue; } t.bad(); } } private void doProtocolSettings(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_PROTOCOL_SETTINGS))) { if (t.name.equals(ELEMENT_PROTOCOL_SETTING)) { Protocol p = config.getProtocols().getLastProtocol(); String name = t.getAttrib("name"); String value = t.getAttrib("value"); Setting setting = p.getSetting(name); if (setting == null) { setting = new Setting(name, value); p.addSetting(setting); } else throw new XMLValidationException("Protocol Setting \"" + name + "\" already exists with value " + setting.getValue()); continue; } t.bad(); } } private void doAddresses(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_ADDRESSES))) { if (t.name.equals(ELEMENT_ADDRESS)) { String protocolid = t.getAttrib("protocolid"); String value = t.getAttrib("value"); boolean unique = Tag.getBooleanValue(t.getAttrib("unique")); Address add = new Address(protocolid, value, unique); config.getAddresses().addAddress(add); if (!t.terminated) doAddress(in); continue; } t.bad(); } } private void doAddress(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_ADDRESS))) { if (t.name.equals(ELEMENT_SPECS)) { if (!t.terminated) doAddressSpecs(in); continue; } t.bad(); } } private void doAddressSpecs(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_SPECS))) { if (t.name.equals(ELEMENT_MAXSPEED)) { int value = Tag.getIntValue(t.getAttrib("value")); MaxSpeed m = new MaxSpeed(value); Address a = config.getAddresses().getLastAddress(); a.addSpec(m); continue; } if (t.name.equals(ELEMENT_WIRELESS)) { String value = t.getAttrib("value"); Wireless w = null; if (value.equals(XML_TRISTATE_TRUE)) w = new Wireless(1, false); else if (value.equals(XML_TRISTATE_FALSE)) w = new Wireless(-1, false); else if (value.equals(XML_TRISTATE_CANBE)) w = new Wireless(0, false); else //this validation should be done by the DTD throw new XMLValidationException("Invalid Wireless value \"" + value + "\"" + "\nUse either \"" + XML_TRISTATE_TRUE + "\", \"" + XML_TRISTATE_FALSE + "\" or \"" + XML_TRISTATE_CANBE + "\"."); Address a = config.getAddresses().getLastAddress(); a.addSpec(w); continue; } if (t.name.equals(ELEMENT_RELIABLE)) { boolean value = Tag.getBooleanValue(t.getAttrib("value")); Reliable r = new Reliable(value, false); Address a = config.getAddresses().getLastAddress(); a.addSpec(r); continue; } if (t.name.equals(ELEMENT_CONNECTION_ORIENTED)) { boolean value = Tag.getBooleanValue(t.getAttrib("value")); ConnectionOriented co = new ConnectionOriented(value, false); Address a = config.getAddresses().getLastAddress(); a.addSpec(co); continue; } if (t.name.equals(ELEMENT_OTHERSPEC)) { String name = t.getAttrib("name"); String value = t.getAttrib("value"); String type = t.getAttrib("type"); OtherSpec os = null; if (type.equals(DATA_TYPE_INDICATOR_INT)) { int intVal = Tag.getIntValue(value); os = new OtherSpec(name, intVal, false); } else if (type.equals(DATA_TYPE_INDICATOR_DOUBLE)) { double dblVal = Tag.getDoubleValue(value); os = new OtherSpec(name, dblVal, false); } else if (type.equals(DATA_TYPE_INDICATOR_STRING)) os = new OtherSpec(name, value, false); else if (type.equals(DATA_TYPE_INDICATOR_BOOLEAN)) { boolean booVal = Tag.getBooleanValue(value); os = new OtherSpec(name, booVal, false); } Address a = config.getAddresses().getLastAddress(); a.addSpec(os); continue; } t.bad(); } } private void doNodeSpecs(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_NODE_SPECS))) { if (t.name.equals(ELEMENT_MAXSPEED)) { int value = Tag.getIntValue(t.getAttrib("value")); MaxSpeed m = new MaxSpeed(value); config.getNodeSpecs().addSpec(m); continue; } if (t.name.equals(ELEMENT_MEMORY)) { int value = Tag.getIntValue(t.getAttrib("value")); Memory m = new Memory(value); config.getNodeSpecs().addSpec(m); continue; } if (t.name.equals(ELEMENT_OTHERSPEC)) { String name = t.getAttrib("name"); String value = t.getAttrib("value"); String type = t.getAttrib("type"); OtherSpec os = null; if (type.equals(DATA_TYPE_INDICATOR_INT)) { int intVal = Tag.getIntValue(value); os = new OtherSpec(name, intVal, false); } else if (type.equals(DATA_TYPE_INDICATOR_DOUBLE)) { double dblVal = Tag.getDoubleValue(value); os = new OtherSpec(name, dblVal, false); } else if (type.equals(DATA_TYPE_INDICATOR_STRING)) os = new OtherSpec(name, value, false); else if (type.equals(DATA_TYPE_INDICATOR_BOOLEAN)) { boolean booVal = Tag.getBooleanValue(value); os = new OtherSpec(name, booVal, false); } config.getNodeSpecs().addSpec(os); continue; } t.bad(); } } private void doLinkProfiles(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_LINK_PROFILES))) { if (t.name.equals(ELEMENT_LINK_PROFILE)) { String name = t.getAttrib("name"); boolean exactMatchRequired = Tag.getBooleanValue(t.getAttrib("requireExactMatch")); LinkProfile lp = new LinkProfile(name, exactMatchRequired); config.getLinkProfiles().addProfile(lp); if (!t.terminated) doLinkProfile(in); continue; } t.bad(); } } private void doLinkProfile(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_LINK_PROFILE))) { if (t.name.equals(ELEMENT_LINK_REQS)) { if (!t.terminated) doLinkReqs(in); continue; } t.bad(); } } private void doLinkReqs(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_LINK_REQS))) { if (t.name.equals(ELEMENT_LINK_REQ_MINSPEED)) { int value = Tag.getIntValue(t.getAttrib("value")); MinSpeed ms = new MinSpeed(value); config.getLinkProfiles().getLastProfile().addReq(ms); continue; } if (t.name.equals(ELEMENT_LINK_REQ_PROTOCOL)) { String protocolid = t.getAttrib("protocolid"); ReqProtocol rp = new ReqProtocol(protocolid); config.getLinkProfiles().getLastProfile().addReq(rp); continue; } if (t.name.equals(ELEMENT_WIRELESS)) { String value = t.getAttrib("value"); Wireless w = null; if (value.equals(XML_TRISTATE_TRUE)) w = new Wireless(1, true); else if (value.equals(XML_TRISTATE_FALSE)) w = new Wireless(-1, true); else if (value.equals(XML_TRISTATE_CANBE)) w = new Wireless(0, true); else //this validation should be done by the DTD throw new XMLValidationException("Invalid Wireless value \"" + value + "\"\nUse either \"" + XML_TRISTATE_TRUE + "\", \"" + XML_TRISTATE_FALSE + "\" or \"" + XML_TRISTATE_CANBE + "\"."); config.getLinkProfiles().getLastProfile().addReq(w); continue; } if (t.name.equals(ELEMENT_RELIABLE)) { boolean value = Tag.getBooleanValue(t.getAttrib("value")); Reliable r = new Reliable(value, true); config.getLinkProfiles().getLastProfile().addReq(r); continue; } if (t.name.equals(ELEMENT_CONNECTION_ORIENTED)) { boolean value = Tag.getBooleanValue(t.getAttrib("value")); ConnectionOriented co = new ConnectionOriented(value, true); config.getLinkProfiles().getLastProfile().addReq(co); continue; } if (t.name.equals(ELEMENT_LINK_REQ_MAXPING)) { int value = Tag.getIntValue(t.getAttrib("value")); MaxPing mp = new MaxPing(value); config.getLinkProfiles().getLastProfile().addReq(mp); continue; } if (t.name.equals(ELEMENT_LINK_REQ_OTHER)) { String name = t.getAttrib("name"); String comparator = t.getAttrib("comparator"); String type = t.getAttrib("type"); String value = t.getAttrib("value"); OtherReq or = null; if (type.equals(DATA_TYPE_INDICATOR_INT)) { int intVal = Tag.getIntValue(value); or = new OtherReq(name, intVal, comparator); } else if (type.equals(DATA_TYPE_INDICATOR_DOUBLE)) { double dblVal = Tag.getDoubleValue(value); or = new OtherReq(name, dblVal, comparator); } else if (type.equals(DATA_TYPE_INDICATOR_STRING)) or = new OtherReq(name, value, comparator); else if (type.equals(DATA_TYPE_INDICATOR_BOOLEAN)) { boolean booVal = Tag.getBooleanValue(value); or = new OtherReq(name, booVal, comparator); } config.getLinkProfiles().getLastProfile().addReq(or); continue; } t.bad(); } } private void doNodeProfiles(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_NODE_PROFILES))) { if (t.name.equals(ELEMENT_NODE_PROFILE)) { String name = t.getAttrib("name"); boolean exactMatchRequired = Tag.getBooleanValue(t.getAttrib("requireExactMatch")); NodeProfile np = new NodeProfile(name, exactMatchRequired); config.getNodeProfiles().addProfile(np); if (!t.terminated) doNodeProfile(in); continue; } t.bad(); } } private void doNodeProfile(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_NODE_PROFILE))) { if (t.name.equals(ELEMENT_NODE_REQS)) { if (!t.terminated) doNodeReqs(in); continue; } t.bad(); } } private void doNodeReqs(Reader in) throws IOException { Tag t; while (((t = nextTag(in)) != null) && (!t.name.equals("/" + ELEMENT_NODE_REQS))) { if (t.name.equals(ELEMENT_NODE_REQ_MINSPEED)) { int value = Tag.getIntValue(t.getAttrib("value")); MinSpeed ms = new MinSpeed(value); config.getNodeProfiles().getLastProfile().addReq(ms); continue; } if (t.name.equals(ELEMENT_NODE_REQ_MINMEMORY)) { int value = Tag.getIntValue(t.getAttrib("value")); MinMemory mm = new MinMemory(value); config.getNodeProfiles().getLastProfile().addReq(mm); continue; } if (t.name.equals(ELEMENT_NODE_REQ_OTHER)) { String name = t.getAttrib("name"); String comparator = t.getAttrib("comparator"); String type = t.getAttrib("type"); String value = t.getAttrib("value"); OtherReq or = null; if(type.equals(DATA_TYPE_INDICATOR_INT)) { int intVal = Tag.getIntValue(value); or = new OtherReq(name, intVal, comparator); } else if(type.equals(DATA_TYPE_INDICATOR_DOUBLE)) { double dblVal = Tag.getDoubleValue(value); or = new OtherReq(name, dblVal, comparator); } else if(type.equals(DATA_TYPE_INDICATOR_STRING)) or = new OtherReq(name, value, comparator); else if(type.equals(DATA_TYPE_INDICATOR_BOOLEAN)) { boolean booVal = Tag.getBooleanValue(value); or = new OtherReq(name, booVal, comparator); } config.getNodeProfiles().getLastProfile().addReq(or); continue; } t.bad(); } } public JCSPConfig getConfig() { return config; } private static final int MAX_ATTRIBS = 20; private final String[] attribs = new String[MAX_ATTRIBS]; private final String[] values = new String[MAX_ATTRIBS]; private Tag nextTag(Reader in) throws IOException { int i; char c; String name; boolean terminated = false; //put in for J# compat - is always set do { // skip whitespace do { i = in.read(); if (i < 0) return null; c = (char) i; } while (isSpace(c)); // expect to find a '<' character if (c != '<') throw new IOException("Expected '<'"); // get the tag name (up to a space) c = nextChar(in); if (c != '!') break; // comment - skip until '>' do { c = nextChar(in); } while (c != '>'); } while (true); name = ""; do { name = name + c; c = nextChar(in); } while ((!isSpace(c)) && (c != '/') && (c != '>')); // get attributes i = 0; do { // skip whitespace while (isSpace(c)) c = nextChar(in); if (c == '>') { terminated = false; break; } if (c == '/') { terminated = true; while (c != '>') c = nextChar(in); break; } // read the attribute name attribs[i] = ""; while ((c != '=') && (!isSpace(c)) && (c != '>') && (c != '/')) { attribs[i] = attribs[i] + c; c = nextChar(in); } // read the attribute value c = nextChar(in); // a quote if (c == '\"') { c = nextChar(in); // skip the quote values[i] = ""; do { values[i] = values[i] + c; c = nextChar(in); } while (c != '\"'); c = nextChar(in); i++; } else { // skip to the '>' or '/' characters while ((c != '>') && (c != '/')) c = nextChar(in); } } while (true); // return the tag String[] a = new String[i], v = new String[i]; for (int j = 0; j < i; j++) { a[j] = attribs[j]; v[j] = values[j]; } return new Tag(name, a, v, terminated); } private boolean isSpace(char c) { return (c == ' ') || (c == '\t') || (c == '\r') || (c == '\n'); } private char nextChar(Reader in) throws IOException { int i = in.read(); if (i < 0) throw new IOException("Unexpected end of file"); return (char) i; } private static class Tag { public final String name; public final String[] attrib; public final String[] value; public final boolean terminated; public Tag(String name, String[] attrib, String[] value, boolean terminated) { this.name = name; this.attrib = attrib; this.value = value; this.terminated = terminated; } public String getAttrib(String attr, String def) { for (int i = 0; i < attrib.length; i++) { if (attr.equals(attrib[i])) return value[i]; } return def; } public String getAttrib(String attr) { return getAttrib(attr, null); } public void bad() throws IOException { throw new IOException("Unexpected tag - " + name); } public static boolean getBooleanValue(String val) { if (val.equals(XML_BOOLEAN_TRUE)) return true; if (val.equals(XML_BOOLEAN_FALSE)) return false; throw new XMLValidationException("expected boolean tag"); } public static int getIntValue(String val) { return Integer.parseInt(val); } public static double getDoubleValue(String val) { return Double.parseDouble(val); } } /** * Thrown in the event of a semantic error in the parsed XML file. * * @author Quickstone Technologies Limited */ public static class XMLValidationException extends RuntimeException { /** * Creates a new exception without a detail message. */ public XMLValidationException() { super(); } /** * Creates a new exception with a detail message. * * @param msg the detail message. */ public XMLValidationException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/MinSpeed.java0000644000000000000000000000626611105701167020150 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a minimum speed setting. * * @author Quickstone Technologies Limited */ public class MinSpeed extends Spec implements Req, XMLConfigConstants { MinSpeed(int minSpeed) { super(REQ_NAME_MINSPEED, true, true); this.minSpeed = minSpeed - 1; } public String getStringValue() { return "" + minSpeed; } public String getComparator() { return REQ_COMPARATOR_GREATER; } public int getIntValue() { return getValue(); } public double getDoubleValue() { throw new UnsupportedOperationException("Type is int"); } public boolean getBooleanValue() { throw new UnsupportedOperationException("Type is int"); } public Class getType() { return Integer.TYPE; } public int getValue() { return minSpeed; } public boolean equals(Object o) { if(o instanceof MinSpeed) { MinSpeed other = (MinSpeed) o; return minSpeed == other.minSpeed; } return false; } public int hashCode() { return minSpeed; } private int minSpeed; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Reliable.java0000644000000000000000000000635611105701167020163 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a reliable protocol. * * @author Quickstone Technologies Limited */ public class Reliable extends Spec implements Req { Reliable(boolean reliable, boolean isReq) { super(SPEC_NAME_RELIABLE, true, isReq); this.reliable = reliable; } public String getStringValue() { return "" + reliable; } public boolean getValue() { return reliable; } public Class getType() { return Boolean.TYPE; } public String getComparator() { return REQ_COMPARATOR_EQUALS; } public int getIntValue() { throw new UnsupportedOperationException("Type is boolean"); } public double getDoubleValue() { throw new UnsupportedOperationException("Type is boolean"); } public boolean getBooleanValue() { return getValue(); } public boolean equals(Object o) { if(o instanceof Reliable) { Reliable other = (Reliable) o; return reliable == other.reliable; } return false; } public int hashCode() { if(reliable) return 1; else return 0; } private boolean reliable; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/package.html0000644000000000000000000000034611077340707020062 0ustar

This package is used internally by the JCSP network infrastructure to load XML configuration files and represent their structure. It is not intended for use and so minimal documentation is supplied.

jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/NodeProfiles.java0000644000000000000000000000750311105701167021030 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; /** * Used internally within the JCSP network infrastructure to represent a set of node profiles. * * @author Quickstone Technologies Limited */ public class NodeProfiles { public void addProfile(NodeProfile p) { if(p != null) { if(!profiles.contains(p) && !profileNameMap.containsKey(p.getName())) { profiles.put(p, p); profileNameMap.put(p.getName(), p); lastProfile = p; } else throw new NodeProfileAlreadyExistsException("Already have a profile named " + p.getName()); } } public void removeProfile(NodeProfile p) { if(profiles.contains(p)) { profiles.remove(p); profileNameMap.remove(p.getName()); } } public NodeProfile getProfile(String name) { return (NodeProfile) profileNameMap.get(name); } public NodeProfile[] getProfiles() { NodeProfile[] toReturn = new NodeProfile[profiles.size()]; return (NodeProfile[])profiles.keySet().toArray(toReturn); } public NodeProfile getLastProfile() { return lastProfile; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n"); NodeProfile[] profiles = getProfiles(); for(int i=0; i"); return sb.toString(); } private Hashtable profiles = new Hashtable(); private Hashtable profileNameMap = new Hashtable(); private NodeProfile lastProfile = null; static class NodeProfileAlreadyExistsException extends RuntimeException { private NodeProfileAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Address.java0000644000000000000000000000667611105701167020036 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a single address. * * @author Quickstone Technologies Limited */ public class Address { public Address(String protocolID, String value, boolean unique) { this.protocolID = protocolID; this.value = value; this.unique = unique; } public String getProtocolID() { return protocolID; } public String getValue() { return value; } public void addSpec(Spec spec) { specs.addSpec(spec); } public void removeSpec(Spec spec) { specs.removeSpec(spec); } public Spec[] getSpecs() { return specs.getSpecs(); } public boolean isUnique() { return unique; } public boolean equals(Object o) { if(o instanceof Address) { Address other = (Address) o; if(protocolID.equals(other.protocolID) && value.equals(other.value)) return true; } return false; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("
\n"); sb.append(JCSPConfig.tabIn(specs.toString())).append("\n"); sb.append("
"); return sb.toString(); } private String protocolID; private String value; private boolean unique; private Specs specs = new Specs(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/MaxPing.java0000644000000000000000000000624011105701167017777 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a maximum ping rate. * * @author Quickstone Technologies Limited */ public class MaxPing extends Spec implements Req, XMLConfigConstants { MaxPing(int maxPing) { super(REQ_NAME_MAXPING, true, true); this.maxPing = maxPing + 1; } public String getStringValue() { return "" + maxPing; } public String getComparator() { return REQ_COMPARATOR_LESS; } public int getIntValue() { return getValue(); } public double getDoubleValue() { throw new UnsupportedOperationException("Type is int"); } public boolean getBooleanValue() { throw new UnsupportedOperationException("Type is int"); } public Class getType() { return Integer.TYPE; } public int getValue() { return maxPing; } public boolean equals(Object o) { if(o instanceof MaxPing) { MaxPing other = (MaxPing) o; return maxPing == other.maxPing; } return false; } public int hashCode() { return maxPing; } private int maxPing; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Memory.java0000644000000000000000000000526011105701167017705 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a memory value. * * @author Quickstone Technologies Limited */ public class Memory extends Spec implements XMLConfigConstants { Memory(int memory) { super(SPEC_NAME_MEMORY, true); this.memory = memory; } public String getStringValue() { return "" + memory; } public boolean equals(Object o) { if(o instanceof Memory) { Memory other = (Memory) o; return memory == other.memory; } return false; } public int hashCode() { return memory; } public int getValue() { return memory; } private int memory; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/NodeProfile.java0000644000000000000000000001242411105701167020643 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; /** * Used internally within the JCSP network infrastructure to represent a node profile. * * @author Quickstone Technologies Limited */ public class NodeProfile { public NodeProfile(String name, boolean exactMatchRequired) { this.name = name; this.exactMatchRequired = exactMatchRequired; } public void addReq(Req req) { if(req instanceof MinSpeed && minSpeed == null) minSpeed = (MinSpeed) req; else if(req instanceof MinMemory && minMemory == null) minMemory = (MinMemory) req; else if(req instanceof OtherReq && !reqs.contains(req)) reqs.put(req, req); else throw new ReqAlreadyExistsException("Already have a req named " + req.getName()); } public void removeReq(Req req) { if(minSpeed == req) minSpeed = null; else if(minMemory == req) minMemory = null; else if(req instanceof OtherReq && reqs.contains(req)) reqs.remove(req); } public Req[] getReqs() { int count=0; if(minSpeed != null) count++; if(minMemory != null) count++; count += reqs.size(); Req[] toReturn = new Req[count]; int pos = 0; if(minSpeed != null) { toReturn[pos] = minSpeed; pos++; } if(minMemory != null) { toReturn[pos] = minMemory; pos++; } for (Enumeration it = reqs.keys(); it.hasMoreElements(); ) { toReturn[pos] = (Req) it.nextElement(); pos++; } return toReturn; } public String getName() { return name; } public boolean getExactMatchRequired() { return exactMatchRequired; } public boolean equals(Object o) { if(o instanceof NodeProfile) { NodeProfile other = (NodeProfile) o; if ((minSpeed == other.minSpeed || (minSpeed != null && minSpeed.equals(other.minSpeed))) && (minMemory == other.minMemory || (minMemory != null && minMemory.equals(other.minMemory))) && reqs.equals(other.reqs)) { return true; } } return false; } public int hashCode() { return reqs.hashCode(); } public String toString() { StringBuffer sb = new StringBuffer(); Req[] reqs = getReqs(); sb.append("\n"); if (reqs.length > 0) sb.append(JCSPConfig.tabIn("")).append("\n"); for (int i=0; i 0) sb.append(JCSPConfig.tabIn("")).append("\n"); sb.append(""); return sb.toString(); } private MinSpeed minSpeed = null; private MinMemory minMemory = null; private MaxPing maxPing = null; private Hashtable reqs = new Hashtable(); private String name; private boolean exactMatchRequired; static class ReqAlreadyExistsException extends RuntimeException { private ReqAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Protocols.java0000644000000000000000000000746511105701167020432 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; /** * Used internally within the JCSP network infrastructure to represent a set of protocols. * * @author Quickstone Technologies Limited */ public class Protocols { public void addProtocol(Protocol p) { if(p != null) { if(!protocols.contains(p) && !protocolIDMap.containsKey(p.getProtocolID())) { protocols.put(p, p); protocolIDMap.put(p.getProtocolID(), p); lastProtocol = p; } } else throw new ProtocolAlreadyExistsException("Already have a protocold named " + p.getName()); } public void removeProtocol(Protocol p) { if (protocols.contains(p)) { protocols.remove(p); protocolIDMap.remove(p.getProtocolID()); } } public Protocol getProtocol(String protocolID) { return (Protocol) protocolIDMap.get(protocolID); } public Protocol getLastProtocol() { return lastProtocol; } public Protocol[] getProtocols() { Protocol[] toReturn = new Protocol[protocols.size()]; return (Protocol[])protocols.keySet().toArray(toReturn); } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n"); Protocol[] protocols = getProtocols(); for(int i=0; i"); return sb.toString(); } private Hashtable protocols = new Hashtable(); private Hashtable protocolIDMap = new Hashtable(); private Protocol lastProtocol = null; static class ProtocolAlreadyExistsException extends RuntimeException { private ProtocolAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Specs.java0000644000000000000000000001460311105701167017513 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; /** * Used internally within the JCSP network infrastructure to represent a set of system specifications. * * @author Quickstone Technologies Limited */ public class Specs { public void addSpec(Spec spec) { if(spec instanceof MaxSpeed && maxSpeed == null) maxSpeed = (MaxSpeed)spec; else if(spec instanceof Memory && memory == null) memory = (Memory)spec; else if(spec instanceof Wireless && wireless == null) wireless = (Wireless)spec; else if(spec instanceof Reliable && reliable == null) reliable = (Reliable)spec; else if(spec instanceof ConnectionOriented && connectionOriented == null) connectionOriented = (ConnectionOriented)spec; else if(spec instanceof OtherSpec && !specs.contains(spec)) specs.put(spec,spec); else throw new SpecAlreadyExistsException("Already have a spec named " + spec.getName()); } public void removeSpec(Spec spec) { if(maxSpeed == spec) maxSpeed = null; else if(memory == spec) memory = null; else if(wireless == spec) wireless = null; else if(reliable == spec) reliable = null; else if(connectionOriented == spec) connectionOriented = null; else if(spec instanceof OtherSpec && specs.contains(spec)) specs.remove(spec); } public Spec[] getSpecs() { int count=0; if(maxSpeed != null) count++; if(memory != null) count++; if(wireless != null) count++; if(reliable != null) count++; if(connectionOriented != null) count++; count += specs.size(); Spec[] toReturn = new Spec[count]; int pos = 0; if(maxSpeed != null) { toReturn[pos] = maxSpeed; pos++; } if(memory != null) { toReturn[pos] = memory; pos++; } if(wireless != null) { toReturn[pos] = wireless; pos++; } if(reliable != null) { toReturn[pos] = reliable; pos++; } if(connectionOriented != null) { toReturn[pos] = connectionOriented; pos++; } for (Enumeration e = specs.keys(); e.hasMoreElements(); ) { toReturn[pos] = (Spec) e.nextElement(); pos++; } return toReturn; } public boolean equals(Object o) { if(o instanceof Specs) { Specs other = (Specs) o; if((maxSpeed==other.maxSpeed || (maxSpeed!= null && maxSpeed.equals(other.maxSpeed))) && (memory == other.memory || (memory != null && memory.equals(other.memory))) && (wireless == other.wireless ||(wireless != null && wireless.equals(other.wireless))) && (reliable == other.reliable || (reliable != null && reliable.equals(other.reliable))) && (connectionOriented == other.connectionOriented || (connectionOriented != null && connectionOriented.equals(other.connectionOriented))) && specs.equals(other.specs)) { return true; } } return false; } public int hashCode() { int count=0; if (maxSpeed != null) count++; if (memory != null) count++; if (wireless != null) count++; if (reliable != null) count++; if (connectionOriented != null) count++; count += specs.size(); return count; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n"); Spec[] specs = getSpecs(); for(int i=0; i"); return sb.toString(); } private MaxSpeed maxSpeed = null; private Memory memory = null; private Wireless wireless = null; private Reliable reliable = null; private ConnectionOriented connectionOriented = null; private Hashtable specs = new Hashtable(); static class SpecAlreadyExistsException extends RuntimeException { private SpecAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Req.java0000644000000000000000000000442311105701167017164 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * A system requirement. * * @author Quickstone Technologies Limited */ public interface Req { public String getName(); public Class getType(); public String getComparator(); public int getIntValue(); public double getDoubleValue(); public boolean getBooleanValue(); public String getStringValue(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/AddressSetting.java0000644000000000000000000000720311105701167021357 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent an address setting. * * @author Quickstone Technologies Limited */ public class AddressSetting extends Setting { public AddressSetting(String name, String value, String protocolID) { super(name, value); this.protocolID = protocolID; } public String getProtocolID() { return protocolID; } public AddressSetting getAlternate() { return alternate; } public boolean addAlternate(AddressSetting alternate) { if(alternate == null || !getName().equals(alternate.getName())) return false; AddressSetting prevRAdd = this; AddressSetting rAdd = alternate; while(rAdd != null) { if(rAdd == this || rAdd == alternate) break; prevRAdd = rAdd; rAdd = rAdd.alternate; } prevRAdd.alternate = alternate; return true; } public boolean equals(Object o) { if(o instanceof AddressSetting) { AddressSetting other = (AddressSetting) o; if(protocolID.equals(other.protocolID) && getName().equals(other.getName()) && getValue().equals(other.getValue())) return true; } return false; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append(""); if(alternate != null) sb.append("\n").append(alternate.toString()); return sb.toString(); } private String protocolID; private AddressSetting alternate = null; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/ConnectionOriented.java0000644000000000000000000000662011105701167022227 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a connection oriented protocol. * * @author Quickstone Technologies Limited */ public class ConnectionOriented extends Spec implements Req { ConnectionOriented(boolean connectionOriented, boolean isReq) { super(SPEC_NAME_CONNECTION_ORIENTED, true, isReq); this.connectionOriented = connectionOriented; } public String getStringValue() { return "" + connectionOriented; } public boolean getValue() { return connectionOriented; } public Class getType() { return Boolean.TYPE; } public String getComparator() { return REQ_COMPARATOR_EQUALS; } public int getIntValue() { throw new UnsupportedOperationException("Type is boolean"); } public double getDoubleValue() { throw new UnsupportedOperationException("Type is boolean"); } public boolean getBooleanValue() { return getValue(); } public boolean equals(Object o) { if(o instanceof ConnectionOriented) { ConnectionOriented other = (ConnectionOriented) o; return connectionOriented == other.connectionOriented; } return false; } public int hashCode() { if(connectionOriented) return 1; else return 0; } private boolean connectionOriented; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/JCSPConfig.java0000644000000000000000000001160311105701167020320 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent the overall configuration. * * @author Quickstone Technologies Limited */ public class JCSPConfig { public void setSettings(Settings settings) { this.settings = settings; } public Settings getSettings() { return settings; } public void setServices(Services services) { this.services = services; } public Services getServices() { return services; } public void setPlugins(Plugins plugins) { this.plugins = plugins; } public Plugins getPlugins() { return plugins; } public void setProtocols(Protocols protocols) { this.protocols = protocols; } public Protocols getProtocols() { return protocols; } public void setAddresses(Addresses addresses) { this.addresses = addresses; } public Addresses getAddresses() { return addresses; } public void setNodeSpecs(Specs specs) { this.nodeSpecs = specs; } public Specs getNodeSpecs() { return nodeSpecs; } public void setLinkProfiles(LinkProfiles linkProfiles) { this.linkProfiles = linkProfiles; } public LinkProfiles getLinkProfiles() { return linkProfiles; } public void setNodeProfiles(NodeProfiles nodeProfiles) { this.nodeProfiles = nodeProfiles; } public NodeProfiles getNodeProfiles() { return nodeProfiles; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n"); sb.append(tabIn(settings.toString())).append("\n"); sb.append(tabIn(services.toString())).append("\n"); sb.append(tabIn(plugins.toString())).append("\n"); sb.append(tabIn(protocols.toString())).append("\n"); sb.append(tabIn(addresses.toString())).append("\n"); sb.append(tabIn(nodeSpecs.toString())).append("\n"); sb.append(tabIn(linkProfiles.toString())).append("\n"); sb.append(tabIn(nodeProfiles.toString())).append("\n"); sb.append(""); return sb.toString(); } public static String tabIn(String string) { StringBuffer sb = new StringBuffer(string); //tab in first line sb.insert(0, " "); for(int i=0; i\n"); Address[] addresses = getAddresses(); for(int i=0; i"); return sb.toString(); } private Hashtable addresses = new Hashtable(); private Address lastAddress = null; static class AddressAlreadyExistsException extends RuntimeException { private AddressAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/OtherSpec.java0000644000000000000000000000777711105701167020350 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent misellaneous specifications. * * @author Quickstone Technologies Limited */ public class OtherSpec extends Spec { OtherSpec(String name, int value, boolean isReq) { super(name, false, isReq); intValue = value; strValue = "" + value; type = Integer.TYPE; } OtherSpec(String name, double value, boolean isReq) { super(name, false, isReq); dblValue = value; strValue = "" + value; type = Double.TYPE; } OtherSpec(String name, boolean value, boolean isReq) { super(name, false, isReq); booValue = value; strValue = "" + value; type = Boolean.TYPE; } OtherSpec(String name, String value, boolean isReq) { super(name, false, isReq); strValue = value; type = String.class; } public Class getType() { return type; } public int getIntValue() { return intValue; } public double getDoubleValue() { return dblValue; } public boolean getBooleanValue() { return booValue; } public String getStringValue() { return strValue; } public boolean equals(Object o) { if(o instanceof OtherSpec) { OtherSpec other = (OtherSpec) o; if(getName().equals(other.getName()) && type.equals(other.type)) { if(type.equals(Integer.TYPE)) return intValue == other.intValue; else if(type.equals(Double.TYPE)) return dblValue == other.dblValue; else if(type.equals(Boolean.TYPE)) return booValue == other.booValue; else if(type.equals(String.class)) return strValue == other.strValue; } } return false; } private Class type; private int intValue = -1; private double dblValue = -1.0; private boolean booValue = false; private String strValue = null; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/XMLConfigConstants.java0000644000000000000000000001517511105701167022126 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to define the XML configuration names. * * @author Quickstone Technologies Limited */ public interface XMLConfigConstants { public static final String SPEC_NAME_MAXSPEED = "MAXSPEED"; public static final String SPEC_NAME_WIRELESS = "WIRELESS"; public static final String SPEC_NAME_RELIABLE = "RELIABLE"; public static final String SPEC_NAME_CONNECTION_ORIENTED = "CONNECTION-ORIENTED"; public static final String SPEC_NAME_MEMORY = "MEMORY"; //determined automatically. public static final String SPEC_NAME_PROTOCOL = "PROTOCOL"; public static final String SPEC_NAME_PING = "AAAPING"; //so it is found quickly public static final String REQ_NAME_MINSPEED = "MINSPEED"; public static final String REQ_NAME_PROTOCOL = "REQPROTOCOL"; public static final String REQ_NAME_MAXPING = "MAXPING"; //MINSPEED used for node as well as network public static final String REQ_NAME_MINMEMORY = "MINMEMORY"; public static final String[] RESERVED_SPEC_NAMES = new String[] { SPEC_NAME_MAXSPEED, SPEC_NAME_WIRELESS, SPEC_NAME_RELIABLE, SPEC_NAME_CONNECTION_ORIENTED, SPEC_NAME_PROTOCOL, SPEC_NAME_PING, SPEC_NAME_MEMORY, REQ_NAME_MAXPING, REQ_NAME_MINSPEED, REQ_NAME_PROTOCOL, REQ_NAME_MINMEMORY }; public static final String REQ_COMPARATOR_EQUALS = "EQU"; public static final String REQ_COMPARATOR_GREATER = "GRT"; public static final String REQ_COMPARATOR_LESS = "LTH"; public static final String XML_BOOLEAN_TRUE = "TRUE"; public static final String XML_BOOLEAN_FALSE = "FALSE"; public static final String XML_TRISTATE_TRUE = "TRUE"; public static final String XML_TRISTATE_FALSE = "FALSE"; public static final String XML_TRISTATE_CANBE = "CANBE"; public static final String DATA_TYPE_INDICATOR_INT = "int"; public static final String DATA_TYPE_INDICATOR_DOUBLE = "dec"; public static final String DATA_TYPE_INDICATOR_STRING = "string"; public static final String DATA_TYPE_INDICATOR_BOOLEAN = "boolean"; public static final String ELEMENT_SETTINGS = "SETTINGS"; public static final String ELEMENT_SERVICES = "SERVICES"; public static final String ELEMENT_PLUGINS = "PLUGINS"; public static final String ELEMENT_PROTOCOLS = "PROTOCOLS"; public static final String ELEMENT_ADDRESSES = "ADDRESSES"; public static final String ELEMENT_LINK_PROFILES = "LINK_PROFILES"; public static final String ELEMENT_NODE_PROFILES = "NODE_PROFILES"; public static final String ELEMENT_NODE_SPECS = "NODE_SPECS"; public static final String ELEMENT_SETTING = "SETTING"; public static final String ELEMENT_SERVICE = "SERVICE"; public static final String ELEMENT_ADDRESS_SETTING = "ADDRESS_SETTING"; public static final String ELEMENT_PLUGIN = "PLUGIN"; public static final String ELEMENT_PROTOCOL = "PROTOCOL"; public static final String ELEMENT_PROTOCOL_SETTINGS = "PROTOCOL_SETTINGS"; public static final String ELEMENT_PROTOCOL_SETTING = "PROTOCOL_SETTING"; public static final String ELEMENT_SPECS = "SPECS"; public static final String ELEMENT_MAXSPEED = "MAXSPEED"; public static final String ELEMENT_WIRELESS = "WIRELESS"; public static final String ELEMENT_RELIABLE = "RELIABLE"; public static final String ELEMENT_CONNECTION_ORIENTED = "CONNECTION-ORIENTED"; public static final String ELEMENT_MEMORY = "MEMORY"; public static final String ELEMENT_OTHERSPEC = "OTHERSPEC"; public static final String ELEMENT_ADDRESS = "ADDRESS"; public static final String ELEMENT_LINK_PROFILE = "LINK_PROFILE"; public static final String ELEMENT_LINK_REQS = "LINK_REQS"; public static final String ELEMENT_LINK_REQ_PROTOCOL = "LINK_REQ_PROTOCOL"; public static final String ELEMENT_LINK_REQ_MINSPEED = "LINK_MINSPEED"; public static final String ELEMENT_LINK_REQ_MAXPING = "LINK_MAXPING"; public static final String ELEMENT_LINK_REQ_OTHER = "LINK_REQ"; public static final String ELEMENT_NODE_PROFILE = "NODE_PROFILE"; public static final String ELEMENT_NODE_REQS = "NODE_REQS"; public static final String ELEMENT_NODE_REQ_MINSPEED = "NODE_MINSPEED"; public static final String ELEMENT_NODE_REQ_MINMEMORY = "NODE_MINMEMORY"; public static final String ELEMENT_NODE_REQ_OTHER = "NODE_REQ"; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Setting.java0000644000000000000000000000563211105701167020055 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a system setting. * * @author Quickstone Technologies Limited */ public class Setting { public Setting(String name, String value) { this.name = name; this.value = value; } public String getName() { return name; } public String getValue() { return value; } public boolean equals(Object o) { if(o instanceof Setting) { Setting other = (Setting) o; return name.equals(other.name) && value.equals(other.value); } return false; } public int hashCode() { return name.hashCode(); } public String toString() { StringBuffer sb = new StringBuffer(); sb.append(""); return sb.toString(); } private String name; private String value; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Wireless.java0000644000000000000000000000644411105701167020237 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a wireless protocol. * * @author Quickstone Technologies Limited */ public class Wireless extends Spec implements Req { Wireless(int wireless, boolean isReq) { super(SPEC_NAME_WIRELESS, true, isReq); if (wireless > 0) this.wireless = 1; else if (wireless < 0) this.wireless = -1; else this.wireless = 0; } public String getStringValue() { return "" + wireless; } public int getValue() { return wireless; } public Class getType() { return Boolean.TYPE; } public String getComparator() { return REQ_COMPARATOR_EQUALS; } public int getIntValue() { return getValue(); } public double getDoubleValue() { throw new UnsupportedOperationException("Type is int"); } public boolean getBooleanValue() { throw new UnsupportedOperationException("Type is int"); } public boolean equals(Object o) { if(o instanceof Wireless) { Wireless other = (Wireless) o; return wireless == other.wireless; } return false; } public int hashCode() { return wireless; } private int wireless; }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Services.java0000644000000000000000000000717511105701167020227 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; import java.util.*; /** * Used internally within the JCSP network infrastructure to represent a set of services. * * @author Quickstone Technologies Limited */ public class Services { public void addService(Service s) { if(s != null) { if(!serviceNameMap.containsKey(s.getName())) { serviceNameMap.put(s.getName(), s); lastService = s; return; } } throw new ServiceAlreadyExistsException("Already have a service named " + s.getName()); } public void removeService(Service s) { if(serviceNameMap.containsKey(s.getName())) serviceNameMap.remove(s.getName()); } public Service getService(String name) { return (Service) serviceNameMap.get(name); } public Service getLastService() { return lastService; } public Service[] getServices() { Service[] toReturn = new Service[serviceNameMap.size()]; return (Service[])serviceNameMap.values().toArray(toReturn); } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n"); Service[] services = getServices(); for(int i=0; i"); return sb.toString(); } private Hashtable serviceNameMap = new Hashtable(); private Service lastService = null; static class ServiceAlreadyExistsException extends RuntimeException { private ServiceAlreadyExistsException(String msg) { super(msg); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/Spec.java0000644000000000000000000000676611105701167017343 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a set of system specifications. * * @author Quickstone Technologies Limited */ public abstract class Spec implements XMLConfigConstants { Spec(String name, boolean builtin) { if(!builtin) for (int i = 0; i < RESERVED_SPEC_NAMES.length; i++) if(name.equals(RESERVED_SPEC_NAMES[i])) throw new ReservedNameException(name); this.name = name; } Spec(String name, boolean builtin, boolean req) { this(name, builtin); this.isReq = req; } public boolean equals(Object o) { if(o instanceof Spec) { Spec other = (Spec) o; return name.equals(other.name); } return false; } public int hashCode() { return name.hashCode(); } public String getName() { return name; } public String toString() { StringBuffer sb = new StringBuffer(); if(isReq) sb.append(""); else sb.append(""); return sb.toString(); } public abstract String getStringValue(); private String name; private boolean isReq = false; static class ReservedNameException extends RuntimeException { private ReservedNameException(String name) { super("\"" + name + "\" is reserved."); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/settings/ReqProtocol.java0000644000000000000000000000641511105701167020711 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.settings; /** * Used internally within the JCSP network infrastructure to represent a protocol requirement. * * @author Quickstone Technologies Limited */ public class ReqProtocol extends Spec implements Req, XMLConfigConstants { ReqProtocol(String protocolid) { super(REQ_NAME_PROTOCOL, true); this.protocolid = protocolid; } public String getStringValue() { return protocolid; } public String getComparator() { return REQ_COMPARATOR_EQUALS; } public int getIntValue() { throw new UnsupportedOperationException("Type is string"); } public double getDoubleValue() { throw new UnsupportedOperationException("Type is string"); } public boolean getBooleanValue() { throw new UnsupportedOperationException("Type is string"); } public Class getType() { return String.class; } public String getValue() { return protocolid; } public boolean equals(Object o) { if(o instanceof ReqProtocol) { ReqProtocol other = (ReqProtocol) o; return protocolid.equals(other.protocolid); } return false; } public int hashCode() { return protocolid.hashCode(); } private String protocolid; }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetSharedConnectionServerImpl.java0000644000000000000000000000727311105701167022511 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; import org.jcsp.util.Buffer; /** * @author Quickstone Technologies Limited */ class NetSharedConnectionServerImpl extends SharedConnectionServerImpl implements NetSharedConnectionServer { static NetSharedConnectionServerImpl create() { NetAltingChannelInput in = NetChannelEnd.createNet2One(); Any2OneChannel synchChan = Channel.any2one(new Buffer(1)); return new NetSharedConnectionServerImpl(synchChan, in); } private Any2OneChannel synchChan; private NetAltingChannelInput in; /** * Constructor for NetSharedConnectionServerImpl. */ private NetSharedConnectionServerImpl(Any2OneChannel synchChan, NetAltingChannelInput in) { super(in,in,synchChan.in(),synchChan.out(),null); this.synchChan = synchChan; this.in = in; } /** * Returns the server's location. * * @return the server's NetChannelLocation object. * * @see org.jcsp.net.Networked#getChannelLocation() */ public NetChannelLocation getChannelLocation() { return in.getChannelLocation(); } /** *

* Produces a duplicate * SharedConnectionServer object which * may be used by another process. *

* @return a new duplicate SharedConnectionServer * object. */ public SharedConnectionServer duplicate() { return new NetSharedConnectionServerImpl(synchChan, in); } /** * Destroys the server and frees any resources used within * the JCSP.NET infrastructure. * */ public void destroyServer() { synchChan.out().write(null); in.destroyReader(); synchChan.in().read(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NodeID.java0000644000000000000000000004312411105701167015700 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; import java.lang.reflect.*; import java.util.*; /** *

* A Class whose instances represent a unique identifier for a JCSP.NET Node. *

*

* For an explanation of this class, see {@link AbstractID}. *

* @author Quickstone Technologies Limited */ public final class NodeID extends AbstractID implements Serializable, Cloneable, Comparable { /*----------------------Constructors------------------------------------------*/ NodeID(NodeUI nodeUI) { if (nodeUI == null) throw new NullPointerException("nodeUI is null"); this.nodeUI = nodeUI; domainID = DomainID.getNullDomainID(); } NodeID(NodeUI nodeUI, NodeAddressID addressID, DomainID domainID) { this(nodeUI, new NodeAddressID[] { addressID }, domainID); } NodeID(NodeUI nodeUI, NodeAddressID[] addressIDs, DomainID domainID) { //copy the supplied array so that contents cannot be modified externally if (nodeUI == null) throw new NullPointerException("nodeUI is null"); if (domainID == null) throw new NullPointerException("domainID is null"); this.nodeUI = nodeUI; this.domainID = domainID; this.addressIDs = new NodeAddressID[addressIDs.length]; for (int i = 0; i < addressIDs.length; i++) { try { this.addressIDs[i] = (NodeAddressID) addressIDs[i].clone(); } catch (CloneNotSupportedException e) { //will make do without cloning this.addressIDs[i] = addressIDs[i]; } catch (NullPointerException e) { throw new NullPointerException("An addressID is null"); } } } private NodeID(String stringRep) throws IllegalArgumentException { if (stringRep == null) throw new IllegalArgumentException("No String supplied."); String[] strings = Utils.stringToArray(stringRep); if (strings.length < 2) throw new IllegalArgumentException("No NodeAddressID supplied."); domainID = new DomainID(strings[0]); nodeUI = NodeUI.createFromStringForm(strings[1]); boolean addressCreated = false; this.addressIDs = new NodeAddressID[strings.length - 2]; for (int i = 2; i < strings.length; i++) { int pos = strings[i].indexOf(":"); if (pos > -1) { String className = strings[i].substring(0, pos); String addStringRep = strings[i].substring(pos + 1); try { Class addressClass = Class.forName(className); Method createMethod = addressClass.getMethod("getAddressIDFromString", new Class[] { String.class }); NodeAddressID naddID = (NodeAddressID)createMethod.invoke(null, new Object[] { addStringRep }); this.addressIDs[i - 2] = naddID; } catch (Exception e) { e.printStackTrace(); if (!addressCreated && i == strings.length - 1) throw new IllegalArgumentException("No NodeAddressID created."); } } } } /*----------------------Public Methods----------------------------------------*/ /** *

* Returns a clone of the instance of NodeID on which * this method is being called. *

* @throws CloneNotSupportedException if the NodeID cannot be cloned. * @return a clone of the current instance of NodeID. */ public Object clone() throws CloneNotSupportedException { NodeID clone = (NodeID)super.clone(); clone.unrecognisedAddressIDs = (HashSet) unrecognisedAddressIDs.clone(); return clone; } /** *

* Compares this NodeID with another object. This will only return * true if the other object is a NodeID representing the same Node as * this NodeID. The comparison is performed by using a Node's unique * identifier. This was introduced for efficiency reasons as comparing two * NodeID objects' sets of addresses could be quite slow. *

* @param o another object to compare with this NodeID. * @return true iff the other object is a NodeID representing the same * Node as this NodeID. */ public boolean equals(Object o) { if (o == null || !(o instanceof NodeID)) return false; NodeID other = (NodeID) o; if (!(domainID.equals(other.getDomainID()))) return false; return nodeUI.equals(other.nodeUI); } /** *

* Returns a hash code for this NodeID object. *

* @return an int hash code. */ public int hashCode() { return nodeUI.hashCode(); } /** *

* Compares this NodeID object with another * NodeID object. Returns 0 if this NodeID is equal * to the other NodeID, a negative int if this * NodeID is less than the supplied NodeID or a positive * int if this NodeID is greater than the supplied * NodeID. *

*

* This comparison is based upon the implementation of NodeUI used. *

* @param o An object to compare with this NodeID. * @throws ClassCastException if the parameter supplied is not a NodeID. * @return 0 if this NodeID is equal * to the other NodeID, a negative int if this * NodeID is less than the supplied NodeID or a positive * int if this NodeID is greater than the supplied * NodeID. */ public int compareTo(Object o) throws ClassCastException { NodeID other = (NodeID) o; if (equals(o)) return 0; int domCompare = domainID.compareTo(other.domainID); if (domCompare != 0) return domCompare; return nodeUI.compareTo(other.nodeUI); } /** *

* This method is equivalent to calling the compareTo(Object) * and supplying the local Node's NodeID as a parameter. *

* * @return an int following the rules of the * compareTo(Object) method. */ public int compareToLocalNode() { return compareTo(Node.getInstance().getActualNode()); } boolean onSameBranch(AbstractID abstractID) { if (abstractID == null) return false; if (abstractID instanceof NodeID) return this.equals(abstractID); if (abstractID instanceof ApplicationID) return abstractID.onSameBranch(this); return domainID.onSameBranch(abstractID); } /** *

* Returns a clone of the set of NodeAddressID objects that * this NodeID holds. *

*

* If any held NodeAddressID objects do not support * cloning, then the actual object is returned but this should * never be the case. *

* @return an array of NodeAddressID objects. */ public synchronized NodeAddressID[] getAddresses() { NodeAddressID[] addressIDs = new NodeAddressID[this.addressIDs.length]; for (int i = 0; i < addressIDs.length; i++) { try { addressIDs[i] = (NodeAddressID) this.addressIDs[i].clone(); } catch (CloneNotSupportedException e) { //will make do without cloning addressIDs[i] = this.addressIDs[i]; } } return addressIDs; } synchronized void addAddress(NodeAddressID addressID) { final NodeAddressID[] newArray = new NodeAddressID[this.addressIDs.length + 1]; System.arraycopy(this.addressIDs, 0, newArray, 0, this.addressIDs.length); newArray[newArray.length - 1] = addressID; this.addressIDs = newArray; } synchronized void removeAddress(NodeAddressID addressID) { int position = -1; for (int i = 0; i < this.addressIDs.length; i++) { if (this.addressIDs[i].equals(addressID)) position = i; } if (position < 0) // The address was not in our list. Maybe raise an exception as this indicates a logical error elsewhere. return; final NodeAddressID[] newArray = new NodeAddressID[this.addressIDs.length - 1]; System.arraycopy(this.addressIDs, 0, newArray, 0, position); int remainingLength = this.addressIDs.length - position - 1; if (remainingLength > 0) System.arraycopy(this.addressIDs, position + 1, newArray, position, remainingLength); this.addressIDs = newArray; } /** * * @deprecated Not needed now channel names have been abstracted */ static NodeID createFromStringForm(String stringForm) throws IllegalArgumentException { return new NodeID(stringForm); } /** * This gets a String form of this NodeID. This is only intended to be * called for NodeID's representing the current JVM as any * NodeAddressIDs in serialized form in the unrecognisedAddressIDs * HashSet will not be saved. This HashSet should be empty for NodeID's * representing the current JVM. * * @deprecated Not needed now channel names have been abstracted * * @return the String form that can be used to reconstruct this NodeID. */ synchronized String getStringForm() { String[] strings = new String[addressIDs.length + 2]; strings[0] = domainID.getStringForm(); strings[1] = nodeUI.getStringForm(); for (int i = 0; i < addressIDs.length; i++) { NodeAddressID naddID = addressIDs[i]; strings[2 + i] = naddID.getClass().getName() + ":" + naddID.getStringForm(); } return Utils.arrayToString(strings); } synchronized void setDomainID(DomainID domainID) { this.domainID = domainID; } public AbstractID getParentID() { return domainID; } /** Get the DomainID of the domain to which the Node represented by * this NodeID object belongs. * If the Node is not a member of a domain then a DomainID object * will be returned that will return true when its * isNullDomain() method is called. * @return this NodeID object's DomainID object. */ public DomainID getDomainID() { return domainID; } /** Returns a name that has been assigned to the Node * represented by this NodeID object. * If no name has been assigned, then an empty String * is returned. * * The Node naming feature is not currently implemented. * @return the name assigned to this NodeID object's Node. */ public String getName() { return name; } /** Returns a human readable String that * represents this NodeID object. * This will either include the name of the Node, if assigned, or else * a list of the Node's addresses. * * The String returned by this method is only really intended as a * way of supply debugging information to users. The contents is not guaranteed * and should not relied upon by a program. * @return a human readable String. */ public String toString() { if (!name.equals("")) return getDomainID() + "\\Node: " + name; StringBuffer stringToReturn = new StringBuffer(getDomainID() + "\\Node("); for (int i = 0; i < addressIDs.length; i++) stringToReturn.append(addressIDs[i] + ")"); return stringToReturn.toString(); } void setName(String name) { if (name != null) this.name = name; else name = ""; } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { domainID = (DomainID) in.readObject(); nodeUI = (NodeUI) in.readObject(); name = (String) in.readObject(); int numAddresses = in.readInt(); addressIDs = new NodeAddressID[numAddresses]; int unrecCount = 0; for (int i = 0; i < numAddresses; i++) { SerializedObject s = (SerializedObject) in.readObject(); try { NodeAddressID naddID = (NodeAddressID) s.get(); addressIDs[i - unrecCount] = naddID; } catch (ClassNotFoundException e) { unrecCount++; unrecognisedAddressIDs.add(s); //put s into HashSet of addresses which this JVM //does not recognise - means they won't be lost } catch (Exception e) { e.printStackTrace(); } } unrecognisedAddressIDs = new HashSet(); if (unrecCount > 0) { NodeAddressID[] addressIDs = new NodeAddressID[numAddresses - unrecCount]; System.arraycopy(this.addressIDs, 0, addressIDs, 0, addressIDs.length); this.addressIDs = addressIDs; } } catch (Exception e) { e.printStackTrace(); throw new IOException("An error occured during deserialization"); } } private void writeObject(ObjectOutputStream out) throws IOException { synchronized (this) { out.writeObject(domainID); out.writeObject(nodeUI); out.writeObject(name); out.writeInt(addressIDs.length + unrecognisedAddressIDs.size()); for (int i = 0; i < addressIDs.length; i++) { try { out.writeObject(new SerializedObject(addressIDs[i], true)); } catch (Exception e) { //ignored - could print out a message e.printStackTrace(); } } for (Iterator it = unrecognisedAddressIDs.iterator(); it.hasNext(); ) { try { out.writeObject(it.next()); } catch (Exception ex) { //ignored - could print out a message ex.printStackTrace(); } } } } /*----------------------Attributes--------------------------------------------*/ /** * This is a set of addresses of LinkServers that the Node, represented by * this NodeID, is running. */ private NodeAddressID[] addressIDs = new NodeAddressID[0]; /** * This is the set of addresses of LinkServers that the Node, represented by * this NodeID, is running but this JVM does not recognise. The serialized * forms of the addresses are stored here so that */ private HashSet unrecognisedAddressIDs = new HashSet(); /** * The Domain of which the Node represented by this NodeID is a member. */ private DomainID domainID; /** * A unique identifier for this node. */ private NodeUI nodeUI; /** * A name assigned to this Node. */ private String name = ""; }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetChannelOutput.java0000644000000000000000000000642211105701167020036 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; /** *

* An interface that should be implemented by * ChannelOutput objects which are used for transmitting * over the network. *

*

* As well as usefully combining the Networked and * ChannelOutput interfaces, this interface adds a * recreate() that requests the implementing class should * reinitialize itself. *

* * @author Quickstone Technologies Limited */ public interface NetChannelOutput extends ChannelOutput, Networked { /** *

* Requests that the instance of the implementing class should * reinitialize itself. *

*/ public void recreate(); /** *

* Requests that the instance of the implementing class should * reinitialize itself with a new location. *

* * @param newLoc the new location. */ public void recreate(NetChannelLocation newLoc); /** *

* Destroys the channel writer end and frees all the * underlying JCSP.NET resources. *

*/ public void destroyWriter(); /** *

* Returns the factory class used for constructing this channel * end object. *

* * @return the Class of the */ public Class getFactoryClass(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/ChannelMessage.java0000644000000000000000000000576211105701167017461 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * Messages used by channels. * *

This is a package-private implementation class. * @author Quickstone Technologies Limited */ // package-private abstract class ChannelMessage extends Message { /** * Data from channel output to channel input. * *

This is a package-private implementation class. * */ // package-private static final class Data extends ChannelMessage { /** * The actual data being transmitted. * This needs to be Serializable. * * @see java.io.Serializable * * @serial */ Object data; boolean acknowledged = true; //debug code public String toString() { return "MessageData: " + data; } } /** * An acknowledgement. * *

This is a package-private implementation class. * */ // package-private static final class Ack extends ChannelMessage { } static final class WriteRejected extends ChannelMessage { } }jcsp-1.1-rc4.orig/src/org/jcsp/net/AbstractID.java0000644000000000000000000001123011105701167016547 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.Serializable; /** *

This is an abstract class that is sub-classed by classes whose * instances should represent some kind of identifier and be part of a * hierarchy of AbstractID objects.

* *

This class has no public or protected constructor so it may * not be sub-classed by JCSP users. JCSP.NET defines four implementations * of this class; {@link ApplicationID}, * {@link NodeID}, {@link DomainID} * and {@link GlobalID}.

* *

* An ApplicationID object identifies a JCSP application. * A JCSP Application is formed of a process network initiated at a * particular Node, but processes launched on a remote Node may * also be part of the same application. The parent AbstractIDApplicationID objects are NodeID * objects. *

*

* A NodeID object identifies a particular JCSP Node. A * JCSP Node is a Java Virtual Machine that has been initialized * to form part of a JCSP.NET network. The parent AbstractIDNodeID objects are DomainID * objects. *

*

* A DomainID object represents a domain of JCSP Nodes. * Node Domains are not presently implemented but this class is * included for completeness. In the future, it is envisaged that * domain controllers will be introduced. At present, all * NodeID objects have a parent DomainID * equal to the Null Domain (this has a zero length string name). *

*

* A GlobalID object represents the global Node domain. * This includes all domains, their sub-domains, and all Nodes within * sub-domains. There only ever needs to be a single instance of this * class. The parent of the Null Domain is a * GlobalID object. *

* * @author Quickstone Technologies Limited */ public abstract class AbstractID implements Serializable { AbstractID() { } /** * Returns this instance's parent AbstractID object. * * @return the parent AbstractID of this object. */ public abstract AbstractID getParentID(); /** * This tests whether another ID is on the same branch of a * hierachy. Returns true if either the supplied object * is a child (or a child of child etc.) of this object or * if the supplied object is a parent (or a parent of a parent * etc.) of this object. * * @return a boolean indicating whether or not * the supplied object is on the same branch. */ abstract boolean onSameBranch(AbstractID abstractID); }jcsp-1.1-rc4.orig/src/org/jcsp/net/Requirement.java0000644000000000000000000001620011105701167017071 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * * @author Quickstone Technologies Limited. */ class Requirement { Requirement(String name, String specName, String comparator, int intValue) { if(name == null || specName == null || comparator == null || !(comparator.equals(COMPARATOR_EQUALS) || comparator.equals(COMPARATOR_LESS_THAN) || comparator.equals(COMPARATOR_GREATER_THAN))) throw new IllegalArgumentException("Illegal arguments - either null parameter or invalid comparator value"); this.name = name; this.specName = specName; this.comparator = comparator; this.intValue = intValue; this.strValue = ""; this.dblValue = -1; this.booValue = false; type = Integer.TYPE; } Requirement(String name, String specName, String comparator, String strValue) { if(name == null || specName == null || comparator == null || !(comparator.equals(COMPARATOR_EQUALS) || comparator.equals(COMPARATOR_LESS_THAN) || comparator.equals(COMPARATOR_GREATER_THAN))) throw new IllegalArgumentException("Illegal arguments - either null parameter or invalid comparator value"); this.name = name; this.specName = specName; this.comparator = comparator; this.strValue = strValue; this.intValue = -1; this.dblValue = -1; this.booValue = false; type = String.class; } Requirement(String name, String specName, String comparator, double dblValue) { if(name == null || specName == null || comparator == null || !(comparator.equals(COMPARATOR_EQUALS) || comparator.equals(COMPARATOR_LESS_THAN) || comparator.equals(COMPARATOR_GREATER_THAN))) throw new IllegalArgumentException("Illegal arguments - either null parameter or invalid comparator value"); this.name = name; this.specName = specName; this.comparator = comparator; this.dblValue = dblValue; this.intValue = -1; this.strValue = ""; this.booValue = false; type = Double.TYPE; } Requirement(String name, String specName, String comparator, boolean booValue) { if(name == null || specName == null || comparator == null || !(comparator.equals(COMPARATOR_EQUALS) || comparator.equals(COMPARATOR_LESS_THAN) || comparator.equals(COMPARATOR_GREATER_THAN))) throw new IllegalArgumentException("Illegal arguments - either null parameter or invalid comparator value"); this.name = name; this.specName = specName; this.comparator = comparator; this.booValue = booValue; this.intValue = -1; this.strValue = ""; this.dblValue = -1; type = Boolean.TYPE; } public boolean matches(Specification spec) { if(specName.equals(spec.name) && type.equals(spec.type)) { Comparable cThis = null; Comparable cOther = null; if(type.equals(String.class)) { cThis = strValue; cOther = spec.strValue; } else if(type.equals(Integer.TYPE)) { cThis = new Integer(intValue); cOther = new Integer(spec.intValue); } else if(type.equals(Double.TYPE)) { cThis = new Double(dblValue); cOther = new Double(spec.dblValue); } else if(type.equals(Boolean.TYPE)) { cThis = new BooleanComparable(booValue); cOther = new BooleanComparable(spec.booValue); } int comparison = cThis.compareTo(cOther); if(comparator.equals(COMPARATOR_EQUALS) && comparison == 0) return true; else if(comparator.equals(COMPARATOR_LESS_THAN) && comparison > 0) //This object is greater than the other object - i.e. the other //object is less than this object return true; else if(comparator.equals(COMPARATOR_GREATER_THAN) && comparison < 0) //This object is less than the other object - i.e. the other //object is greater than this object return true; } return false; } final Class type; final String name; final String specName; final String comparator; final int intValue; final String strValue; final double dblValue; final boolean booValue; private static final String COMPARATOR_EQUALS = "EQU"; private static final String COMPARATOR_LESS_THAN = "LTH"; private static final String COMPARATOR_GREATER_THAN = "GRT"; private class BooleanComparable implements Comparable { BooleanComparable(boolean val) { this.val = val; } public int compareTo(Object o) { BooleanComparable other = (BooleanComparable) o; if(val == other.val) return 0; else if(other.val == true) return -1; return 1; } private boolean val; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/LinkFactory.java0000644000000000000000000003137211105701167017025 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.util.*; //based upon AbstractFactory /** *

* This class does not need to be used by normal JCSP users. *

*

* The Builder inner class needs to be sub-classed * by JCSP.NET protocol implementations. *

* * @author Quickstone Technologies Limited */ public class LinkFactory { /*-------------------Singleton Class Instance---------------------------------*/ private static LinkFactory instance = new LinkFactory(); /*-------------------Private Constructor--------------------------------------*/ private LinkFactory() { } /*----------------------Methods-----------------------------------------------*/ static LinkFactory getInstance() { return instance; } synchronized Link makeLink(NodeID target, Profile linkProfile) { NodeAddressID[] targetAddressIDs = (NodeAddressID[])target.getAddresses(); Node.info.log(this, "MakeLink " + target + " " + linkProfile); ProtocolComparator protocolComparator = new ProtocolComparator(); Arrays.sort(targetAddressIDs, protocolComparator); //this should contain no duplicates ProtocolID[] txProtocols = getTxProtocols(); Arrays.sort(txProtocols, protocolComparator); ArrayList matchingProtocolAddresses = new ArrayList(); NodeAddressID bestExactMatch = null; int txIndex = 0; int targetRxIndex = 0; Link linkToReturn = null; while (txIndex < txProtocols.length && targetRxIndex < targetAddressIDs.length) { int comparison = protocolComparator.compare(txProtocols[txIndex], targetAddressIDs[targetRxIndex]); if (comparison == 0) { //found some matching tx and rx protocols //check that protocol meets requirements ProtocolID pID = targetAddressIDs[targetRxIndex].getProtocolID(); int specMatch = 0; if (linkProfile != null) specMatch = linkProfile.matches(ProtocolManager.getInstance().getProtocolSpecifications(pID)); if (linkProfile == null || specMatch == 1) { if (bestExactMatch == null) { bestExactMatch = targetAddressIDs[targetRxIndex]; bestExactMatch.getProtocolID().getPosition(); } else if (bestExactMatch.getProtocolID().getPosition() > targetAddressIDs[targetRxIndex].getProtocolID().getPosition()) bestExactMatch = targetAddressIDs[targetRxIndex]; } else if (bestExactMatch == null) matchingProtocolAddresses.add(targetAddressIDs[targetRxIndex]); targetRxIndex++; } else if (comparison < 0) //txProtocol is less txIndex++; else if (comparison > 0) //rx protocol is less targetRxIndex++; } if (bestExactMatch != null) { ProtocolID pID = bestExactMatch.getProtocolID(); Builder builder = (Builder) builders.get(pID); if (builder != null) linkToReturn = builder.testAndBuild(bestExactMatch); } else if ((linkProfile == null || !linkProfile.requiresExactMatch()) && matchingProtocolAddresses.size() > 0) { Collections.sort(matchingProtocolAddresses, new ProtocolPerformanceComparator()); //iterate through the protocols until a Link is built ListIterator li = matchingProtocolAddresses.listIterator(); while (li.hasNext() && linkToReturn == null) { NodeAddressID nadID = (NodeAddressID) li.next(); ProtocolID pID = nadID.getProtocolID(); Builder builder = (Builder) builders.get(pID); if (builder != null) linkToReturn = builder.testAndBuild(nadID); } } if (linkToReturn != null) linkToReturn.setProfile(linkProfile); return linkToReturn; } synchronized Link makeLink(NodeAddressID targetAddress) { if (targetAddress == null) return null; Builder builder = (Builder) builders.get(targetAddress.getProtocolID()); if (builder != null) return builder.testAndBuild(targetAddress); return null; } synchronized boolean installBuilder(Builder builder) { if (builder == null) throw new NullPointerException(); ProtocolID protocolID = builder.getProtocolID(); if (builders.containsKey(protocolID)) return false; builders.put(protocolID, builder); return true; } synchronized boolean removeBuilder(ProtocolID protocolID, Builder builder) { if (protocolID == null) return false; //perform a security check here? if (builders.get(protocolID) == builder) { builders.remove(protocolID); return true; } return false; } /** Used to find out the communication protocols currently installed in the LinkFactory instance. * Returns an array of ProtocolID objects which identify the protocols. * @return an array of ProtocolID objects which identify the currently installed protocols. */ synchronized ProtocolID[] getTxProtocols() { Set tmp = builders.keySet(); return (ProtocolID[]) tmp.toArray(new ProtocolID[tmp.size()]).clone(); } /** An abstract inner class which should be implemented by * comunication protocol implementations. * * The Builder class provides an abstract method which * should be implemented to take a NodeAddressID object * which should be used to construct a Link which is then * returned by the method to the factory. */ public static abstract class Builder { /** A constructor which takes the ProtocolID identifying the * protocol that this Builder supports. This must be called * by sub-classes. * @param protocolID the ProtocolID for the protocol that the implementation supports. */ public Builder(ProtocolID protocolID) { this.protocolID = protocolID; } /** Takes a NodeAddressID and constructs and returns * a Link object. * @param addressID the AddressID for the remote Node. * @throws IllegalArgumentException if the AddressID object is invalid. * @return the constructed Link. */ public abstract Link testAndBuild(NodeAddressID addressID) throws IllegalArgumentException; /** Gets the ProtocolID that this Builder supports. * @return the ProtocolID that this Builder supports. */ public final ProtocolID getProtocolID() { return protocolID; } private final ProtocolID protocolID; } /*----------------------Attributes--------------------------------------------*/ /** * This Hashtable stores ProtocolID's as it keys and map these to * Builders for those Protocols. */ private Hashtable builders = new Hashtable(); /*----------------------Inner Classes-----------------------------------------*/ private static class ProtocolComparator implements Comparator { /** * @param o1 * @param o2 * @return */ public int compare(Object o1, Object o2) { if (o1 instanceof NodeAddressID) { if (o2 instanceof NodeAddressID) return compare((NodeAddressID) o1, (NodeAddressID) o2); else if (o2 instanceof ProtocolID) return compare((NodeAddressID) o1, (ProtocolID) o2); } else if (o1 instanceof ProtocolID) { if (o2 instanceof NodeAddressID) return compare((ProtocolID) o1, (NodeAddressID) o2); else if (o2 instanceof ProtocolID) return compare((ProtocolID) o1, (ProtocolID) o2); } throw new ClassCastException(); } /** * @param naID * @param pID * @return */ public int compare(NodeAddressID naID, ProtocolID pID) { ProtocolID pID1 = naID.getProtocolID(); return compare(pID1, pID); } /** * @param pID * @param naID * @return */ public int compare(ProtocolID pID, NodeAddressID naID) { ProtocolID pID2 = naID.getProtocolID(); return compare(pID, pID2); } /** * @param naID1 * @param naID2 * @return */ public int compare(NodeAddressID naID1, NodeAddressID naID2) { ProtocolID pID1 = naID1.getProtocolID(); ProtocolID pID2 = naID2.getProtocolID(); return compare(pID1, pID2); } /** * @param pID1 * @param pID2 * @return */ public int compare(ProtocolID pID1, ProtocolID pID2) { return pID1.getClass().getName().compareTo(pID2.getClass().getName()); } } private static class ProtocolPerformanceComparator implements Comparator { /** * @param o1 * @param o2 * @return */ public int compare(Object o1, Object o2) { if (o1 instanceof ProtocolID) { if (o2 instanceof ProtocolID) return compare((ProtocolID) o1, (ProtocolID) o2); } throw new ClassCastException(); } /** * @param pID1 * @param pID2 * @return */ public int compare(ProtocolID pID1, ProtocolID pID2) { if (pID1.getPosition() == pID2.getPosition()) return 0; else if (pID1.getPosition() < pID2.getPosition()) return -1; else return 1; } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/0000755000000000000000000000000011410045050015211 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/SpawnerServiceNT.java0000644000000000000000000000574211105701167021277 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.remote; import org.jcsp.win32.*; /** *

Wraps up the SpawnerService as an NT service. To install the service, register the * path java org.jcsp.net.remote.SpawnerServiceNT with the service name * JCSP.NET:SpawnerService.

* * @author Quickstone Technologies Limited */ public class SpawnerServiceNT extends NTService { private SpawnerService svc; /** * Starts the service by calling SpawnerService.main. */ protected void startService() { svc = SpawnerService.construct(new String[0]); svc.run(); // will block } /** * Terminates the spawner. */ protected void stopService() { svc.stop(); } /** * Creates the service instance. */ private SpawnerServiceNT() { super("JCSP.NET:SpawnerService"); } /** * Creates a service instance and sets it running. */ public static void main(String[] args) { new SpawnerServiceNT().run(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/package.html0000644000000000000000000000150110520670125017477 0ustar

Supports the remote spawning of processes at other nodes. A local proxy process strategy is used which attempts to create similar effects to running the process locally. For example the run method of the proxy will not complete until the run of the remote process completes so that a conventional Parallel can be used to synchronize on process termination. Also, any exceptions raised by the remote process will be similarly raised at the local machine.

Refer to the description of RemoteProcess for examples of use. Refer to SpawnerService for details of starting the server process to support the spawning of additional JVMs at a node.

This package is currently in a beta state and the API may be subject to changes.

jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/SpawnerService.java0000644000000000000000000001302511105701167021026 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.remote; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.*; import org.jcsp.net.dynamic.*; import org.jcsp.util.filter.*; /** *

Services requests from RemoteProcess proxies to start up child JVMs running the * actual processes.

* *

If started from the command line, it will use the XML config file specified by the first * command parameter. If no file is given it will try and use JCSPNetSpawnerService.xml to * initialize the local node. Alternatively it can be started programmatically and the caller must * take responsibility for initializing the node.

* * @author Quickstone Technologies Limited */ public class SpawnerService implements CSProcess { /** The node key. */ private final NodeKey nodeKey; /** Termination channel. */ private final One2OneChannel terminate = Channel.one2one(); /** * Constructs a new service. * * @param nodeKey the local node key. */ public SpawnerService(NodeKey nodeKey) { this.nodeKey = nodeKey; } /** Runs the service. */ public void run() { // Create an input channel to accept requests on AltingChannelInput in = NetChannelEnd.createNet2One("controlSignals"); // Put a dynamic class loader in place ServiceManager mgr = Node.getInstance().getServiceManager(nodeKey); if (mgr != null) { Service svc = mgr.getService("dynamic_loading"); if (svc != null) { DynamicClassLoader dcl = (DynamicClassLoader)svc; in = FilteredChannelEnd.createFiltered(in); ((FilteredChannelInput)in).addReadFilter(dcl.getChannelRxFilter()); } } int unique = 0; // Service requests Alternative alt = new Alternative(new Guard[] { terminate.in(), in }); while (true) { try { if (alt.priSelect() == 0) { terminate.in().read(); return; } else { SpawnerMessage msg = (SpawnerMessage)in.read(); if (msg != null) { NetChannelOutput out = NetChannelEnd.createOne2Net(msg.caller); new ProcessManager(new ProcessSpawner(this, msg.process, out, msg.factory, msg.applicationID, unique++, msg.classPath)).start(); } } } catch (Exception e) { e.printStackTrace(); } } } void stop() { terminate.out().write(null); } public static SpawnerService construct(String[] args) { NodeKey nodeKey = null; // Initialize the node try { String configFile = "JCSPNetSpawnerService.xml"; if (args.length > 0) configFile = args[0]; nodeKey = Node.getInstance().init(new XMLNodeFactory(configFile)); } catch (IOException e) { System.err.println("Error reading from config file"); System.exit(1); } catch (NodeInitFailedException e) { System.err.println("Unable to initialize node - aborting"); System.exit(1); } return new SpawnerService(nodeKey); } /** * Program entry point. * * @param args the command line arguments. The first one may be the name of an XML file for * initializing the local node. */ public static void main(String[] args) { construct(args).run(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/JCSPNetSpawnerService.xml0000644000000000000000000000160610522104430022026 0ustar
jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/ChildProcess.java0000644000000000000000000001125511105701167020453 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.remote; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.*; /** *

For use by the infrastructure only.

* *

Process launcher for starting a child JVM. This class should not be used directly. On loading the * process to be started will be retrieved from the main SpawnerService JVM and run. The * .NET node will be initialized using the factory supplied by the spawner. This may be either the * platform's default factory or one supplied to the proxy ChildProcess processes.

* *

The process started should not call System.exit to terminate. If it does a * RemoteProcessFailedException will be raised as an abrupt exit cannot be distinguished * from a .NET infrastructure failure.

* *

If the process raises an exception, this will be forwarded to the caller if possible.

* * @author Quickstone Technologies Limited */ public class ChildProcess { /** * Program entry point. An argument will give the name of a temporary file that contains serialized * representations of the process and other information required to locate the originating host. * * @param args program command line arguments */ public static void main(String[] args) { Throwable eToThrow = null; NetChannelLocation ncl = null; try { NodeFactory nf = null; CSProcess p = null; File f = new File(args[0]); try { ObjectInputStream os = new ObjectInputStream(new FileInputStream(f)); nf = (NodeFactory)os.readObject(); p = (CSProcess)os.readObject(); RemoteProcess.applicationID = (ApplicationID)os.readObject(); ncl = (NetChannelLocation)os.readObject(); os.close(); } finally { f.delete(); } if (nf != null) Node.setNodeFactory(nf); Node.getInstance().init(); p.run(); } catch (Throwable e) { eToThrow = e; } // Try and route the exception back (or send the null for an OK signal) try { NetChannelOutput out = NetChannelEnd.createOne2Net(ncl); out.write(eToThrow); System.exit(0); } catch (Throwable e) { System.err.println("\n"); System.err.println("Unable to route exception back to calling application"); System.err.println("Reason for not being able to route:"); e.printStackTrace(); System.err.println("Exception:"); eToThrow.printStackTrace(); } finally { System.exit(1); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/ProcessSpawner.java0000644000000000000000000004164411111260160021042 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.remote; import java.io.*; import org.jcsp.lang.*; import org.jcsp.util.ints.*; import org.jcsp.net.*; /** * Launches a new JVM to run a process received by this spawner. This process will communicate with the * new JVM, routing any exceptions to the requesting host and also any information printed to the * System.err or System.out streams. * * @author Quickstone Technologies Limited */ class ProcessSpawner implements CSProcess { /** A String follows with a line of text that was for System.out. */ final static int MSG_STDOUT = 0; // string follows /** A String follows with a line of text that was for System.err. */ final static int MSG_STDERR = 1; // string follows /** An Exception follows that was raised by the spawned process. */ final static int MSG_EXCEPTION = 2; // exception follows /** An Exception follows that was raised by the spawned process on failure. */ final static int MSG_FAIL = 4; // exception follows /** The process terminated without error. */ final static int MSG_OK = 5; // nothing follows /** A String follows with a line of text that was for System.out. */ private final static Integer msgSTDOUT = new Integer(MSG_STDOUT); /** A String follows with a line of text that was for System.err. */ private final static Integer msgSTDERR = new Integer(MSG_STDERR); /** An Exception follows that was raised by the spawned process. */ private final static Integer msgEXCEPTION = new Integer(MSG_EXCEPTION); /** An Exception follows that was raised by the spawned process on failure. */ private final static Integer msgFAIL = new Integer(MSG_FAIL); /** The process terminated without error. */ private final static Integer msgOK = new Integer(MSG_OK); /** The parent service that started this one. */ private final SpawnerService service; /** The process that needs to be started. */ private final CSProcess process; /** For sending data back to the calling JVM who is running the RemoteProcess proxy. */ private final NetChannelOutput caller; /** * The factory the child should use to initialize its node or null if the default initialization * should take place. */ private final NodeFactory factory; /** The application identifier of the caller that the child should adopt. */ private final ApplicationID applicationID; /** A unique name generated by the service fo use in creating a temporary file. */ private final String uniqueName; /** * The classpath the spawned JVM should use to get the caller's classes from a networked * filesystem or null if the default classpath should be used. */ private final String classPath; /** * Constructs a new spawner. * * @param service the parent service that is creating this object. * @param process the process that should be run. * @param caller for sending data back to the caller. * @param factory optional factory for initializing the child process' node. * @param applicationID caller's application ID that the child should adopt. * @param unique a unique number allocated by the parent service. * @param classPath classpath specified by the caller process for any classes available from a * networked filesystem. */ public ProcessSpawner(SpawnerService service, CSProcess process, NetChannelOutput caller, NodeFactory factory, ApplicationID applicationID, int unique, String classPath) { this.service = service; this.process = process; this.caller = caller; this.factory = factory; this.applicationID = applicationID; String str = Node.getInstance().getNodeID().toString(); str = str.replace(' ', '_').replace('\\', '_').replace('.', '_').replace(':', '_'); this.uniqueName = str + unique; this.classPath = classPath; } /** * Main process loop. */ public void run() { final Throwable eToThrow[] = new Throwable[] { null }; try { final NetAltingChannelInput _in = NetChannelEnd.createNet2One(); File f = File.createTempFile(uniqueName, "bin"); ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(f)); os.writeObject(factory); os.flush(); os.writeObject(process); os.flush(); os.writeObject(applicationID); os.flush(); os.writeObject(_in.getChannelLocation()); os.close(); // Start the child process Node.info.log(this, "Starting child process " + f.getAbsolutePath()); final Process child; if (classPath == null) child = Runtime.getRuntime().exec(new String[] {"java", ChildProcess.class.getName(), f.getAbsolutePath()}); else child = Runtime.getRuntime().exec(new String[] {"java", "-cp", classPath, ChildProcess.class.getName(), f.getAbsolutePath()}); Node.info.log(this, "Child process " + f.getAbsolutePath() + " started"); // A semaphore for synchronising access to the caller final Any2OneChannelInt semaphore = Channel.any2oneInt(new BufferInt(1)); // Trap the STDOUT and STDERR Parallel par = new Parallel(new CSProcess[] { new CSProcess() { public void run() { try { boolean claimed = false; try { InputStream in = child.getErrorStream(); Reader reader = new InputStreamReader(in); BufferedReader buffReader = new BufferedReader(reader); String line = buffReader.readLine(); while (line != null) { semaphore.out().write(0); claimed = true; caller.write(msgSTDERR); caller.write(line); semaphore.in().read(); claimed = false; line = buffReader.readLine(); } buffReader.close(); } catch (LinkLostException e) { child.destroy(); semaphore.in().read(); } catch (Exception e) { if (!claimed) semaphore.out().write(0); caller.write(msgEXCEPTION); caller.write(e); semaphore.in().read(); } } catch (Exception e) { eToThrow[0] = e; } } }, new CSProcess() { public void run() { // Wait for an exception to be sent from the child, a null to be sent or // the process to terminate without sending either (an error) CSTimer tim = new CSTimer(); Alternative alt = new Alternative(new Guard[] { _in, tim }); while (true) { tim.setAlarm(tim.read() + 2000); if (alt.priSelect() == 0) { eToThrow[0] = (Throwable) _in.read(); try { semaphore.out().write(0); caller.write(null); } catch (Exception e) { child.destroy(); } finally { semaphore.in().read(); } break; } else { try { int ec = child.exitValue(); eToThrow[0] = new RemoteProcessFailedException(ec, process); break; } catch (IllegalThreadStateException e) { } } } } }, new CSProcess() { public void run() { try { boolean claimed = false; try { InputStream in = child.getInputStream(); Reader reader = new InputStreamReader(in); BufferedReader buffReader = new BufferedReader(reader); String line = buffReader.readLine(); while (line != null) { semaphore.out().write(0); claimed = true; caller.write(msgSTDOUT); caller.write(line); semaphore.in().read(); claimed = false; line = buffReader.readLine(); } buffReader.close(); } catch (LinkLostException e) { child.destroy(); semaphore.in().read(); } catch (Exception e) { if (!claimed) semaphore.out().write(0); caller.write(msgEXCEPTION); caller.write(e); semaphore.in().read(); } } catch (Exception e) { eToThrow[0] = e; } } } }); par.run(); par.releaseAllThreads(); // wait for process to terminate Node.info.log(this, "Child process " + f.getAbsolutePath() + " waiting to terminate"); int ec = child.waitFor(); Node.info.log(this, "Child process " + f.getAbsolutePath() + " terminated"); if (ec != 0) if (eToThrow[0] == null) eToThrow[0] = new RemoteProcessFailedException(ec, process); } catch (Exception e) { eToThrow[0] = e; } try { if (eToThrow[0] != null) { caller.write(msgFAIL); caller.write(eToThrow[0]); } else caller.write(msgOK); } finally { caller.destroyWriter(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/SpawnerMessage.java0000644000000000000000000000636711105701167021025 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.remote; import java.io.*; import org.jcsp.lang.*; import org.jcsp.net.*; /** * Message sent from RemoteProcess to SpawnerService listing the details of * the process that should be started and a network channel address for replying on. * * @author Quickstone Technologies Limited */ class SpawnerMessage implements Serializable { public final CSProcess process; public final NetChannelLocation caller; public final NodeFactory factory; public final ApplicationID applicationID; public final String classPath; /** * Constructs a new message. * * @param process the process to be spawned. * @param caller the location of the RemoteProcess's channel for replies. * @param factory the optional factory for initializing the remote node. * @param applicationID the application ID that the remote node should adopt. * @param classPath the class path the remote JVM should use. */ public SpawnerMessage(CSProcess process, NetChannelLocation caller, NodeFactory factory, ApplicationID applicationID, String classPath) { this.process = process; this.caller = caller; this.factory = factory; this.applicationID = applicationID; this.classPath = classPath; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/RemoteProcess.java0000644000000000000000000003052111105701167020660 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.remote; import org.jcsp.lang.*; import org.jcsp.net.*; /** *

A proxy process that runs locally while another process executes on a different node. An instance * is created with a CSProcess and an address of a remote node to execute the process on. * This proxy is itself a CSProcess so can be used in a PAR construct. When * run it will trigger the remote process. The local run will not return until * the remote process has terminated.

* *

A factory can be specified to control how the remote process initializes its Node. * The factory used to initialize the local node should be passed to the remote node so that it will * use the same CNS and configure other services in the same manner. For example, to initialize from * the same XML file:

* *
 *   NodeFactory nf = new XMLNodeFactory ("config.xml");
 *   try {
 *     Node.getInstance ().init (nf);
 *   } catch (NodeNotInitializedException e) {
 *     System.exit (1);
 *   }
 *   NodeAddressID slaveNode1 = new TCPIPAddressID ("123.45.6.78", 6000);
 *   NodeAddressID slaveNode2 = new TCPIPAddressID ("123.45.6.79", 6000);
 *   CSProcess proc1 = ...;
 *   CSProcess proc2 = ...;
 *   new Parallel (new CSProcess[] {
 *     new RemoteProcess (proc1, slaveNode1, nf),
 *     new RemoteProcess (proc2, slaveNode2, nf)
 *   }).run ();
 * 
* *

If the local node has class files that won't be available at the remote node it can specify a * network location for a classpath that the remote node should use to get classes from. Dynamic class * loading is not currently implemented for remote spawning in this release.

* *
 *   NodeAddressID slaveNode1 = new TCPIPAddressID ("123.45.6.78", 6000);
 *   NodeAddressID slaveNode2 = new TCPIPAddressID ("123.45.6.79", 6000);
 *   CSProcess proc1 = ...;
 *   CSProcess proc2 = ...;
 *   new Parallel (new CSProcess[] {
 *     new RemoteProcess (proc1, slaveNode1, "\\\\FileServer\\Packages"),
 *     new RemoteProcess (proc2, slaveNode2, "\\\\FileServer\\Packages")
 *   }).run ();
 * 
* *

The remote process will be started in its own JVM and so this approach is not recommended for many * small processes at the same node. If a number of remote processes are required it is suggested that * a process responsible for creating the others be started remotely. For example:

* *
 *   class WorkerGroup implements CSProcess, Serializable {
 *
 *     private final int numWorkers;
 *     private final NetChannelLocation farmer, harvester;
 *
 *     public WorkerGroup (int numWorkers, NetChannelLocation farmer,
 *                           NetChannelLocation harvester) {
 *       this.numWorkers = numWorkers;
 *     }
 *
 *     public void run () {
 *       CSProcess workers[] = new CSProcess[numWorkers];
 *       for (int i = 0; i < numWorkers; i++) {
 *         workers[i] = new Worker (farmer, harvester);
 *       }
 *       new Parallel (workers).run ();
 *     }
 *   }
 *
 *   NodeAddressID slaveNode1 = new TCPIPAddressID ("123.45.6.78", 6000);
 *   NodeAddressID slaveNode2 = new TCPIPAddressID ("123.45.6.79", 6000);
 *   NetChannelInput workers2farmer    = NetChannelEnd.createNet2One ();
 *   NetChannelInput workers2harvester = NetChannelEnd.createNet2One ();
 *   One2OneChannel farmer2harvester   = Channel.one2one ();
 *   new Parallel (new CSProcess[] {
 *     new Farmer (farmer2harvester.out (), workers2farmer),
 *     new Harvester (farmer2harvester.in (), workers2harvester),
 *     new RemoteProcess (new WorkerGroup (10, workers2farmer.getChannelLocation (),
 *                                         workers2harvester.getChannelLocation ()),
 *                        slaveNode1),
 *     new RemoteProcess (new WorkerGroup (10, workers2farmer.getChannelLocation (),
 *                                         workers2harvester.getChannelLocation ()),
 *                        slaveNode2),
 *   }).run ();
 * 
* *

Using a single RemoteProcess for each remote node is more efficient than using * a RemoteProcess for each of the 10 worker processes at each node.

* *

If a process needs an application ID it should call the static getApplicationID. If * this is the only node running, it will allocate a new ID. If the process running was started * remotely then the application ID of the parent node will be returned.

* * @author Quickstone Technologies Limited */ public class RemoteProcess implements CSProcess { /** The process to be started at the remote end. */ private final CSProcess process; /** The location of the node to start the process at. */ private final NetChannelLocation remoteNode; /** The factory to use for initializing the remote node. */ private final NodeFactory factory; /** The classpath the remote node should use. */ private final String classPath; /** False initialially and then true once this has been run at least once. */ private boolean hasBeenRun = false; /** True if the previous run was okay, false if there was an error of some form. */ private boolean statusOfLastRun = false; /** The application ID returned by getApplicationID. */ static ApplicationID applicationID = null; /** * Returns the application ID. If the caller of this was started as a remote process then the * parent's application ID will be returned. If this is the first node started then a new * application ID is allocated. * * @return the application ID. */ public static synchronized ApplicationID getApplicationID() { if (applicationID == null) applicationID = Node.getInstance().getNewApplicationID(); return applicationID; } /** * Constructs a new proxy. * * @param process the process to launch remotely. * @param remoteNode the node to launch the process on. */ public RemoteProcess(CSProcess process, NodeAddressID remoteNode) { this.process = process; this.remoteNode = new NetChannelLocation(remoteNode, "controlSignals"); this.factory = null; this.classPath = null; } /** * Constructs a new proxy. * * @param process the process to launch remotely. * @param remoteNode the node to launch the process on. * @param nodeFactory the factory to use for initializing the remote node. */ public RemoteProcess(CSProcess process, NodeAddressID remoteNode, NodeFactory factory) { this.process = process; this.remoteNode = new NetChannelLocation(remoteNode, "controlSignals"); this.factory = factory; this.classPath = null; } /** * Constructs a new proxy. * * @param process the process to launch remotely. * @param remoteNode the node to launch the process on. * @param classPath the classpath the remote JVM should use. */ public RemoteProcess(CSProcess process, NodeAddressID remoteNode, String classPath) { this.process = process; this.remoteNode = new NetChannelLocation(remoteNode, "controlSignals"); this.factory = null; this.classPath = classPath; } /** * Constructs a new proxy. * * @param process the process to launch remotely. * @param remoteNode the node to launch the process on. * @param factory the factory to use for initializing the remote node. * @param classPath the classpath the remote JVM should use. */ public RemoteProcess(CSProcess process, NodeAddressID remoteNode, NodeFactory factory, String classPath) { this.process = process; this.remoteNode = new NetChannelLocation(remoteNode, "controlSignals"); this.factory = factory; this.classPath = classPath; } /** *

The main process body. This will communicate with the remote node and send it the information * needed to spawn the remote process. And output from the remote process will be put onto the * system output streams. If the remote process throws an exception this will rethrow the * same exception to the caller.

* *

If there is a problem with the remote process, such as it throwing a checked exception or * error, a RemoteSpawnException will be rethrown which contains the actual exception * from the process.

* * @throws RemoteSpawnException if there was a serious problem with the remote process. * @throws RemoteProcessFailedException if the remote JVM terminated with a non-zero error code. */ public void run() { NetChannelOutput out = NetChannelEnd.createOne2Net(remoteNode); NetAltingChannelInput in = NetChannelEnd.createNet2One(); Node.info.log(this, "Writing spawner message"); out.write(new SpawnerMessage(process, in.getChannelLocation(), factory, getApplicationID(), classPath)); out.destroyWriter(); Node.info.log(this, "Spawner message written"); Throwable eToThrow = null; statusOfLastRun = false; hasBeenRun = false; while (!hasBeenRun) { Integer msg = (Integer) in.read(); if (msg == null) continue; switch (msg.intValue()) { case ProcessSpawner.MSG_STDOUT : System.out.println((String) in.read()); break; case ProcessSpawner.MSG_STDERR : System.err.println((String) in.read()); break; case ProcessSpawner.MSG_EXCEPTION : statusOfLastRun = false; hasBeenRun = true; break; case ProcessSpawner.MSG_FAIL : eToThrow = (Throwable) in.read(); statusOfLastRun = false; hasBeenRun = true; break; case ProcessSpawner.MSG_OK : statusOfLastRun = true; hasBeenRun = true; break; } } if (eToThrow != null) { if (eToThrow instanceof RuntimeException) throw (RuntimeException) eToThrow; else throw new RemoteSpawnException(eToThrow); } } /** Returns false iff the last run generated one or more exceptions. */ public boolean lastRunStatus() { return statusOfLastRun; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/RemoteSpawnException.java0000644000000000000000000000556011105701167022216 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.remote; /** * Wraps up a non-RuntimeException into a runtime exception that can be ignored or caught and * rethrown if required. * * @author Quickstone Technologies Limited */ public class RemoteSpawnException extends RuntimeException { /** The actual exception. */ public final Throwable cause; /** * Constructs a new exception. * * @param cause the actual exception. */ public RemoteSpawnException(Throwable cause) { this.cause = cause; } /** * Rethrows the actual exception. */ public void rethrow() throws Throwable { throw cause; } /** * Prints the stack trace of the actual exception. */ public void printStackTrace() { cause.printStackTrace(); } /** * Returns a string representation of the actual exception. */ public String toString() { return cause.toString(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/remote/RemoteProcessFailedException.java0000644000000000000000000000615011105701167023645 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.remote; import org.jcsp.lang.*; /** * Thrown if a remote process terminates abruptly with a non-zero error code. * * @author Quickstone Technologies Limited */ public class RemoteProcessFailedException extends RuntimeException { /** The error code returned by the process. */ private final int errorCode; /** The offending process. */ private final CSProcess process; /** * Constructs a new exception. * * @param ec the exit code from the remote JVM. * @param proc the process that was running. */ public RemoteProcessFailedException(int ec, CSProcess proc) { errorCode = ec; process = proc; } /** * Returns a string description of the exception. */ public String toString() { return "Remote process '" + process.toString() + "' failed with error code " + errorCode; } /** * Returns the error code of the remote JVM. */ public int getErrorCode() { return errorCode; } /** * Returns the process that was running when the error occurred. */ public CSProcess getFailedProcess() { return process; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NodeInitFailedException.java0000644000000000000000000000437711105701167021302 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * An Exception that is thrown if Node initialization * fails. * * @author Quickstone Technologies Limited */ public class NodeInitFailedException extends Exception { NodeInitFailedException() { super(); } NodeInitFailedException(String msg) { super(msg); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetChannelError.java0000644000000000000000000000517511105701167017633 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* This is an error that is thrown by a Networked * channel if something happens that should never * happen. This can occur if users disobey rules * to do with the number of concurrent processes * that are allowed to access a channel object at * any instant. *

* * @author Quickstone Technologies Limited */ public class NetChannelError extends Error { /** *

* Constructor for NetChannelError. *

*/ public NetChannelError() { super(); } /** *

* Constructor for NetChannelError. *

* @param message */ public NetChannelError(String message) { super(message); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/ServiceManager.java0000644000000000000000000001361111105701167017467 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.util.*; /** *

* An instance of the ServiceManager is created by the Node when * it is initialized. This reference can be obtained from the Node * class. *

*

* The class allows the local Node's services to be installed and started. The * class does not currently allow services to removed. Services can be stopped * by obtaining their reference and stopping them directly. *

* @author Quickstone Technologies Limited */ public class ServiceManager { private Hashtable services = new Hashtable(); /** * Installs a service as specified by its class and a set * of settings. * @param settings the settings for the service. * @param serviceClass the Class object of the class of the service to install. * @return true iff the service has successfully been installed. */ public synchronized boolean installService(ServiceSettings settings, Class serviceClass) { try { Service service = (Service) serviceClass.newInstance(); if (!service.init(settings)) return false; return installService(service, settings.getServiceName()); } catch (Exception e) { Node.err.log(this, e); return false; } } /** * Installs a Service object as a service in this * ServiceManager. The name of the service must be supplied. * @param service the Service object to install. * @param name the name of the service. * @return true iff the service has been successfully installed. */ public boolean installService(Service service, String name) { synchronized (services) { services.put(name, service); } return true; } /** * Starts the service with the specified name. * @param name the name of the service to start. * @return true iff the service has been successfully started. */ public synchronized boolean startService(String name) { Service service = getService(name); if (service != null) return service.start(); return false; } /** *

* This method allows a service that is not running to be * uninstalled. *

*

* A running service can be uninstalled by obtaining the service * reference, calling its stop() method and then * calling this method with the service's name. *

* @param name the name of the service to uninstall. * @return true iff the service has been uninstalled. */ public synchronized boolean uninstallService(String name) { Service service = getService(name); if (!service.isRunning()) { services.remove(name); return true; } return false; } /** *

* Returns the Service object of the service with the specified name. *

* @param name the name of the service * @return the Service object of the service with the specified name. */ public Service getService(String name) { synchronized (services) { return (Service) services.get(name); } } /** * Returns an array containing an array of String objects * which represent the names of the currently installed * services. * * @return an array of String service names. */ public String[] getServiceNames() { synchronized (services) { String[] serviceNames = new String[this.services.size()]; Enumeration en = services.keys(); int i = 0; while (en.hasMoreElements()) { serviceNames[i] = (String) en.nextElement(); i++; } return serviceNames; } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Networked.java0000644000000000000000000000462211105701167016540 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * An interface that should be implemented by any * class that has a Networked channel location or wishes * to expose the location of an underlying channel. * * @author Quickstone Technologies Limited */ public interface Networked { /** * Returns the location of the Networked * ChannelInput. * * @return the NetChannelLocation object. */ public NetChannelLocation getChannelLocation(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/config.xml0000644000000000000000000000236610520670125015724 0ustar
jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/0000755000000000000000000000000011410045050014501 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/LocationNotCNSRegisterable.java0000644000000000000000000000430311105701167022503 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; /** * This class should be implemented by NetChannelLocation objects * which do not want to allow themselves to be registered with the * Channel Name Server. * * @author Quickstone Technologies Limited */ public interface LocationNotCNSRegisterable { }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/NamedChannelEndFactory.java0000644000000000000000000001452111105701167021654 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import org.jcsp.net.*; /** *

* Classes implementing this interface act as factories for constructing * NetChannelInput and NetChannelOutput objects. *

*

* NetChannelInput objects are constructed and have their * location registered with a channel naming service. *

*

* NetChannelOutput objects are constructed and connected * to NetChannelInput objects whose location is resolved from * a channel naming service. *

* * @author Quickstone Technologies Limited */ public interface NamedChannelEndFactory { /** * Constructs a NetAltingChannelInput object and * registers its location with the supplied name in the global namespace * of a channel naming service. * * @param name the name against which to register the channel. * * @return the constructed NetAltingChannelInput object. */ public NetAltingChannelInput createNet2One(String name); /** * Constructs a NetAltingChannelInput object and * registers its location with the supplied name in specified * namespace of a channel naming service. * * @param name the name against which to register the channel. * @param nameAccessLevel the namespace in which to register the name. * * @return the constructed NetAltingChannelInput object. */ public NetAltingChannelInput createNet2One(String name, NameAccessLevel nameAccessLevel); /** * Constructs a NetSharedChannelInput object and * registers its location with the supplied name in the global namespace * of a channel naming service. * * @param name the name against which to register the channel. * * @return the constructed NetSharedChannelInput object. */ public NetSharedChannelInput createNet2Any(String name); /** * Constructs a NetSharedChannelInput object and * registers its location with the supplied name in specified * namespace of a channel naming service. * * @param name the name against which to register the channel. * @param nameAccessLevel the namespace in which to register the name. * * @return the constructed NetSharedChannelInput object. */ public NetSharedChannelInput createNet2Any(String name, NameAccessLevel nameAccessLevel); /** * Constructs a NetChannelOutput object connected * to a NetChannelInput located at a location * resolved from the specified channel name. * * @param name the name of the channel from which to resolve the location. * * @return the constructed NetChannelOutput object. */ public NetChannelOutput createOne2Net(String name); /** * Constructs a NetChannelOutput object connected * to a NetChannelInput located at a location * resolved from the specified channel name that exists in the supplied * namespace. * * @param name the name of the channel from which to resolve the location. * @param accessLevel the namespace in which the channel name exists. * * @return the constructed NetChannelOutput object. */ public NetChannelOutput createOne2Net(String name, NameAccessLevel accessLevel); /** * Constructs a NetSharedChannelOutput object connected * to a NetChannelInput located at a location * resolved from the specified channel name. * * @param name the name of the channel from which to resolve the location. * * @return the constructed NetChannelOutput object. */ public NetSharedChannelOutput createAny2Net(String name); /** * Constructs a NetSharedChannelOutput object connected * to a NetChannelInput located at a location * resolved from the specified channel name that exists in the supplied * namespace. * * @param name the name of the channel from which to resolve the location. * @param accessLevel the namespace in which the channel name exists. * * @return the constructed NetChannelOutput object. */ public NetSharedChannelOutput createAny2Net(String name, NameAccessLevel accessLevel); }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/CNSChannelEndManager.java0000644000000000000000000003235611105701167021224 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import org.jcsp.net.*; import java.util.*; /** * This class implements the NamedChannelEndManager interface; * providing methods for both constructing and destroying channels. * * This implementation uses the standard Channel Name Server. Instances * interact with a local CNSService through the use of a * CNSUser object. The default constructor assumes the use * of the default CNS service and obtains the reference itself. The * constructor which takes a CNSUser object allows the use of * an alternative CNS service. A CNSUser object can be * obtained by calling a CNSService object's * getUserObject() method * ({@link org.jcsp.net.cns.CNSService#getUserObject()}). * * For further information see * {@link org.jcsp.net.cns.NamedChannelEndFactory}. * * @see org.jcsp.net.cns.NamedChannelEndFactory * @see org.jcsp.net.cns.NamedChannelEndManager * @see org.jcsp.net.cns.CNSService * * * @author Quickstone Technologies Limited */ public class CNSChannelEndManager implements NamedChannelEndManager { private Hashtable channelInputRegistrations = new Hashtable(); private Hashtable channelOutputsCreated = new Hashtable(); private CNSUser cnsUser; private NetChannelEndFactory factoryToUse; /** * Constructor for CNSChannelEndManager. */ public CNSChannelEndManager() { super(); factoryToUse = StandardNetChannelEndFactory.getDefaultInstance(); if (CNSService.staticServiceRef != null) this.cnsUser = (CNSUser)CNSService.staticServiceRef.getUserObject(); } public CNSChannelEndManager(CNSUser cnsUser) { super(); factoryToUse = StandardNetChannelEndFactory.getDefaultInstance(); this.cnsUser = cnsUser; } private void checkCnsService() { if (this.cnsUser == null) { if (CNSService.staticServiceRef != null) this.cnsUser = (CNSUser)CNSService.staticServiceRef.getUserObject(); if (this.cnsUser == null) throw new NullPointerException("CNS service to use is null."); } } /** * Constructs a NetAltingChannelInput object and * registers its location with the supplied name in the global namespace * of a channel naming service. * * @param name the name against which to register the channel. * * @return the constructed NetAltingChannelInput object. * * @see org.jcsp.net.cns.NamedChannelEndFactory#createNet2One(String) */ public NetAltingChannelInput createNet2One(String name) { return createNet2One(name, null); } /** * Constructs a NetAltingChannelInput object and * registers its location with the supplied name in specified * namespace of a channel naming service. * * @param name the name against which to register the channel. * @param nameAccessLevel the namespace in which to register the name. * * @return the constructed NetAltingChannelInput object. * * @see org.jcsp.net.cns.NamedChannelEndFactory#createNet2One(String, NameAccessLevel) */ public NetAltingChannelInput createNet2One(String name, NameAccessLevel nameAccessLevel) { NetAltingChannelInput chanIn = factoryToUse.createNet2One(); checkCnsService(); ChannelNameKey key = (nameAccessLevel != null) ? cnsUser.register(chanIn, name, nameAccessLevel) : cnsUser.register(chanIn, name); ChannelRegistration cr = new ChannelRegistration(name, nameAccessLevel, key); channelInputRegistrations.put(chanIn, cr); return chanIn; } /** * Constructs a NetSharedChannelInput object and * registers its location with the supplied name in the global namespace * of a channel naming service. * * @param name the name against which to register the channel. * * @return the constructed NetSharedChannelInput object. * * @see org.jcsp.net.cns.NamedChannelEndFactory#createNet2Any(String) */ public NetSharedChannelInput createNet2Any(String name) { return createNet2Any(name, null); } /** * Constructs a NetSharedChannelInput object and * registers its location with the supplied name in specified * namespace of a channel naming service. * * @param name the name against which to register the channel. * @param nameAccessLevel the namespace in which to register the name. * * @return the constructed NetSharedChannelInput object. * * @see org.jcsp.net.cns.NamedChannelEndFactory#createNet2Any(String, NameAccessLevel) */ public NetSharedChannelInput createNet2Any(String name, NameAccessLevel nameAccessLevel) { NetSharedChannelInput chanIn = factoryToUse.createNet2Any(); checkCnsService(); ChannelNameKey key = (nameAccessLevel != null) ? cnsUser.register(chanIn, name, nameAccessLevel) : cnsUser.register(chanIn, name); ChannelRegistration cr = new ChannelRegistration(name, nameAccessLevel, key); channelInputRegistrations.put(chanIn, cr); return chanIn; } /** * Constructs a NetChannelOutput object connected * to a NetChannelInput located at a location * resolved from the specified channel name. * * @param name the name of the channel from which to resolve the location. * * @return the constructed NetChannelOutput object. * * @see org.jcsp.net.cns.NamedChannelEndFactory#createOne2Net(String) */ public NetChannelOutput createOne2Net(String name) { return createOne2Net(name, null); } /** * Constructs a NetChannelOutput object connected * to a NetChannelInput located at a location * resolved from the specified channel name that exists in the supplied * namespace. * * @param name the name of the channel from which to resolve the location. * @param accessLevel the namespace in which the channel name exists. * * @return the constructed NetChannelOutput object. * * @see org.jcsp.net.cns.NamedChannelEndFactory#createOne2Net(String, NameAccessLevel) */ public NetChannelOutput createOne2Net(String name, NameAccessLevel accessLevel) { checkCnsService(); NetChannelOutput chanOut = factoryToUse.createOne2Net(cnsUser.resolve(name, accessLevel)); //never use the value for 2Net channels but it must not be null channelOutputsCreated.put(chanOut, this); return chanOut; } /** * Constructs a NetSharedChannelOutput object connected * to a NetChannelInput located at a location * resolved from the specified channel name. * * @param name the name of the channel from which to resolve the location. * * @return the constructed NetChannelOutput object. * * @see org.jcsp.net.cns.NamedChannelEndFactory#createAny2Net(String) * */ public NetSharedChannelOutput createAny2Net(String name) { return createAny2Net(name, null); } /** * Constructs a NetSharedChannelOutput object connected * to a NetChannelInput located at a location * resolved from the specified channel name that exists in the supplied * namespace. * * @param name the name of the channel from which to resolve the location. * @param accessLevel the namespace in which the channel name exists. * * @return the constructed NetChannelOutput object. * * @see org.jcsp.net.cns.NamedChannelEndFactory#createAny2Net(String, NameAccessLevel) */ public NetSharedChannelOutput createAny2Net(String name, NameAccessLevel accessLevel) { checkCnsService(); NetSharedChannelOutput chanOut = factoryToUse.createAny2Net(cnsUser.resolve(name, accessLevel)); channelOutputsCreated.put(chanOut, this); return chanOut; } /** * Destroys an individual NetChannelInput object * that was constructed with this instance. This will deregister * the channel name and destroy the channel end. * * @param chanInEnd the channel end to destroy. * @see org.jcsp.net.cns.NamedChannelEndManager#destroyChannelEnd(NetChannelInput) */ public void destroyChannelEnd(NetChannelInput chanInEnd) { ChannelRegistration registration = (ChannelRegistration) channelInputRegistrations.remove(chanInEnd); if (registration != null) { //channel must have been in the collection so ok //to deregister it from the CNS chanInEnd.destroyReader(); checkCnsService(); cnsUser.deregisterChannelName(registration.name, registration.accessLevel, registration.key); } else { //channel was not created by this factory throw new WrongFactoryException("Channel End was not created by this factory"); } } /** * Destroys an individual NetChannelOutput object * that was constructed with this instance. This will simply * destroy the channel end. * * @param chanInEnd the channel end to destroy. * @see org.jcsp.net.cns.NamedChannelEndManager#destroyChannelEnd(NetChannelOutput) */ public void destroyChannelEnd(NetChannelOutput chanOutEnd) { if (channelOutputsCreated.remove(chanOutEnd) != null) //channel was in the HashTable chanOutEnd.destroyWriter(); else //channel was not created by this factory throw new WrongFactoryException("Channel End was not created by this factory"); } /** * Destroys all channel ends constructed with this instance * of the factory. * @see o.jcsp.net.cns.NamedChannelEndManager#destroyAllChannelEnds() */ public void destroyAllChannelEnds() { NetChannelInput[] inputChans = new NetChannelInput[channelInputRegistrations.size()]; NetChannelOutput[] outputChans = new NetChannelOutput[channelOutputsCreated.size()]; Enumeration keys = channelInputRegistrations.keys(); int i=0; while (keys.hasMoreElements()) { inputChans[i] = (NetChannelInput) keys.nextElement(); i++; } keys = channelOutputsCreated.keys(); i=0; while (keys.hasMoreElements()) { outputChans[i] = (NetChannelOutput)keys.nextElement(); i++; } //code for destroying channels for (i=0; iAbstractID objects (currently including * {@link org.jcsp.net.ApplicationID}, * {@link org.jcsp.net.NodeID}, * {@link org.jcsp.net.DomainID} and * {@link org.jcsp.net.GlobalID} * ). An AbstractID object can have a single parent * AbstractID object. This allows a tree-like hierarchy * to be formed which in turn allows a name space hierarchy. *

*

* For example, two ApplicationID objects, A and B, may each * have a parent NodeID Z. The namespaces created around * A and B will each be a superset of the namespace of Z. Channels registered * in Z's namespace can be resolved in either A's or B's namespace. A channel * registered in A's namespace may neither be resolved in Z's namespace nor * B's. *

* * @author Quickstone Technologies Limited */ public final class NameAccessLevel implements Serializable { /*------------Attributes-----------------------------------------------------*/ private final AbstractID abstractID; /** * The NameAccessLevel for the global namespace. */ public static final NameAccessLevel GLOBAL_ACCESS_LEVEL = new NameAccessLevel(GlobalID.instance); /*------------Constructor----------------------------------------------------*/ /** *

* Constructor which takes an AbstractID to use * for identifying the namespace. * */ public NameAccessLevel(AbstractID abstractID) { this.abstractID = abstractID; } /*------------Methods overriden from Object----------------------------------*/ /** * Compares an object with this object. * * @return ture iff the other object is a * NameAccessLevel object which has an * equal underlying AbstractID. * * @see org.jcsp.net.AbstractID */ public boolean equals(Object o) { if(o == null || !(o instanceof NameAccessLevel)) return false; NameAccessLevel other = (NameAccessLevel) o; return abstractID.equals(other.abstractID); } /** * Returns a hash code for this object obeying the standard rules * for a hash code. * * @see java.lang.Object#hashCode() */ public int hashCode() { return abstractID.hashCode(); } /** * Returns a string representation of this object. * * @return a human readable string. */ public String toString() { return abstractID.toString(); } /*------------Package level methods------------------------------------------*/ /** * Accessor for the underlying AbstractID object. * * @return the underlying AbstractID. */ AbstractID getLevelAbstractID() { return abstractID; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/CNSUser.java0000644000000000000000000002670511105701167016651 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import org.jcsp.net.*; /** * Interface that a class can implement to indicate that instances allow * channel names within a naming service to be managed. * * @see CNSService * @see CNSService#getUserObject() * * @author Quickstone Technologies Limited */ public interface CNSUser { /** *

* This method resolves a channel name into a * NetChannelLocation object. The name should be * assumed to be in the global name space (see * {@link NameAccessLevel#GLOBAL_ACCESS_LEVEL}). *

* * @param name the name of channel to resolve. * @return the location to which the name resolved. */ public NetChannelLocation resolve(String name); /** *

* This method resolves a channel name into a * NetChannelLocation object. The name must * exist in the specified name space. *

*

* The name space is specified by passing in a * {@link NameAccessLevel} object. A name space * includes itself and any name space higher up in the * hierarchy. The global name space is the highest level of * name space. *

* @param name the name of channel to resolve. * @param accessLevel the name space in which to resolve * the channel name. * @return the location to which the name resolved. */ public NetChannelLocation resolve(String name, NameAccessLevel accessLevel); /** *

* This method allows a channel (or any instance of a class implementing * {@link Networked}) to be registered with a Naming * Service Implementation. The name will be registered in the * global name space. *

* @param owner the Networked object whose location * should be registered. * @param name the name against which to register the channel. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. */ public ChannelNameKey register(Networked owner, String name); /** *

* This method allows a channel (or any instance of a class implementing * {@link Networked}) to be registered with a Naming Service * Implementation. *

*

* The name will be registered in the specified name space. This is * specified by passing in a {@link NameAccessLevel} object. *

* @param owner the Networked object whose location * should be registered. * @param name the name against which to register the channel. * @param accessLevel the name space in which to register the channel name. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. * * @see NameAccessLevel */ public ChannelNameKey register(Networked owner, String name, NameAccessLevel accessLevel); /** *

* This method allows a channel (or any instance of a class implementing * {@link Networked}) that has previously been registered * with the to be reregistered with a Naming Service implementation. * The name should have been leased (see * {@link #leaseChannelName(String, NameAccessLevel, ChannelNameKey)} * ). It is necessaray to supply the key that was obtained when * the name was leased. If the channel name has not previously been * registered, then the key can be specified as null. *

*

* The name will be registered in the in the global name space. *

* @param owner the Networked object whose location * should be registered. * @param name the name against which to register the channel. * @param accessLevel the name space in which to register the channel name. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. */ public ChannelNameKey register(Networked owner, String name, ChannelNameKey key); /** *

* This method allows a channel (or any instance of a class implementing * {@link Networked}) that has previously been registered * to be reregistered with the Naming Service implementation. The name * should have been leased (see * {@link #leaseChannelName(String, NameAccessLevel, ChannelNameKey)} * ). It is necessaray to supply the key that was obtained when * the name was leased. If the channel name has not previously been * registered, then the key can be specified as null. *

*

* The name will be registered in the specified name space. This is * specified by passing in a {@link NameAccessLevel} object. *

* * @param owner the Networked object whose location * should be registered. * @param name the name against which to register the channel. * @param accessLevel the name space in which to register the channel name. * @param key the ChannelNameKey returned when the * name was leased. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. * @see NameAccessLevel */ public ChannelNameKey register(Networked owner, String name, NameAccessLevel accessLevel, ChannelNameKey key); /** *

* This method allows a channel's location to be registered against a * name in the Naming Service implementation. It differs from the other * register methods in that it takes a NetChannelLocation * object instead of a Networked object. This can be obtained * from a Networked object by invoking its * getChannelLocation() method (see * {@link Networked#getChannelLocation()}). *

*

* The name will be registered in the specified name space. This is * specified by passing in a {@link NameAccessLevel} object. *

* This method also allows a leased channel name to be registered against * an actual location (see * {@link #register(Networked, String, NameAccessLevel, ChannelNameKey)} * ). *

* * @param ownerLocation the location of a channel to be registered * against the name. * @param name the name against which to register the channel. * @param accessLevel the name space in which to register the channel name. * @param key the ChannelNameKey returned when the * name was leased. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. * * @see #register(Networked, String, NameAccessLevel, ChannelNameKey) * @see NameAccessLevel */ public ChannelNameKey register(NetChannelLocation ownerLocation, String name, NameAccessLevel accessLevel,ChannelNameKey key); /** *

* Leases the channel name within the specified name space * from the Naming Service Implemenation. Once a name has been leased, * a channel cannot be registered with that name without supplying * the key returned by the call to this method. *

*

* Depending on the implementation, leases may expire, however, they * may be renew by recalling this mehtod. Leases * can be given up by deregistering the name. Leases should remain even * after the obtaining Node has shut down. This allows a channel to move * its registered location to another channel on a different Node. There * should be no danger of another party managing to obtain the name as * transfering a registered name into a lease should be an atomic action. * * @param name the name to lease. * @param accessLevel the name space in which to lease the name. * @param channelKey the key to use if the name is currently * registered or leased. * * @return a new ChannelNameKey needed for managing the * lease or null if leasing failed. * * @throws ChannelNameException if the channel name is invalid. * @throws NameAccessLevelException if the specifed name space is * invalid. * */ public ChannelNameKey leaseChannelName(String name, NameAccessLevel accessLevel, ChannelNameKey channelKey) throws ChannelNameException, NameAccessLevelException; /** *

* This deregisters a registered or leased Channel name from the * Naming Service implementation. * A boolean is returned to indicate whether deregistration was successful. *

* * @param name the name of the channel as a String. * @param nameAccessLevel the nameAccessLevel of the channel. * @param channelKey the ChannelNameKey to use to deregister the * Channel name. * * @return a boolean indicating success. */ public boolean deregisterChannelName(String name, NameAccessLevel accessLevel, ChannelNameKey channelKey); }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/package.html0000644000000000000000000000147511077376055017016 0ustar

This package contains the files specifically for the JCSP.NET Channel Name Service (CNS). A CNS provides a broker service, enabling distributed JCSP processes to set up communications with each other. Networked channels have names. Currently, networked channels are automatically Any-One. The reading process is responsible for creating the channel and (optionally) registering it with a CNS with some unique (to the CNS) name. Writing processes need to know (or be told) the name of a networked channel to connect to it by the CNS. Communications between networked writers and reader then proceed directly (independent from the CNS).

See {@link org.jcsp.net.cns.CNS} and {@link org.jcsp.net.cns.CNSService} for information on the service.

jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/NamedChannelEndManager.java0000644000000000000000000000741411105701167021622 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import org.jcsp.net.*; /** *

* Classes implementing this interface act as factories for constructing * NetChannelInput and NetChannelOutput objects * (see {@link NamedChannelEndFactory}). *

*

* They also supply methods for destroying the channel ends created, either * an individual end or all constructed so far. The later provides a convenient * way for a releasing all org.jcsp.net resources used by a process network. An * instance of an implementing class could be passed as parameter around a * process network and used to construct all channels. Once the network has * terminated the rousources can be released by calling * {@link #destroyAllChannelEnds()}. *

*

* If an attempt is made to destroy a channel end that was not constructed * by the instance of this class that was invoked, then a * WrongFactoryException should be thrown. *

* @author Quickstone Technologies Limited */ public interface NamedChannelEndManager extends NamedChannelEndFactory { /** * Destroys an individual NetChannelInput object * that was constructed with this instance. This will deregister * the channel name and destroy the channel end. * * @param chanInEnd the channel end to destroy. */ public void destroyChannelEnd(NetChannelInput chanInEnd); /** * Destroys an individual NetChannelOutput object * that was constructed with this instance. This will simply * destroy the channel end. * * @param chanOutEnd the channel end to destroy. */ public void destroyChannelEnd(NetChannelOutput chanOutEnd); /** * Destroys all channel ends constructed with this instance * of the factory. */ public void destroyAllChannelEnds(); } jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/CNSService.java0000644000000000000000000013733711105701167017337 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import java.util.*; import org.jcsp.lang.*; import org.jcsp.net.*; import org.jcsp.util.Buffer; /** *

* This class is the Channel Name Server's main client process class. *

*

* One instance of this class needs to be instantiated at each Node wishing * to interact with a Channel Name Server. *

*

* At present only one instance of this service class should be installed at * each Node, however, it is envisaged that it may be desirable to be able to * use multiple Channel Name servers. This functionality has been partially * implemented and eventually multiple instances of this service will be able * to be installed. Each instance would be given a separate name. *

*

* A default instance of this class can be held. Interaction with this * default instance is facilitated through the static methods of * the {@link CNS} class. *

*

* Once constructed, an instance of the object can be installed into the * Node's service manager in the same way as any other Service * (see {@link org.jcsp.net.ServiceManager}). * Alternatively, the one of the static install methods may be used * (see {@link CNSService#install(NodeKey, NodeAddressID)}, * {@link CNSService#install(NodeKey, NodeAddressID, String)}). *

* * @see CNS * * @author Quickstone Technologies Limited */ public class CNSService implements Service, CNSUser { /*---------------Private fields----------------------------------------------*/ private final int RX_BUFFER_SIZE = 30; private NetChannelLocation cnsChannelLocation = null; private NetAltingChannelInput fromCNS = null; private NetChannelOutput toCNS = null; private boolean running = false; private Object processStatusChanging = new Object(); /** * Channels used to send requests to the service process * */ private final Any2OneChannel resolveRequestChan = Channel.any2one(); private final AltingChannelInput resolveRequestChanIn; private final SharedChannelOutput resolveRequestChanOut; private final Any2OneChannel registerRequestChan = Channel.any2one(); private final AltingChannelInput registerRequestChanIn; private final SharedChannelOutput registerRequestChanOut; private final Any2OneChannel deregisterRequestChan = Channel.any2one(); private final AltingChannelInput deregisterRequestChanIn; private final SharedChannelOutput deregisterRequestChanOut; private final Any2OneChannel leaseRequestChan = Channel.any2one(); private final AltingChannelInput leaseRequestChanIn; private final SharedChannelOutput leaseRequestChanOut; /** * Channels used to get replies from the service process * */ private final One2OneChannel registerReplyChan = Channel.one2one(); private final AltingChannelInput registerReplyChanIn; private final ChannelOutput registerReplyChanOut; private final One2OneChannel deregisterReplyChan = Channel.one2one(); private final AltingChannelInput deregisterReplyChanIn; private final ChannelOutput deregisterReplyChanOut; private final One2OneChannel leaseReplyChan = Channel.one2one(); private final AltingChannelInput leaseReplyChanIn; private final ChannelOutput leaseReplyChanOut; private final Any2OneChannel stopChan = Channel.any2one(); /** * List of all pending resolve requests. */ private Hashtable pendingResolves = new Hashtable(); private boolean initialized = false; private boolean holdStaticRef = true; private String cnsServiceName = CNS_DEFAULT_SERVICE_NAME; private final CNSService outerObject = this; private final UserObject userProxy = new UserObject(); /*---------------Public constants--------------------------------------------*/ /** * Constant specifying the setting name for CNS address. */ public static final String CNS_SETTING_NAME_ADDRESS = "cns_address"; /** * Constant specifying the setting name for setting the service * name. */ public static final String CNS_SETTING_NAME_SERVICE_NAME = "cns_service_name"; /** * Constant specifying the setting name for server's admin channel. */ public static final String CNS_SETTING_NAME_ADMIN_CHANNEL_LABEL = "admin_chan_label"; /** * Constant specifying the default name of this service. */ public static final String CNS_DEFAULT_SERVICE_NAME = "org.jcsp.net.cns.CNSService - The CNS."; /*---------------Private/Package static fields-------------------------------*/ /** * Reference used by static methods of CNS class. * */ static CNSService staticServiceRef = null; /** * Object used for synchronizing around staticServiceRef. * */ private static Object staticSync = new Object(); /*---------------Constructors------------------------------------------------*/ /** *

* Default constructor that does not supply any of the necessary settings * for initializing the CNS. The init(ServiceSettings) method * must be called if this constructor is used. *

*/ public CNSService() { holdStaticRef = true; //Request channels resolveRequestChanIn = resolveRequestChan.in(); resolveRequestChanOut = resolveRequestChan.out(); registerRequestChanIn = registerRequestChan.in(); registerRequestChanOut = registerRequestChan.out(); deregisterRequestChanIn = deregisterRequestChan.in(); deregisterRequestChanOut = deregisterRequestChan.out(); leaseRequestChanIn = leaseRequestChan.in(); leaseRequestChanOut = leaseRequestChan.out(); //leaseRequestChanIn registerReplyChanIn = registerReplyChan.in(); registerReplyChanOut = registerReplyChan.out(); deregisterReplyChanIn = deregisterReplyChan.in(); deregisterReplyChanOut = deregisterReplyChan.out(); leaseReplyChanIn = leaseReplyChan.in(); leaseReplyChanOut = leaseReplyChan.out(); } /** *

* Constructor which takes an address of the Node hosting * the Channel Name Server. *

*

* In order to connect to the Channel Name Server, this service * must know the label of the server's admin channel. By default this * is given the value of the CNS.CNS_CHANNEL_LABEL constant. * This constructor assumes that this label has been used. It is equivalent * to calling the constructor which takes * (NodeAddressID, String) parameters. *

* @see #CNSService(NodeAddressID,String) * * @param cnsAddress the address of channel name server to use. */ public CNSService(NodeAddressID cnsAddress) { this(cnsAddress, CNS.CNS_CHANNEL_LABEL); } /** *

* Constructor which takes an address of the Node hosting * the Channel Name Server as well as a boolean * indicating whether or not the service should be started. *

*

* In order to connect to the Channel Name Server, this service * must know the label of the server's admin channel. By default this * is given the value of the CNS.CNS_CHANNEL_LABEL constant. * This constructor assumes that this label has been used. It is * equivalent to calling the constructor which takes * (NodeAddressID, String,boolean) parameters. *

* * @param cnsAddress the address of channel name server to use. * @param start indicates whether the service should be started. * Should be true to start service. * * @see #CNSService(NodeAddressID,String,boolean) */ public CNSService(NodeAddressID cnsAddress, boolean start) { this(cnsAddress, CNS.CNS_CHANNEL_LABEL, start); } /** *

* Constructor which takes an address of the Node hosting * the Channel Name Server as well as the label of the Channel * Name Server's admin channel. *

*

* This is equivalent to using the construtor with * (NodeAddressID, String, boolean) parameters with the * boolean equal to false. *

* * @param cnsAddress the address of channel name server to use. * @param adminChannelLabel the label of server's admin channel. * * @see #CNSService(NodeAddressID,String,boolean) * */ public CNSService(NodeAddressID cnsAddress, String adminChannelLabel) { this(cnsAddress, adminChannelLabel, false); } /** *

* Constructor which takes an address of the Node hosting * the Channel Name Server, the label of the Channel * Name Server's admin channel and a boolean indicating * whether the service should be started. *

*

* If the service is started, there is no need to initialize and start * the service separately. *

* * @param cnsAddress the address of channel name server to use. * @param adminChannelLabel the label of server's admin channel. * @param start indicates whether the service should be started. * Should be true to start service. * * @see org.jcsp.net.NodeAddressID */ public CNSService(NodeAddressID cnsAddress, String adminChannelLabel, boolean start) { cnsChannelLocation = new NetChannelLocation(cnsAddress, adminChannelLabel); holdStaticRef = true; //Request channels resolveRequestChanIn = resolveRequestChan.in(); resolveRequestChanOut = resolveRequestChan.out(); registerRequestChanIn = registerRequestChan.in(); registerRequestChanOut = registerRequestChan.out(); deregisterRequestChanIn = deregisterRequestChan.in(); deregisterRequestChanOut = deregisterRequestChan.out(); leaseRequestChanIn = leaseRequestChan.in(); leaseRequestChanOut = leaseRequestChan.out(); //leaseRequestChanIn registerReplyChanIn = registerReplyChan.in(); registerReplyChanOut = registerReplyChan.out(); deregisterReplyChanIn = deregisterReplyChan.in(); deregisterReplyChanOut = deregisterReplyChan.out(); leaseReplyChanIn = leaseReplyChan.in(); leaseReplyChanOut = leaseReplyChan.out(); //if want to initialize, then initialize if (start) { if (init(null)) { if (!start()) { cnsChannelLocation = null; throw new RuntimeException("Failed to start CNS."); } } else { cnsChannelLocation = null; throw new RuntimeException("Failed to init CNS."); } } } /*-----------Concrete Implementations of Methods Service---------------------*/ /** *

* Initializes the this instance of the CNSService. *

*

* If the default constructor was used to construct the instance of this * class, then a name of the instance must be supplied along with at * least one address of a channel name server. The admin channel label of * the server may also be supplied. The keys to use in the * ServiceSettings are held as constants in this class * ({@link #CNS_SETTING_NAME_ADDRESS}, * {@link #CNS_SETTING_NAME_SERVICE_NAME}, * {@link #CNS_SETTING_NAME_ADMIN_CHANNEL_LABEL}). *

*

* This need only be called if the no-arg constructor is used. *

* * @param settings A * {@link org.jcsp.net.ServiceSettings} * object that holds the * settings for this service. * * @return true if this request to initialize the service * succeeds. * */ public boolean init(ServiceSettings settings) { synchronized (processStatusChanging) { fromCNS = NetChannelEnd.createNet2One(new Buffer(RX_BUFFER_SIZE)); CNSMessage.LogonMessage logonMsg = new CNSMessage.LogonMessage(); logonMsg.replyLocation = fromCNS.getChannelLocation(); String serviceName = (settings != null) ? settings.getSetting(CNS_SETTING_NAME_SERVICE_NAME) : null; if (serviceName != null) this.cnsServiceName = serviceName; if (cnsChannelLocation == null) { //construct from the settings object //get the channel label of CNS Server's admin channel String adminChannelLabel = settings.getSetting(CNS_SETTING_NAME_ADMIN_CHANNEL_LABEL); //if no label supplied, use default if (adminChannelLabel == null) adminChannelLabel = CNS.CNS_CHANNEL_LABEL; //Get the list of addresses to try and use to connect to the CNS NodeAddressID[] possibleAddresses = settings.getAddresses(CNS_SETTING_NAME_ADDRESS); for (int i = 0; i < possibleAddresses.length; i++) { cnsChannelLocation = new NetChannelLocation(possibleAddresses[i], adminChannelLabel); try { //Attempt to send message to CNS toCNS = NetChannelEnd.createOne2Net(cnsChannelLocation); toCNS.write(logonMsg); } catch (Exception e) { if (i == possibleAddresses.length - 1) { //no more addresses to try so return false clearFields(); return false; } } } if (toCNS == null) { clearFields(); return false; } } else { //Constructor supplied cns channel location information try { toCNS = NetChannelEnd.createOne2Net(cnsChannelLocation); toCNS.write(logonMsg); } catch (Exception e) { e.printStackTrace(); clearFields(); return false; } } try { //Wait for logon reply message from CNS CNSMessage.LogonReplyMessage reply = (CNSMessage.LogonReplyMessage)fromCNS.read(); if (reply.success) { synchronized (staticSync) { if (holdStaticRef && staticServiceRef == null) staticServiceRef = this; } initialized = true; return true; } else { Node.err.log(this, "CNS Logon failure"); clearFields(); return false; } } catch (Exception e) { e.printStackTrace(); clearFields(); return false; } } } private void clearFields() { if (fromCNS != null) { fromCNS.destroyReader(); fromCNS = null; } cnsChannelLocation = null; if (toCNS != null) { toCNS.destroyWriter(); toCNS = null; } } /** * This checks to see if the service is already running, if it is not then * it starts it. * * @return true iff the service is running once this method has returned. */ public boolean start() { synchronized (processStatusChanging) { if (!initialized) return false; if (running) return true; One2OneChannel startedChan = Channel.one2one(); new ProcessManager(new ServiceProcess(startedChan.out())).start(); return ((Boolean) startedChan.in().read()).booleanValue(); } } /** * This checks to see if the service is running, if it is then it stops it. * * @return true if the service is NOT running. */ public boolean stop() { stopChan.out().write(null); return true; } /** * This returns whether the service is running. * If the service is currently starting or stopping, this method will block * until the state change is complete. * * @return true iff the service is running. */ public boolean isRunning() { synchronized (processStatusChanging) { return running; } } /** * This returns a ServiceUserObject which implements the * Resolver interface. This allows processes to obtain a * reference to an installed CNS Service without having admin * privileges. A SecurityException may be thrown if the * calling process does not have permission to obtain the * ServiceUserObject. * * @return a Resolver which can be used to resolve names * using this CNSService. * @throws SecurityException if the calling process does not have * permission to obtain the ServiceUserObject. * * @see CNSUser * */ public ServiceUserObject getUserObject() throws SecurityException { return userProxy; } /*---------------Public Methods-----------------------------------------------*/ /** *

* Installs and starts a Channel Name Server client service on the * local Node. The service is installed with the default service name * as specified by CNSService.CNS_DEFAULT_SERVICE_NAME. * This method needs to be supplied with the local Node's * NodeKey. This is required in order to obtain access * to the Node's service manager. *

* * @param key the local Node's NodeKey. * @param cnsAddress the address of the Channel Name Server to use. * * @throws ServiceInstallationException if installation fails. * * @return the CNS object installed. */ public static CNSService install(NodeKey key, NodeAddressID cnsAddress) { return install(key, cnsAddress, CNS_DEFAULT_SERVICE_NAME); } /** *

* Installs and starts a Channel Name Server client service on the * local Node. The service is installed with the specified service name. * This method needs to be supplied with the local Node's * NodeKey. This is required in order to obtain access to * the Node's service manager. *

* * @param key the local Node's NodeKey. * @param cnsAddress the address of the Channel Name Server to use. * @param name the name to give the service. * * @throws ServiceInstallationException if installation fails. * * @return the CNS object installed. * * @see org.jcsp.net.NodeAddressID */ public static CNSService install(NodeKey key, NodeAddressID cnsAddress, String serviceName) { ServiceManager sm = Node.getInstance().getServiceManager(key); //Initialize the CNS Server Process CNSService cnsService = new CNSService(cnsAddress, false); if (sm.installService(cnsService, serviceName)) { if (cnsService.init(null)) { if (sm.startService(serviceName)) { Node.info.log("org.jcsp.net.cns.CNSService", "CNSService Started"); return cnsService; } } sm.uninstallService(serviceName); throw new ServiceInstallationException("Failed to start service."); } else { Node.info.log("org.jcsp.net.cns.CNSService", "CNSService failed to start"); throw new ServiceInstallationException("Failed to install service."); } } /*-----------Resolving-------------------------*/ /** *

* This method resolves a channel name into a * NetChannelLocation object. The name is assumed * to be in the global name space (see * {@link NameAccessLevel#GLOBAL_ACCESS_LEVEL}). *

*

* This method is safe to be called by concurrent processes. *

* @param name the name of channel to resolve. * @return the location to which the name resolved. */ public NetChannelLocation resolve(String name) { return resolve(name, NameAccessLevel.GLOBAL_ACCESS_LEVEL); } /** *

* This method resolves a channel name into a * NetChannelLocation object. The name must * exist in the specified name space. *

*

* The name space is specified by passing in a * {@link NameAccessLevel} object. A name space * includes itself and any name space higher up in the * hierarchy. The global name space is the highest level of * name space. *

*

* This method is safe to be called by concurrent processes. *

* @param name the name of channel to resolve. * @param accessLevel the name space in which to resolve * the channel name. * @return the location to which the name resolved. */ public NetChannelLocation resolve(String name, NameAccessLevel accessLevel) { if (accessLevel == null) return resolve(name); if (name == null) throw new IllegalArgumentException("name cannot be null."); PendingResolve req = new PendingResolve(name, accessLevel); resolveRequestChanOut.write(req); NetChannelLocation resolved = (NetChannelLocation) req.sync.in().read(); CNSNetChannelLocation toReturn = new CNSNetChannelLocation(resolved, name, accessLevel, this, cnsServiceName); return (toReturn); } /*-----------Registration----------------------*/ /** *

* This method allows a channel (or any instance of a class implementing * {@link Networked}) to be registered with the Channel * Name Server. The name will be registered in the global name space. *

*

* A name will stay registered with the Channel Name Server until it * has been leased, deregistered or the Node that registered the name * has shut down. *

*

* This method is safe to be called by concurrent processes. *

* @param owner the Networked object whose location * should be registered. * @param name the name against which to register the channel. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. */ public ChannelNameKey register(Networked owner, String name) { return register(owner, name, NameAccessLevel.GLOBAL_ACCESS_LEVEL); } /** *

* This method allows a channel (or any instance of a class implementing * {@link Networked}) to be registered with the Channel * Name Server. *

*

* The name will be registered in the specified name space. This is * specified by passing in a {@link NameAccessLevel} object. *

*

* A name will stay registered with the Channel Name Server until it * has been leased, deregistered or the Node that registered the name * has shut down. *

*

* This method is safe to be called by concurrent processes. *

* @param owner the Networked object whose location * should be registered. * @param name the name against which to register the channel. * @param accessLevel the name space in which to register the channel name. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. * * @see NameAccessLevel */ public ChannelNameKey register(Networked owner, String name, NameAccessLevel accessLevel) { return register(owner, name, accessLevel, null); } /** *

* This method allows a channel (or any instance of a class implementing * {@link Networked}) that has previously been registered * with the to be reregistered with the Channel Name Server. The name * should have been leased (see * {@link #leaseChannelName(String, NameAccessLevel, ChannelNameKey)} * ). It is necessaray to supply the key that was obtained when * the name was leased. If the channel name has not previously been * registered, then the key can be specified as null. *

*

* The name will be registered in the in the global name space. *

*

* A name will stay registered with the Channel Name Server until it * has been leased, deregistered or the Node that registered the name * has shut down. *

*

* This method is safe to be called by concurrent processes. *

* * @param owner the Networked object whose location * should be registered. * @param name the name against which to register the channel. * @param accessLevel the name space in which to register the channel name. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. */ public ChannelNameKey register(Networked owner, String name, ChannelNameKey key) { return register(owner.getChannelLocation(), name, NameAccessLevel.GLOBAL_ACCESS_LEVEL, key); } /** *

* This method allows a channel (or any instance of a class implementing * {@link Networked}) that has previously been registered * to be reregistered with the Channel Name Server. The name * should have been leased (see * {@link #leaseChannelName(String, NameAccessLevel, ChannelNameKey)} * ). It is necessaray to supply the key that was obtained when * the name was leased. If the channel name has not previously been * registered, then the key can be specified as null. *

*

* The name will be registered in the specified name space. This is * specified by passing in a {@link NameAccessLevel} object. *

*

* A name will stay registered with the Channel Name Server until it * has been leased, deregistered or the Node that registered the name * has shut down. *

*

* This method is safe to be called by concurrent processes. *

* * @param owner the Networked object whose location * should be registered. * @param name the name against which to register the channel. * @param accessLevel the name space in which to register the channel name. * @param key the ChannelNameKey returned when the * name was leased. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. * @see NameAccessLevel */ public ChannelNameKey register(Networked owner, String name, NameAccessLevel accessLevel, ChannelNameKey key) { return register(owner.getChannelLocation(), name, accessLevel, key); } /** *

* This method allows a channel's location to be registered against a * name in the Channel Name Server. It differs from the other register * methods in that it takes a NetChannelLocation object * instead of a Networked object. This can be obtained * from a Networked object by invoking its * #getChannelLocation() method (see * {@link Networked#getChannelLocation()}). *

*

* The name will be registered in the specified name space. This is * specified by passing in a {@link NameAccessLevel} object. *

* This method also allows a leased channel name to be registered against * an actual location (see * {@link #register(Networked, String, NameAccessLevel, ChannelNameKey)} * ). *

*

* A name will stay registered with the Channel Name Server until it * has been leased, deregistered or the Node that registered the name * has shut down. *

*

* This method is safe to be called by concurrent processes. *

* * @param ownerLocation the location of a channel to be registered * against the name. * @param name the name against which to register the channel. * @param accessLevel the name space in which to register the channel name. * @param key the ChannelNameKey returned when the * name was leased. * @return the ChannelNameKey needed for managing * the name registration or null if registration * failed. * * @see #register(Networked, String, NameAccessLevel, ChannelNameKey) * @see NameAccessLevel */ public ChannelNameKey register(NetChannelLocation ownerLocation, String name, NameAccessLevel accessLevel, ChannelNameKey key) { if (accessLevel == null) accessLevel = NameAccessLevel.GLOBAL_ACCESS_LEVEL; if (ownerLocation instanceof LocationNotCNSRegisterable) throw new IllegalArgumentException("The NetChannelLocation object supplied cannot be registered with the CNS."); if (name == null || accessLevel == null || ownerLocation == null) throw new IllegalArgumentException("One or more parameters is null " + (name == null) + " " + (accessLevel == null) + " " + (ownerLocation == null)); CNSMessage.RegisterRequest request = new CNSMessage.RegisterRequest(); request.name = name; request.accessLevel = accessLevel; request.key = key; request.channelLocation = ownerLocation; registerRequestChanOut.write(request); CNSMessage.RegisterReply reply = (CNSMessage.RegisterReply)registerReplyChanIn.read(); if (reply != null) return reply.key; else //link to CNS lost return null; } /*-----------Leasing---------------------------*/ /** *

* Leases the channel name within the specified name space * from the Channel Name Server. Once a name has been leased, * a channel cannot be registered with that name without supplying * the key returned by the call to this method. *

*

* Currently, leases are infinite; they never expire. This is likely * to change in the future so that leases have to be renewed. Leases * can be given up by deregistering the name. Leases will remain even * after the obtaining Node has shut down. This allows a channel to move * its registered location to another channel on a different Node. There * is no danger of another party managing to obtain the name as transfering * a registered name into a lease is an atomic action. Although leases * are currently infinite, there is no reason why a program cannot renew * the lease by recalling this method. *

*

* A name may be leased without first registering a channel against it. *

*

* This method is safe to be called by concurrent processes. *

* * @param name the name to lease. * @param accessLevel the name space in which to lease the name. * @param channelKey the key to use if the name is currently * registered or leased. * * @return a new ChannelNameKey needed for managing the * lease or null if leasing failed. * * @throws ChannelNameException if the channel name is invalid. * @throws NameAccessLevelException if the specifed name space is * invalid. * */ public ChannelNameKey leaseChannelName(String name, NameAccessLevel accessLevel, ChannelNameKey channelKey) throws ChannelNameException, NameAccessLevelException { if (name == null) throw new IllegalArgumentException("Null parameter"); if (accessLevel == null) accessLevel = NameAccessLevel.GLOBAL_ACCESS_LEVEL; CNSMessage.LeaseRequest request = new CNSMessage.LeaseRequest(); request.name = name; request.accessLevel = accessLevel; request.key = channelKey; leaseRequestChanOut.write(request); CNSMessage.LeaseReply reply = (CNSMessage.LeaseReply) leaseReplyChanIn.read(); if (reply != null) return reply.key; else return null; } /*-----------Deregistration--------------------*/ /** *

* This deregisters a Channel name from the Channel Name Server. * If the CNS Service is not running, this method will block until it * is running. * A boolean is returned to indicate whether deregistration was successful. * This is also returned if the link to the CNS is lost. *

*

* This method is safe to be called by concurrent processes. *

* * @param name the name of the channel as a String. * @param nameAccessLevel the nameAccessLevel of the channel. * @param channelKey the ChannelNameKey to use to deregister the * Channel name. * * @return a boolean indicating success. */ public boolean deregisterChannelName(String name, NameAccessLevel accessLevel, ChannelNameKey channelKey) { if (name == null || channelKey == null) throw new IllegalArgumentException("Null parameter"); if (accessLevel == null) accessLevel = NameAccessLevel.GLOBAL_ACCESS_LEVEL; CNSMessage.DeregisterRequest request = new CNSMessage.DeregisterRequest(); request.name = name; request.accessLevel = accessLevel; request.key = channelKey; deregisterRequestChanOut.write(request); CNSMessage.DeregisterReply reply = (CNSMessage.DeregisterReply) deregisterReplyChanIn.read(); if (reply != null) return reply.success; else //link to CNS lost return false; } /*---------------Inner Classes------------------------------------------------*/ /** * Data structure for pending resolve requests. * */ private static class PendingResolve { PendingResolve(String name, NameAccessLevel nameAccessLevel) { channelName = name; next = null; sync = Channel.one2one(); this.nameAccessLevel = nameAccessLevel; } final String channelName; final One2OneChannel sync; final NameAccessLevel nameAccessLevel; PendingResolve next; } /** * The main process of the service. * * This handles a single request at a time. * * Register, lease and deregister requests are sent to the server * and then the process waits for a response. * * Resolve requests are sent to the server after which the process * resumes serving requests. The server will send a response back to * this process once a name matching the request has been registered. * */ private class ServiceProcess implements CSProcess { ServiceProcess(ChannelOutput startedChan) { this.startedChan = startedChan; } ChannelOutput startedChan; public void run() { try { final int STOP_INDEX = 0; final int FROM_CNS_INDEX = 1; final int RESOLVE_INDEX = 2; final int REGISTER_INDEX = 3; final int LEASE_INDEX = 4; final int DEREGISTER_INDEX = 5; running = true; Alternative alt = new Alternative(new Guard[] { stopChan.in(), fromCNS, resolveRequestChanIn, registerRequestChanIn, leaseRequestChanIn, deregisterRequestChanIn }); startedChan.write(new Boolean(true)); while (running) { switch (alt.priSelect()) { case STOP_INDEX : stopChan.in().read(); running = false; break; case FROM_CNS_INDEX : Object obj = fromCNS.read(); if (obj instanceof CNSMessage.ResolveReply) { CNSMessage.ResolveReply rr = (CNSMessage.ResolveReply) obj; PendingResolve pr = (PendingResolve)pendingResolves.remove(new CNS.NameAndLevel(rr.name, rr.accessLevel)); while (pr != null) { pr.sync.out().write(rr.channelLocation); pr = pr.next; } } else Node.err.log(this, "Unexpected message type received: " + obj.getClass()); break; case RESOLVE_INDEX : { PendingResolve req = (PendingResolve)resolveRequestChanIn.read(); req.next = (PendingResolve)pendingResolves.put(new CNS.NameAndLevel(req.channelName, req.nameAccessLevel), req); if (req.next == null) { // The request to establish this link had not already // been sent so send request CNSMessage.ResolveRequest request = new CNSMessage.ResolveRequest(); request.name = req.channelName; request.accessLevel = req.nameAccessLevel; request.replyLocation = fromCNS.getChannelLocation(); request.RequestIndex = 0; toCNS.write(request); } break; } case REGISTER_INDEX : { CNSMessage.RegisterRequest req = (CNSMessage.RegisterRequest)registerRequestChanIn.read(); req.RequestIndex = 0; req.replyLocation = fromCNS.getChannelLocation(); // Send request to CNS toCNS.write(req); CNSMessage reply = getRegistrationReply(); if (reply == null) { Node.err.log(this, "Link to CNS lost"); stopCNSService(); } else { while (!(reply instanceof CNSMessage.RegisterReply)) { Node.err.log(this, "Wrong message type received"); reply = getRegistrationReply(); } } registerReplyChanOut.write(reply); break; } case LEASE_INDEX : { CNSMessage.LeaseRequest req = (CNSMessage.LeaseRequest)leaseRequestChanIn.read(); req.RequestIndex = 0; req.replyLocation = fromCNS.getChannelLocation(); // Send request to CNS toCNS.write(req); CNSMessage reply = getRegistrationReply(); if (reply == null) { Node.err.log(this, "Link to CNS lost"); stopCNSService(); } else while (!(reply instanceof CNSMessage.LeaseReply)) Node.err.log(this, "Wrong message type received"); reply = getRegistrationReply(); leaseReplyChanOut.write(reply); break; } case DEREGISTER_INDEX : { CNSMessage.DeregisterRequest req = (CNSMessage.DeregisterRequest)deregisterRequestChanIn.read(); req.RequestIndex = 0; req.replyLocation = fromCNS.getChannelLocation(); // Send request to CNS toCNS.write(req); CNSMessage reply = getRegistrationReply(); if (reply == null) { Node.err.log(this, "Link to CNS lost"); stopCNSService(); } else { while (!(reply instanceof CNSMessage.DeregisterReply)) { Node.err.log(this, "Wrong message type received"); reply = getRegistrationReply(); } } deregisterReplyChanOut.write(reply); break; } } } } catch (Exception e) { e.printStackTrace(); } finally { running = false; } } private CNSMessage getRegistrationReply() { // Get reply from CNS and handle others in the mean time. CNSMessage reply = null; while (reply == null) { Object obj = fromCNS.read(); if (obj instanceof CNSMessage.RegisterReply) reply = (CNSMessage.RegisterReply) obj; else if (obj instanceof CNSMessage.DeregisterReply) reply = (CNSMessage.DeregisterReply) obj; else if (obj instanceof CNSMessage.LeaseReply) reply = (CNSMessage.LeaseReply) obj; else if (obj instanceof CNSMessage.ResolveReply) { CNSMessage.ResolveReply rr = (CNSMessage.ResolveReply) obj; PendingResolve pr = (PendingResolve)pendingResolves.remove(new CNS.NameAndLevel(rr.name, rr.accessLevel)); while (pr != null) { pr.sync.out().write(rr.channelLocation); pr = pr.next; } } else { Thread.dumpStack(); Node.err.log(this, "Unexpected message type received."); } } return reply; } /** * This stops the CNS Service and removes its Channel from * IndexManager. It sets the running indicator to false. * */ private void stopCNSService() { } } /** * This class acts as a proxy for the name management * methods in its outer class. * */ private class UserObject implements ServiceUserObject, CNSUser { public NetChannelLocation resolve(String name) { return outerObject.resolve(name); } public NetChannelLocation resolve(String name, NameAccessLevel accessLevel) { return outerObject.resolve(name, accessLevel); } public ChannelNameKey register(Networked owner, String name) { return outerObject.register(owner, name); } public ChannelNameKey register(Networked owner, String name, NameAccessLevel accessLevel) { return outerObject.register(owner, name, accessLevel); } public ChannelNameKey register(Networked owner, String name, ChannelNameKey key) { return outerObject.register(owner, name, key); } public ChannelNameKey register(Networked owner, String name, NameAccessLevel accessLevel, ChannelNameKey key) { return outerObject.register(owner, name, accessLevel, key); } public ChannelNameKey register(NetChannelLocation ownerLocation, String name, NameAccessLevel accessLevel, ChannelNameKey key) { return outerObject.register(ownerLocation, name, accessLevel, key); } public ChannelNameKey leaseChannelName(String name, NameAccessLevel accessLevel, ChannelNameKey channelKey) throws ChannelNameException, NameAccessLevelException { return outerObject.leaseChannelName(name, accessLevel, channelKey); } public boolean deregisterChannelName(String name, NameAccessLevel accessLevel, ChannelNameKey channelKey) { return outerObject.deregisterChannelName(name, accessLevel, channelKey); } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/CNSMessage.java0000644000000000000000000000722711105701167017315 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import java.io.*; import org.jcsp.net.*; /** * This class is only visible to this package and does not need to be * used by JCSP users. * * The class is used for sending messages between the CNS server * process and CNSService client processes. * * @author Quickstone Technologies Limited */ abstract class CNSMessage implements Serializable { static class LogonMessage extends CNSMessage { NetChannelLocation replyLocation; } static class LogonReplyMessage extends CNSMessage { boolean success; } static abstract class CNSRequestMessage extends CNSMessage { NetChannelLocation replyLocation; int RequestIndex; String name; NameAccessLevel accessLevel; } static abstract class CNSReplyMessage extends CNSMessage { int RequestIndex; } static class RegisterRequest extends CNSRequestMessage { NetChannelLocation channelLocation; ChannelNameKey key; } static class ResolveRequest extends CNSRequestMessage { } static class LeaseRequest extends CNSRequestMessage { ChannelNameKey key; } static class DeregisterRequest extends CNSRequestMessage { ChannelNameKey key; } static class RegisterReply extends CNSReplyMessage { ChannelNameKey key; } static class ResolveReply extends CNSReplyMessage { NetChannelLocation channelLocation; String name; NameAccessLevel accessLevel; } static class LeaseReply extends CNSReplyMessage { ChannelNameKey key; } static class DeregisterReply extends CNSReplyMessage { boolean success; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/WrongFactoryException.java0000644000000000000000000000473411105701167021670 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; /** * Thrown if an attempt is made to get a NamedChannelEndManager * to destroy a channel that it did not create. * * @author Quickstone Technologies Limited */ public class WrongFactoryException extends RuntimeException { /** * Constructor for WrongFactoryException. */ public WrongFactoryException() { super(); } /** * Constructor for WrongFactoryException. * @param message */ public WrongFactoryException(String message) { super(message); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/CNS.java0000644000000000000000000012171611105701167016010 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import java.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.net.*; /** *

* This class is the Channel Name Server's main server process class. *

*

* This class should only be instantiated at Nodes wishing to run * a server process. Although this class does not need to be used * by clients wishing to interact with a server, it does * provide some convenient static methods for client code to use. There * are static versions of the methods provided in CNSService * and there are also static factory methods for constructing CNS * registered channel objects. *

*

*

Server Installation

*

*

* Channel Name Servers may be run either on a dedicated Node or else on * the same Node as one of the user Nodes. The former approach is recommended * for most sitations but for smaller scale use, the latter approach may * suffice. The service implements the * org.jcsp.net.Service interface and can be installed * in the same way as any other other service by using the service manager * ({@link org.jcsp.net.ServiceManager}). Alternatively, the * service provides install methods which handle the service manager * interaction directly. *

*

* The following example initializes a Node and installs a Channel Name Server. * It then proceeds to install a CNS client service and creates and resolves * a channel. The example does not proceed to do anything else but could be * used as the framework for an application wishing to host its own * Channel Name Server. *

*
 * import org.jcsp.lang.*;
 * import org.jcsp.net.*;
 * import org.jcsp.net.cns.*;
 * import org.jcsp.net.tcpip.*;
 *
 * import java.io.IOException;
 *
 * public class CNSInSameJVM implements CSProcess {
 *
 *   //main method for running example
 *   public static void main(String[] args) {
 *     CNSInSameJVM proc = new CNSInSameJVM();
 *     proc.run();
 *   }
 *
 *   public void run() {
 *     NodeKey key = null;
 *     NodeID localNodeID = null;
 *     try {
 *       //Initialize a Node that does not have a CNS client
 *       key = Node.getInstance().init(new XMLNodeFactory("nocns.xml"));
 *       localNodeID = Node.getInstance().getNodeID();
 *
 *       //Initialize the CNS Server Process
 *       CNS.install(key);
 *
 *       //Dedicated server code could stop here
 *
 *       //Initialize the CNS client
 *       //use the first address of the local Node as CNS address
 *       NodeAddressID cnsAddress = localNodeID.getAddresses()[0];
 *       CNSService.install(key, cnsAddress);
 *
 *       //creating Channel named "in"
 *       NetChannelInput in = CNS.createNet2One("in");
 *       //resolve the channel
 *       NetChannelOutput out = CNS.createOne2Net("in");
 *
 *       //could now use these channels for something!!
 *       //but this is only a test so will terminate
 *
 *
 *     } catch (NodeInitFailedException e) {
 *       e.printStackTrace();
 *     } catch (IOException e) {
 *       e.printStackTrace();
 *     }
 *     Node.info.log(this, "Done.");
 *   }
 *
 * }
 * 
*

* This is the contents of the nocns.xml file: *

* <JCSP-CONFIG>
* <PROTOCOLS>
* <PROTOCOL id="TCPIP" name="TCP/IP" idclass="org.jcsp.net.tcpip.TCPIPProtocolID">
* </PROTOCOL>
* </PROTOCOLS>
* <ADDRESSES>
* <ADDRESS protocolid="TCPIP" value="127.0.0.1:7896" unique="FALSE">
* </ADDRESS>
* </ADDRESSES>
* </JCSP-CONFIG>
*

* The above code can be copied into a file named CNSInSameJVM.java and compiled * an run in same directory as the nocns.xml file. *

*

*

Channel Factory Methods

*

*

* In order to construct a ChannelInput object which can be * resolved by other users of a channel name server, a client simply needs * to to do this: *

*
 *   NetChannelInput in = CNS.createNet2One("Fred");
 * 
*

* Another process using the same channel name server can create a * ChannelOutput that will send objects to this channel * by do this: *

*
 *   NetChannelOutput out = CNS.createOne2Net("Fred");
 * 
*

* When these factory methods are called, various resources are used * within the JCSP infrastructure. A channel name will be registered * and held in the channel name server. These resources are taken for * the duration of the JCSP Node's runtime unless the user manually * frees the resources. When channel ends are constructed with these * factory methods, the destroyChannelEnd(***) methods * can be used to free all resources. It is only really necessary to * do this if channels are being created for short term use within * a long-lived Node. *

*

* This is an example "Hello World" program which contains two * inner classes with main methods, each of which can be run in * separate JVMs. *

*
 *  import org.jcsp.lang.*;
 *  import org.jcsp.net.*;
 *  import org.jcsp.net.cns.*;
 *
 *  public class TestCNS {
 *
 *    public static class Rx {
 *      public static void main(String[] args) {
 *    	  try {
 *    	    Node.getInstance().init();
 *    	    NetChannelInput in = CNS.createNet2One("rx.in");
 *    	    System.out.println(in.read());
 *    	    CNS.destroyChannelEnd(in);
 *    	  } catch (NodeInitFailedException e) {
 *    	    e.printStackTrace();
 *    	  }
 *      }
 *    }
 *
 *    public static class Tx {
 *      public static void main(String[] args) {
 *        try {
 *          Node.getInstance().init();
 *          NetChannelOutput out = CNS.createOne2Net("rx.in");
 *          out.write("Hello World");
 *          CNS.destroyChannelEnd(out);
 *        } catch (NodeInitFailedException e) {
 *          e.printStackTrace();
 *        }
 *      }
 *    }
 *  }
 * 
*

* This code can be compiled and then the following run at two * command prompts: *

*

* java TestCNS$Rx *

*

* java TestCNS$Tx *

*

* The programs will connect to a default channel name server. The * Rx program will create a NetChannelInput and wait * for a message on the channel. Once it has received the message, * it prints it, destroys its channel and then terminates. * The Tx program creates a NetChannelOutput that will * send to the Rx program's input channel. It sends a "Hello World" * message. Once this has been accepted by the Rx process, it * destoys its output channel and terminates. *

*

*

*

CNS Client Methods

*

*

* The following code functions the same as the above code but does * not use the CNS class' factory methods. The code uses the CNS client * methods and manually registers and resolves the channel with the * channel name server. * *

*
 *  import org.jcsp.lang.*;
 *  import org.jcsp.net.*;
 *  import org.jcsp.net.cns.*;
 *
 *  public class TestCNS {
 *
 *    public static class Rx {
 *      public static void main(String[] args) {
 *    	  try {
 *    	    Node.getInstance().init();
 *          NetChannelInput in = NetChannelEnd.createNet2One();
 *          ChannelNameKey key = CNS.register(in, "rx.in");
 *          System.out.println(in.read());
 *          CNS.deregisterChannelName("rx.in", null, key);
 *    	  } catch (NodeInitFailedException e) {
 *    	    e.printStackTrace();
 *    	  }
 *      }
 *    }
 *
 *    public static class Tx {
 *      public static void main(String[] args) {
 *        try {
 *          Node.getInstance().init();
 *          NetChannelLocation loc = CNS.resolve("rx.in");
 *          NetChannelOutput out = NetChannelEnd.createOne2Net(loc);
 *          out.write("Hello World");
 *          out.destroyWriter();
 *        } catch (NodeInitFailedException e) {
 *          e.printStackTrace();
 *        }
 *      }
 *    }
 *  }
 * 
*

* The CNS client methods provide the programmer with greater control * over how the Channel Name Server is used. Interaction with the * server need not be performed at the same time as construction of * the channel. A channel can be registered with a Channel Name Server * at any time after construction of its input end. A channel can be resolved * at any time before construction of an output end. This allows one process * to resolve a name into a NetChannelLocation object and * then pass this object on for another process to use in constructing the * channel. * * The Channel Name Server will allow a channel to be registered multiple * times with different names and/or in different name spaces. Channel * implementations that make direct use of the Channel Name Server may * forbid this, so the behaviour of channel implemenations should be checked * before this is carried out *

* * @see org.jcsp.net.cns.CNSService * @see org.jcsp.net.ServiceManager * @see org.jcsp.net.Node * * @author Quickstone Technologies Limited */ public class CNS implements Service, CSProcess { /** A public constructor which takes a NodeKey as a parameter which * should be the key for the local Node. * * @param nodeKey a NodeKey object that should match * the local Node's NodeKey. * @throws IllegalStateException if the local Node has not been * initialized. * @throws SecurityException if the supplied NodeKey * object cannot be verified by the local Node. */ public CNS(NodeKey nodeKey) throws IllegalStateException, SecurityException { if (!Node.getInstance().isInitialized()) throw new IllegalStateException(); if (!Node.getInstance().verifyKey(nodeKey)) throw new SecurityException(); } /*---------------Public constants--------------------------------------------*/ public final static String CNS_DEFAULT_SERVICE_NAME = "org.jcsp.net.cns:Channel Name Server"; /*---------------Package level constants-------------------------------------*/ final static String CNS_CHANNEL_LABEL = "org.jcsp.net.cns.CNSLabel"; /*---------------Private fields----------------------------------------------*/ private final int INPUT_BUFFER_SIZE = 30; private boolean running = false; private Any2OneChannel stopChan = Channel.any2one(); private Hashtable toClientChans = new Hashtable(); private long channelKeyCount = 0; private One2OneChannel startedReplyChan = Channel.one2one(); /** * The registered channel names and indexes. * This is a hashtable where the key is a * NameAndLevel object and the value is the ChannelID. */ private Hashtable channels = new Hashtable(); private Hashtable leasedChannelKeys = new Hashtable(); /** * This holds NameAndLevel objects as the keys that map to the * associated ChannelNameKey objects. */ private Hashtable registeredChannelKeys = new Hashtable(); /** * The registered channel names and indexes. * This is a hashtable where the key is the * channel name and the value is the ChannelID. */ private Hashtable pendingResolves = new Hashtable(); private static CNSChannelEndManager CHAN_FACTORY = new CNSChannelEndManager(); /*---------------Public Methods-from Service Interface------------------------*/ /** This starts the channel name server. * @return true iff the channel name server is able to start. */ public boolean start() { new ProcessManager(this).start(); running = Boolean.TRUE.equals(startedReplyChan.in().read()); return running; } /** * Stops the channel name server. * @return true iff the Channel Name Server has accepted the stop request. */ public boolean stop() { //change this to a connection later if (running) { stopChan.out().write(null); running = false; return true; } return false; } /** This method does not need to be called for the Channel Name Server. It returns true. * @param settings A ServiceSettings object containing settings for the service. * @return false */ public boolean init(ServiceSettings settings) { return true; } /** Returns whether the service is running. * At the moment this always returns false. * This will probably change in the future. * Early JCSP.NET applications always had the CNS process running in its own JVM. * @return false */ public boolean isRunning() { return false; } /** * Returns a null reference as this method has no * use with this service. * * @return null. */ public ServiceUserObject getUserObject() throws SecurityException { return null; } /*---------------Public Methods from CSProcess--------------------------------*/ public void run() { boolean run = true; final int CHAN_STOP = 0; final int CHAN_EVENT = 1; final int CHAN_FROM_NET = 2; //get a channel from the Node which can be used to received //events notiying that a link to a particular Node has been //dropped. AltingChannelInput linkEvents = Node.getInstance().getLinkLostEventChannel(); NetAltingChannelInput fromNet = null; try { fromNet = NetChannelEnd.createNet2One(CNS_CHANNEL_LABEL, new Buffer(INPUT_BUFFER_SIZE)); } catch (DuplicateChannelLabelException e) { Node.err.log(this, "CNS unable to create a labelled channel. Another CNS service might be running."); run = false; startedReplyChan.out().write(Boolean.FALSE); return; } catch (Exception e) { Node.err.log(this, "Exception occurred while starting CNS"); Node.err.log(this, e); run = false; startedReplyChan.out().write(Boolean.FALSE); return; } Alternative alt = new Alternative(new Guard[] { stopChan.in(), linkEvents, fromNet }); startedReplyChan.out().write(Boolean.TRUE); Node.info.log(this, "CNS server starting"); while (run) { switch (alt.priSelect()) { case CHAN_STOP : run = false; break; case CHAN_EVENT : Object obj = linkEvents.read(); handleLinkDropped((NodeID) obj); Node.info.log(this, "Received link event " + obj); break; case CHAN_FROM_NET : try { Object o = fromNet.read(); if (o instanceof CNSMessage.LogonMessage) handleLogonMessage((CNSMessage.LogonMessage) o); else if (o instanceof CNSMessage.RegisterRequest) handleRegisterRequest((CNSMessage.RegisterRequest) o); else if (o instanceof CNSMessage.ResolveRequest) handleResolveRequest((CNSMessage.ResolveRequest) o); else if (o instanceof CNSMessage.LeaseRequest) handleLeaseRequest((CNSMessage.LeaseRequest) o); else if (o instanceof CNSMessage.DeregisterRequest) handleDeregisterRequest((CNSMessage.DeregisterRequest) o); } catch (Exception e) { Node.err.log(this, "Error caught and ignored"); Node.err.log(this, e); } break; } } //Destroy the fromNet channel so that all the //CNS clients are notified that the CNS has gone down fromNet.destroyReader(); if (stopChan.in().pending()) stopChan.in().read(); } /*---------------Other Public Methods-----------------------------------------*/ /*---------------Public Static Methods----------------------------------------*/ /*-----------Resolving-------------------------*/ public static NetChannelLocation resolve(String name) { return CNSService.staticServiceRef.resolve(name); } public static NetChannelLocation resolve(String name, NameAccessLevel accessLevel) { return CNSService.staticServiceRef.resolve(name, accessLevel); } /*-----------Registration----------------------*/ public static ChannelNameKey register(Networked owner, String name) { return CNSService.staticServiceRef.register(owner, name); } public static ChannelNameKey register(Networked owner, String name, NameAccessLevel accessLevel) { return CNSService.staticServiceRef.register(owner, name, accessLevel); } public static ChannelNameKey register(Networked owner, String name, ChannelNameKey key) { return CNSService.staticServiceRef.register(owner, name, key); } public static ChannelNameKey register(Networked owner, String name, NameAccessLevel accessLevel, ChannelNameKey key) { return CNSService.staticServiceRef.register(owner, name, accessLevel, key); } public static ChannelNameKey register(NetChannelLocation ownerLocation, String name, NameAccessLevel accessLevel, ChannelNameKey key) { return CNSService.staticServiceRef.register(ownerLocation, name, accessLevel, key); } /*-----------Leasing---------------------------*/ public static ChannelNameKey leaseChannelName(String name, NameAccessLevel accessLevel, ChannelNameKey channelKey) throws ChannelNameException, NameAccessLevelException { return CNSService.staticServiceRef.leaseChannelName(name, accessLevel, channelKey); } /*-----------Deregistration--------------------*/ /** * This deregisters a Channel name with the CNS. If the CNS Service is not * running, this method will block until it is running. * A boolean is returned to indicate whether deregistration was successful. * This is also returned if the link to the CNS is lost. * * @param name the name of the channel as a String. * @param nameAccessLevel the nameAccessLevel of the channel. * @param channelKey the ChannelNameKey to use to deregister the * Channel name. * * @return a boolean indicating success. */ public static boolean deregisterChannelName(String name, NameAccessLevel accessLevel, ChannelNameKey channelKey) { return CNSService.staticServiceRef.deregisterChannelName(name, accessLevel, channelKey); } /*---------------Private Methods----------------------------------------------*/ private void handleLogonMessage(CNSMessage.LogonMessage msg) { NetChannelOutput toClient = NetChannelEnd.createOne2Net(msg.replyLocation); NodeID clientID = msg.replyLocation.getChannelNodeID(); CNSMessage.LogonReplyMessage reply = new CNSMessage.LogonReplyMessage(); if (clientID == null || toClientChans.containsKey(clientID)) //not going to allow Node to logon - does not have NodeID //or a CNS service on that NodeID is already logged in reply.success = false; else { toClientChans.put(clientID, toClient); reply.success = true; } toClient.write(reply); } private void handleRegisterRequest(CNSMessage.RegisterRequest msg) { //get the channel to reply down ChannelOutput replyChan = (ChannelOutput)toClientChans.get(msg.replyLocation.getChannelNodeID()); if (replyChan == null || msg.name == null || (msg.channelLocation == null)) Node.info.log(this, "CNS server process received an invalid register request"); else { // set up reply CNSMessage.RegisterReply reply = new CNSMessage.RegisterReply(); reply.RequestIndex = msg.RequestIndex; //attempt to register the channel - key will be null if //registration fails reply.key = registerChannel(msg.name, msg.accessLevel, msg.channelLocation, msg.key); //send the reply to the user replyChan.write(reply); if (reply.key != null) { Node.info.log(this, msg.name + ", " + msg.accessLevel + " registered to " + msg.channelLocation); // Notify any waiting processes. PendingResolve toPutBack = null; PendingResolve ir = (PendingResolve) pendingResolves.remove(msg.name); while (ir != null) { PendingResolve nextIr = ir.next; ir.reply.channelLocation = getChannel(ir.channelName, ir.nameAccessLevel); if (ir.reply.channelLocation == null) { //The new channel has the wrong nameAccessLevel //for this queued request, so put request back ir.next = toPutBack; toPutBack = ir; } else { ir.txReplyChannel.write(ir.reply); Node.info.log(this, "Queued resolve for " + ir.channelName + "," + ir.nameAccessLevel + " was completed"); } ir = nextIr; } if (toPutBack != null) pendingResolves.put(msg.name, toPutBack); } else Node.err.log(msg.name + ", " + msg.accessLevel + " could not be registered to " + msg.channelLocation + " - already registered."); } } private void handleResolveRequest(CNSMessage.ResolveRequest msg) { Node.info.log(this, "ResolveRequest"); ChannelOutput replyChan = (ChannelOutput)toClientChans.get(msg.replyLocation.getChannelNodeID()); if (replyChan == null || msg.name == null) Node.err.log(this, "CNS asked to resolve null name"); else { // set up reply CNSMessage.ResolveReply reply = new CNSMessage.ResolveReply(); reply.RequestIndex = msg.RequestIndex; reply.channelLocation = getChannel(msg.name, msg.accessLevel); reply.name = msg.name; reply.accessLevel = msg.accessLevel; if (reply.channelLocation != null) { Node.info.log(this, "Channel " + msg.name + " resolved by " + msg.replyLocation + " to " + reply.channelLocation); // Send reply replyChan.write(reply); } else { Node.info.log(this, "Attempted resolve of " + msg.name + " by " + msg.replyLocation + " was queued"); // Queue request, reply when it registers. PendingResolve ir = new PendingResolve(reply, replyChan, msg.name, msg.accessLevel); ir.next = (PendingResolve) pendingResolves.put(msg.name, ir); } } } private void handleLeaseRequest(CNSMessage.LeaseRequest msg) { ChannelOutput replyChan = (ChannelOutput)toClientChans.get(msg.replyLocation.getChannelNodeID()); if (replyChan == null) Node.err.log(this, "CNS received an invalid lease request."); else { CNSMessage.LeaseReply reply = new CNSMessage.LeaseReply(); reply.RequestIndex = msg.RequestIndex; if (msg.name == null) reply.key = null; else { NameAccessLevel nameAccessLevel = msg.accessLevel; if (nameAccessLevel == null) nameAccessLevel = NameAccessLevel.GLOBAL_ACCESS_LEVEL; NameAndLevel nal = new NameAndLevel(msg.name, nameAccessLevel); //check to see the channel has been registered if (deregisterChannel(msg.name, nameAccessLevel, msg.key)) { reply.key = new ChannelNameKey(channelKeyCount++); leasedChannelKeys.put(nal, reply.key); } } replyChan.write(reply); } } private void handleDeregisterRequest(CNSMessage.DeregisterRequest msg) { ChannelOutput replyChan = (ChannelOutput)toClientChans.get(msg.replyLocation.getChannelNodeID()); if (replyChan == null) Node.err.log(this, "CNS received an invalid deregister request."); else { // set up reply CNSMessage.DeregisterReply reply = new CNSMessage.DeregisterReply(); reply.RequestIndex = msg.RequestIndex; // do the request reply.success = deregisterChannel(msg.name, msg.accessLevel, msg.key); // Send reply replyChan.write(reply); if (reply.success) Node.info.log(this, msg.name + ", " + msg.accessLevel + " was deregistered."); else Node.info.log(this, msg.name + ", " + msg.accessLevel + " could not be deregistered"); } } private void handleLinkDropped(NodeID nodeID) { Object txChannel = toClientChans.get(nodeID); // Iterating a Hashtable is a **nightmare** // But we're going to do it twice! // // What happens if we change the Hashtable while // we're enumerating is undefined, so we have to start // all over again. // Any pending requests? boolean changed = true; while (changed) { changed = false; Enumeration e = pendingResolves.keys(); while ((!changed) && e.hasMoreElements()) { String n = (String) e.nextElement(); PendingResolve ir = (PendingResolve) pendingResolves.get(n); // Make sure we need to keep the first one. while ((ir != null) && (ir.txReplyChannel == txChannel)) { ir = ir.next; changed = true; // must start again. } if (ir == null) pendingResolves.remove(n); else { if (changed) pendingResolves.put(n, ir); // Unlink any others we need to remove. // (We can change here without starting again, // since this isn't actually in the Hashtable) while (ir.next != null) { if (ir.next.txReplyChannel == txChannel) // Unlink ir.next = ir.next.next; else // OK, check next. ir = ir.next; } } } } // Any registered channels? // Well, unregister them. changed = true; while (changed) { changed = false; Enumeration e = channels.keys(); while ((!changed) && e.hasMoreElements()) { NameAndLevel n = (NameAndLevel) e.nextElement(); NetChannelLocation id = (NetChannelLocation) channels.get(n); if (id.getChannelNodeID().equals(nodeID)) { channels.remove(n); // "Broken link, so unregistered."); Node.info.log(this, "Broken link, so " + n + " unregistered."); changed = true; // must start again. } } } } /** * Register a Channel in the database. Fails if the channel has already * been registered to a different location. (Re-registering to * the same ChannelID is allowed) or if it has been leased and the supplied * key does not match the leased channel name's key. * * @param channelName The channel's name. * @param channelId The channel's ChannelID. * @return a ChannelNameKey on successful database update, null if the name * is already registered elsewhere. */ private ChannelNameKey registerChannel(String channelName, NameAccessLevel nameAccessLevel, NetChannelLocation channelLoc, ChannelNameKey channelKey) { if (channelName == null || nameAccessLevel == null) return null; NameAndLevel nal = new NameAndLevel(channelName, nameAccessLevel); NetChannelLocation existingID = (NetChannelLocation) channels.get(nal); //Check to see whether name has been leased, and if it has then //the supplied channel key must equal the leased channel name's key, //otherwise return null. if (existingID == null) { Node.info.log(this, "Reg: channel not registered - might be leased"); ChannelNameKey leasedNameKey = (ChannelNameKey)leasedChannelKeys.get(nal); if (leasedNameKey != null) { Node.info.log(this, "Has been leased"); if (!leasedNameKey.equals(channelKey)) { Node.info.log(this, "Keys not equal - " + leasedNameKey + ", " + channelKey); return null; } } //key matches so remove from the leasedChannelKeys set leasedChannelKeys.remove(nal); } if ((existingID != null) && (!existingID.equals(channelLoc))) return null; else { channels.put(nal, channelLoc); ChannelNameKey newChannelKey = new ChannelNameKey(channelKeyCount++); registeredChannelKeys.put(nal, newChannelKey); Node.info.log(this, "Returning new key"); return newChannelKey; } } /** * Get a ChannelID for a channel with a name that matches the supplied name * and whose name is within the supplied scope. * * @param channelName The channel's name. * @param nameAccessLevel the channel's nameAccessLevel * @return a ChannelID if one can be found that matches the name and * nameAccessLevel, otherwise returns null. */ private NetChannelLocation getChannel(String channelName, NameAccessLevel nameAccessLevel) { //find most local matching channel NetChannelLocation toReturn = null; AbstractID abstractID = nameAccessLevel.getLevelAbstractID(); while (toReturn == null && abstractID != null) { toReturn = (NetChannelLocation)channels.get(new NameAndLevel(channelName, nameAccessLevel)); if (toReturn == null) { abstractID = abstractID.getParentID(); nameAccessLevel = new NameAccessLevel(abstractID); } } return toReturn; } /** * Deregisters a channel name and nameAccessLevel if a channel matches * or removes a matching lease. * * @param channelName the channel's name. * @param nameAccessLevel the channel's nameAccessLevel * @return true iff a matching channel is not registered after returning. */ private boolean deregisterChannel(String channelName, NameAccessLevel nameAccessLevel, ChannelNameKey channelKey) { if (channelName == null || nameAccessLevel == null) return true; NameAndLevel nal = new NameAndLevel(channelName, nameAccessLevel); ChannelNameKey registeredKey = (ChannelNameKey)registeredChannelKeys.get(nal); if (registeredKey != null) { if (registeredKey.equals(channelKey)) { registeredChannelKeys.remove(nal); return (channels.remove(nal) != null); } else return false; } //channel isn't registered - check to see if it has been leased //If so, remove the lease registeredKey = (ChannelNameKey) leasedChannelKeys.get(nal); if (registeredKey != null) { if (registeredKey.equals(channelKey)) { leasedChannelKeys.remove(nal); return true; } else return false; } return true; } /*----------------Factory Methods for Channels--------------------------------*/ /** * @see org.jcsp.net.cns.NamedChannelEndFactory#createNet2One(String) */ public static NetAltingChannelInput createNet2One(String name) { return CHAN_FACTORY.createNet2One(name); } /** * @see org.jcsp.net.cns.NamedChannelEndFactory#createNet2One(String, NameAccessLevel) */ public static NetAltingChannelInput createNet2One(String name, NameAccessLevel nameAccessLevel) { return CHAN_FACTORY.createNet2One(name, nameAccessLevel); } /** * @see org.jcsp.net.cns.NamedChannelEndFactory#createNet2Any(String) */ public static NetSharedChannelInput createNet2Any(String name) { return CHAN_FACTORY.createNet2Any(name); } /** * @see org.jcsp.net.cns.NamedChannelEndFactory#createNet2Any(String, NameAccessLevel) */ public static NetSharedChannelInput createNet2Any(String name, NameAccessLevel nameAccessLevel) { return CHAN_FACTORY.createNet2Any(name, nameAccessLevel); } /** * @see org.jcsp.net.cns.NamedChannelEndFactory#createOne2Net(String) */ public static NetChannelOutput createOne2Net(String name) { return CHAN_FACTORY.createOne2Net(name); } /** * @see org.jcsp.net.cns.NamedChannelEndFactory#createOne2Net(String, NameAccessLevel) */ public static NetChannelOutput createOne2Net(String name, NameAccessLevel accessLevel) { return CHAN_FACTORY.createOne2Net(name, accessLevel); } /** * @see org.jcsp.net.cns.NamedChannelEndFactory#createAny2Net(String) */ public static NetSharedChannelOutput createAny2Net(String name) { return CHAN_FACTORY.createAny2Net(name); } /** * @see org.jcsp.net.cns.NamedChannelEndFactory#createAny2Net(String, NameAccessLevel) */ public static NetSharedChannelOutput createAny2Net(String name, NameAccessLevel accessLevel) { return CHAN_FACTORY.createAny2Net(name, accessLevel); } public static void destroyChannelEnd(NetChannelInput chanInEnd) { CHAN_FACTORY.destroyChannelEnd(chanInEnd); } public static void destroyChannelEnd(NetChannelOutput chanOutEnd) { CHAN_FACTORY.destroyChannelEnd(chanOutEnd); } /*----------------Static method for installing CNS into current Node----------*/ /** * Installs and starts a Channel Name Server on the local Node. * The service is installed with the default service name as specified * by CNS.CNS_DEFAULT_SERVICE_NAME. This method needs to be * supplied with the local Node's NodeKey. This is * required in order to obtain access to the Node's service manager. * * @param key the local Node's NodeKey. * * @throws ServiceInstallationException if installation fails. * * @return the CNS object installed. */ public static CNS install(NodeKey key) { return install(key, CNS_DEFAULT_SERVICE_NAME); } /** * Installs and starts a Channel Name Server on the local Node. * The service is installed with the specified service name. This * method needs to be supplied with the local Node's NodeKey. * This is required in order to obtain access to the Node's service * manager. * * @param key the local Node's NodeKey. * @param name the name to give the service. * * @throws ServiceInstallationException if installation fails. * * @return the CNS object installed. */ public static CNS install(NodeKey key, String serviceName) { ServiceManager sm = Node.getInstance().getServiceManager(key); //Initialize the CNS Server Process CNS cns = new CNS(key); if (sm.installService(cns, serviceName)) { if (sm.startService(serviceName)) { Node.info.log("org.jcsp.net.cns.CNS", "CNS Started"); return cns; } else { sm.uninstallService(serviceName); throw new ServiceInstallationException("Failed to start service."); } } else { Node.info.log("org.jcsp.net.cns.CNS", "CNS failed to start"); throw new ServiceInstallationException("Failed to install service."); } } /*----------------Inner Classes-----------------------------------------------*/ /** * A data structure for holding a channel name and access level. * This can be used as a key in a Hashtable. */ static class NameAndLevel { NameAndLevel(String name, NameAccessLevel nameAccessLevel) { this.name = name; this.nameAccessLevel = nameAccessLevel; } /** Compares this object with another object. * @param o An object to compare with this object. * @return true iff o is a non-null NameAndLevel * object which represents the same name and level as this object. */ public boolean equals(Object o) { if (o == null || !(o instanceof NameAndLevel)) return false; NameAndLevel other = (NameAndLevel) o; //should be able to use == check for nameAccessLevel as only //static nameAccessLevel's are accessible return name.equals(other.name) && nameAccessLevel.equals(other.nameAccessLevel); } /** Returns a hash code for this object. * @return an int hash code for this object. */ public int hashCode() { return name.hashCode() + nameAccessLevel.hashCode(); } /** Returns a human readable String representation of this NameAccessLevel object. * @return the human readable string as a String object. */ public String toString() { return "[" + name + ", " + nameAccessLevel + "]"; } private String name; private NameAccessLevel nameAccessLevel; } static private class PendingResolve { CNSMessage.ResolveReply reply; ChannelOutput txReplyChannel; String channelName; NameAccessLevel nameAccessLevel; PendingResolve next; PendingResolve(CNSMessage.ResolveReply reply, ChannelOutput txReplyChannel, String channelName, NameAccessLevel nameAccessLevel) { this.channelName = channelName; this.nameAccessLevel = nameAccessLevel; this.reply = reply; this.txReplyChannel = txReplyChannel; next = null; } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/CNSNetChannelLocation.java0000644000000000000000000001041611105701167021433 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import org.jcsp.net.*; /** *

* Instances of this class are returned by the resolve methods * of {@link CNSService}. JCSP.NET users cannot create * the objects directly. *

*

* The objects returned by the {@link CNSService} can be used * in place of normal NetChannelLocation objects. *

* @author Quickstone Technologies Limited */ public class CNSNetChannelLocation extends NetChannelLocation { /*-----------Constructors----------------------------------------------------*/ CNSNetChannelLocation(NetChannelLocation locToClone, String name, NameAccessLevel accessLevel, CNSService cnsService, String cnsServiceName) { super(locToClone); this.name = name; this.accessLevel = accessLevel; this.cnsResolver = cnsService; this.cnsServiceName = cnsServiceName; } /*-----------Private fields--------------------------------------------------*/ private String name; private NameAccessLevel accessLevel; private transient CNSUser cnsResolver = null; private String cnsServiceName = null; /*-----------Overriden methods from NetChannelLocation-----------------------*/ /** * This method requests that the instance of this class refresh * its information. * * The method will re-resolve the location of the * NetChannelInput from the channel name server. * * @return true if any information has changed, otherwise * false. * */ public boolean refresh() { NetChannelLocation refreshed = null; if (cnsResolver == null) //obtain a reference to the installed CNS this.cnsResolver = (CNSUser) Node.getInstance().getServiceUserObject(this.cnsServiceName); if (accessLevel == null) refreshed = cnsResolver.resolve(name); else refreshed = cnsResolver.resolve(name, accessLevel); if (!this.equals(refreshed)) { //CNS has updated the location object refreshFrom(refreshed); return true; } else //nothing has changed return false; } /*-----------Other public methods--------------------------------------------*/ }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/ChannelNameException.java0000644000000000000000000000462711105701167021416 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; /** * An exception caused by an invalid channel name. * * @author Quickstone Technologies Limited */ public class ChannelNameException extends IllegalArgumentException { /** * Default constructor. */ public ChannelNameException() { super(); } /** * Constructor. * * @param description Description of the error. */ public ChannelNameException(String description) { super(description); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns/ChannelNameKey.java0000644000000000000000000000704611105701167020206 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net.cns; import java.util.*; import java.io.*; /** * Instances of this hold a key for a particular channel. * ChannelNameKey objects are issued by the channel * name server. They must be supplied to the channel name server * along with any channel management requests (channel deregistration, * relocation etc.). * * This class has no public constructor. * * @author Quickstone Technologies Limited */ public final class ChannelNameKey implements Serializable { private int hashCode; private final long val; private final long key; ChannelNameKey(long val) { this.val = val; Random rnd = new Random(System.currentTimeMillis() - Runtime.getRuntime().freeMemory() + val); key = rnd.nextLong(); hashCode = new Long(val).hashCode(); } /** * Compares another Object with this * ChannelNameKey. * * @param o the other Object to compare with * this Object. * @return true iff o is a non-null * ChannelNameKey object which holds the * same key as this object. */ public boolean equals(Object o) { if (o == null || !(o instanceof ChannelNameKey)) return false; ChannelNameKey other = (ChannelNameKey) o; return val == other.val && key == other.key; } /** * Returns an int hash code for this object. * * @return an int hash code. */ public int hashCode() { return hashCode; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NodeUI.java0000644000000000000000000001625511105701167015726 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; import java.lang.reflect.*; /** *

* A Unique Identifier for a Node. * This class is different from NodeID in that it does not describe the * Node's location. *

*

* Implementations of this class should provide a constructor that takes a * String parameter which is in the format of the String * returned from the getImplStringForm() method. *

* * @author Quickstone Technologies Limited */ public abstract class NodeUI implements Serializable, Comparable { final String getStringForm() { String[] array = new String[2]; array[0] = this.getClass().getName(); array[1] = getImplStringForm(); return Utils.arrayToString(array); } /** Returns a String that can be supplied to the * static createFromStringForm(String) method in order to * create an equal NodeUI object. * * @return a String containing the necessary information to recreate this NodeUI object. */ protected abstract String getImplStringForm(); /** Creates a NodeUI from a String in the format of that returned from the * getImplStringForm() method. * @param stringForm the String to use in creating the NodeUI object. * @return a newly created NodeUI object. */ public static final NodeUI createFromStringForm(String stringForm) { String[] strings = Utils.stringToArray(stringForm); if(strings.length < 2) throw new IllegalArgumentException("Incorrect string supplied."); try { Class nodeUIClass = Class.forName(strings[0]); Constructor constr = nodeUIClass.getConstructor(new Class[] {String.class}); NodeUI instance = (NodeUI)constr.newInstance(new Object[] {strings[1]}); return instance; } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Constructor with String does not exist."); } catch (Exception e) { throw new IllegalArgumentException("Unable to create constructor from String provided."); } } /** Compares this NodeUI with another object. * This method checks that the supplied object is a NodeUI object * and then calls the implementation of the checkEqual(NodeUI) * method and returns its result value as the result of this method. * @param o an object to compare with this object. * @return true iff the supplied object is a NodeUI and the * result of a call to the checkEqual(NodeUI) method is true. */ public final boolean equals(Object o) { if(o == null || !(o instanceof NodeUI) || !(this.getClass().equals(o.getClass()))) return false; return checkEqual((NodeUI) o); } /** Compares this NodeUI with another object. This method * calls the implementation of the getComparisonString() method * on both this NodeUI object and the NodeUI object * supplied. The String class' compareTo(Object) is * used to perform the comparison. The method is called on the String * returned by this object and the String returned by the other object * is supplied as the parameter. * @param o another object to compare with this object. * @throws ClassCastException if the supplied object is not a NodeUI object. * @return an int value that follows the rules of the * compareTo(Object) method in the String class. */ public final int compareTo(Object o) throws ClassCastException { NodeUI other = (NodeUI) o; return getComparisonString().compareTo(other.getComparisonString()); } /** * An abstract method to be implemented to return whether another * NodeUI object is equal to this instance. If the the * NodeUI is of a different implementation class, the method * should return false. * @param other a NodeUI to compare with this NodeUI. * @return true iff the supplied NodeUI is equal to this one. */ protected abstract boolean checkEqual(NodeUI other); /** This is an abstract method that should be implemented to return a * String that can be used by the compareTo(Object) * method in order to compare two NodeUI objects. * * Two NodeUI objects should return equal * String objects iff the two NodeUI objects are equal. * @return a String that follows the above rules. */ protected abstract String getComparisonString(); /** Returns an int hash code for this object. * Two NodeUI objects will return equal hash codes if the two objects * are equal. * @return an int hash code. */ public abstract int hashCode(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/DomainID.java0000644000000000000000000001526611105701167016230 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; /** *

* A Class whose instances represent a unique identifier for a JCSP.NET domain. *

*

* See {@link AbstractID} for a further explanation of domains and the use * of this class. *

* * @author Quickstone Technologies Limited */ public final class DomainID extends AbstractID implements Serializable, Comparable { private boolean nullDom = false; private String name = ""; private static final String NullDomainStringForm = "NullDomain"; private static final String DomainStringFormPrefix = "Domain :"; /** * Constructor which constructs an ID for the Null Domain. * */ DomainID() { //constructor for null domain nullDom = true; } /** * Public constructor for a DomainID which takes * the name of the domain as a parameter. * @param name The name of the domain. */ public DomainID(String name) { this.name = name; } /** * * @deprecated not needed now channel names abstracted */ static DomainID createFromStringForm(String str) throws IllegalArgumentException { if (str == null) throw new IllegalArgumentException("No String supplied"); if (str.equals(DomainStringFormPrefix + NullDomainStringForm)) return getNullDomainID(); else return new DomainID(str.substring(DomainStringFormPrefix.length())); } /** * This compares an object with this object. * @param o an object to compare with this object. * @return true iff the supplied object is a non-null DomainID which represents the same Domain. */ public boolean equals(Object o) { if (o == null || !(o instanceof DomainID)) return false; DomainID other = (DomainID) o; if (nullDom) { if (other.isNullDomain()) return true; return false; } //change later to make more secure return name.equals(other.getDomainName()); } /** *

* Returns an int hash code for the current object. *

*

* This obeys the standard hash code rules. *

* @return an int hash code. */ public int hashCode() { return name.hashCode(); } /** *

* Compares this object with another object and returns whether * the supplied object is equals, smaller or larger. *

* @param o The object to compare with this object. * @return 0 if the supplied object is equal, a negative integer if the supplied object is smaller or a positive integer if the other object is larger. */ public int compareTo(Object o) { DomainID other = (DomainID) o; if (nullDom && other.nullDom) return 0; return name.compareTo(other.name); } boolean onSameBranch(AbstractID abstractID) { if (abstractID == null) return false; if (abstractID instanceof GlobalID) return true; if (abstractID instanceof DomainID) return this.equals(abstractID); if (abstractID instanceof NodeID || abstractID instanceof ApplicationID) //abstractID below this in name hierachy - ask it return abstractID.onSameBranch(this); return false; } boolean isNullDomain() { return nullDom; } static DomainID getNullDomainID() { return new DomainID(); } /** *

* Public accessor for the Domain name. *

*

* Returns "" if this represents the Null Domain. *

* @return the domain name as a String. */ public String getDomainName() { return name; } /** *

* Returns a human readable String showing this domain * name and any parent domains. *

* @return the human readable String. */ public String toString() { if (nullDom) return "\\" + getParentID(); return getParentID() + "\\" + name; } /** * * @deprecated not needed now channel names abstracted */ String getStringForm() { if (nullDom) return DomainStringFormPrefix + NullDomainStringForm; else return DomainStringFormPrefix + name; } /** *

* Returns the identifier representing this domain's parent * domain. *

*

* At present this always returns the global domain's ID. *

* @return the parent AbstractID. */ public AbstractID getParentID() { return GlobalID.instance; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetAltingConnectionServer.java0000644000000000000000000000707611105701167021700 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; /** *

* Instances of this class are AltingConnectionServer * objects which allow connections from ConnectionClient * objects from over a JCSP.NET network. *

*

* Instances of this class are not guaranteed to be safe to use * by muliple concurrent processes. See * {@link NetSharedConnectionServer} for a server * class that may be used between multiple processes, however * this may not be ALTed over. *

*

* Instances can be constructed by using a * {@link NetConnectionFactory} or by * using the {@link NetConnection} class. *

* * @author Quickstone Technologies Limited */ class NetAltingConnectionServer extends AltingConnectionServerImpl implements NetConnectionServer { static NetAltingConnectionServer create() { //buffering done at sending end NetAltingChannelInput chan = NetChannelEnd.createNet2One(); return new NetAltingConnectionServer(chan); } private NetAltingChannelInput chan; private NetAltingConnectionServer(NetAltingChannelInput chan) { super(chan, chan); this.chan = chan; } /** * Returns the server's location. * * @return the server's NetChannelLocation * object. */ public NetChannelLocation getChannelLocation() { return chan.getChannelLocation(); } /** * Destroys the server and frees any resources used * in the JCSP.NET infrastructure. */ public void destroyServer() { chan.destroyReader(); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetConnection.java0000644000000000000000000000641211105701167017343 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* This class provides static methods for constructing * NetConnectionServer and NetConnectionClient * objects. *

*

* The methods provided are equivalent to the methods defined in * {@link NetConnectionFactory}. *

* * @author Quickstone Technologies Limited */ public class NetConnection { private static StandardNetConnectionFactory factory = new StandardNetConnectionFactory(); /** * @see org.jcsp.net.NetConnectionFactory#createNet2One() */ public static NetAltingConnectionServer createNet2One() { return factory.createNet2One(); } /** * @see org.jcsp.net.NetConnectionFactory#createNet2Any() */ public static NetSharedConnectionServer createNet2Any() { return factory.createNet2Any(); } /** * @see org.jcsp.net.NetConnectionFactory#createOne2Net(NetChannelLocation) */ public static NetAltingConnectionClient createOne2Net(NetChannelLocation serverLoc) { return factory.createOne2Net(serverLoc); } /** * @see org.jcsp.net.NetConnectionFactory#createAny2Net(NetChannelLocation) */ public static NetSharedAltingConnectionClient createAny2Net(NetChannelLocation serverLoc) { return factory.createAny2Net(serverLoc); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/Net2OneChannel.java0000644000000000000000000001360411105701167017341 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; import org.jcsp.util.ChannelDataStore; /** * A channel for network input (RX). This is a "Net2One" channel, * which can only be used by one reader at a time. * * @author Quickstone Technologies Limited */ class Net2OneChannel extends NetAltingChannelInput { static Net2OneChannel create(String label) { RejectableOne2OneChannel chan = new RejectableOne2OneChannel(); return new Net2OneChannel(label, chan.inAlt(), chan); } static Net2OneChannel create() { RejectableOne2OneChannel chan = new RejectableOne2OneChannel(); return new Net2OneChannel(chan.inAlt(), chan); } static Net2OneChannel create(ChannelDataStore buffer) { RejectableBufferedOne2OneChannel chan = new RejectableBufferedOne2OneChannel(buffer); return new Net2OneChannel(chan.inAlt(), chan); } static Net2OneChannel create(String label, ChannelDataStore buffer) { RejectableBufferedOne2OneChannel chan = new RejectableBufferedOne2OneChannel(buffer); return new Net2OneChannel(label, chan.inAlt(), chan); } /** * Creates a channel which receives data on a labelled VCN. * * @param label The label to apply to this channel's VCN. * @throws IllegalArgumentException if the label supplied * is a null reference. */ private Net2OneChannel(String label, AltingChannelInput actualChan, RejectableChannel ch) throws IllegalArgumentException { super(actualChan); if (label == null) throw new IllegalArgumentException("Label supplied is null"); if (label != "") Node.info.log(this, "Creating a channel with VCN label: " + label); this.label = label; netChannelInputProcess = new NetChannelInputProcess(label,ch); new ProcessManager(netChannelInputProcess).start(); } /** * Creates a zero-buffered channel reader. * The getChannelLocation() method can * be called to obtain the location information of the constructed * channel. */ private Net2OneChannel(AltingChannelInput actualChan, RejectableChannel ch) { super(actualChan); this.label = null; netChannelInputProcess = new NetChannelInputProcess(this.label,ch); new ProcessManager(netChannelInputProcess).start(); } /** * Returns a new NetChannelLocation object which holds the * information necessary for a networked ChannelOutput to * establish a connection to this channel reader. * * @return the location information for this channel reader. */ public NetChannelLocation getChannelLocation() { return new NetChannelLocation(Node.getInstance().getNodeID(), netChannelInputProcess.getChannelIndex()); } /** * Destroys this end of the channel. */ public void destroyReader() { netChannelInputProcess.breakChannel(); } /** * This method should not be called. The implementation channel is not * available to subclasses of Net2OneChannel. * * @return Always null. */ protected AltingChannelInput getChannel() { return null; } long getChannelIndex() { return netChannelInputProcess.getChannelIndex(); } public Class getFactoryClass() { return StandardNetChannelEndFactory.class; } /** * Currently, network channels are unpoisonable so this method has no effect. */ public void poison(PoisonException poison) { } /** * Currently, network channels are unpoisonable so this method will never throw a PoisonException */ public void checkPoison() throws PoisonException { } /*-----------------Attributes-------------------------------------------------*/ private final String label; private NetChannelInputProcess netChannelInputProcess; }jcsp-1.1-rc4.orig/src/org/jcsp/net/ReaderIndexException.java0000644000000000000000000000431211105701167020643 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * An exception that is thrown if data is written to a * Networked ChannelOutput and * the destination address is incorrect. * * @author Quickstone Technologies Limited */ public class ReaderIndexException extends RuntimeException { }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetChannelInputProcess.java0000644000000000000000000002032111105701167021166 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.*; /** * A process for network input (RX). * *

This is a package-private implementation class. * * @author Quickstone Technologies Limited */ // package-private class NetChannelInputProcess implements CSProcess { /** * Constructor which takes a label to assign to the channel's * VCN and a ChannelOutput object on which to output * any data received from over the network. * * @param label the label to assign to the VCN. If this is * null then no label will be assigned. * @param out the ChannelOutput object on which to * forward any data received from over the network. * * @author Jo Aldous */ NetChannelInputProcess(String label, RejectableChannel out) { this.out = out; IndexManager.ChannelAndIndex chanAndIndex = IndexManager.getInstance().getNewChannel(label); fromNetIn = chanAndIndex.channel.in(); fromNetOut = chanAndIndex.channel.out(); channelIndex = chanAndIndex.index; alt = new Alternative(new Guard[] {stopChannel.in(), fromNetIn}); channelID = new ChannelID(Node.getInstance().getNodeID(), channelIndex); } void breakChannel() { //Remove channel from index manager - must be done before rejecting any data IndexManager.getInstance().removeChannel(channelIndex,fromNetOut); //reject data from channel out.in().reject(); stopChannel.out().write(this); } long getChannelIndex() { return channelIndex; } /** * Reads a message from the network communications channel. * Acknowledges and ignores LinkLost messages.

* * @return The first Message read from the network. */ private Object readFromNetChannel() { int selection = alt.priSelect(); if(selection == 0) { stopChannel.in().read(); //request to stop the server - reject any more messages while (fromNetIn.pending()) { Object obj = fromNetIn.read(); if (obj instanceof LinkLost) { LinkLost cl = (LinkLost)obj; cl.txChannel.write(cl); // acknowlegement. } else { ChannelMessage.Data message; try { //reject any messages pending message = (ChannelMessage.Data)obj; } catch (ClassCastException e) { Node.err.log(this, "NetChannelInputProcess received an unexpected message type"); break; } ChannelMessage.WriteRejected writeRejected = new ChannelMessage.WriteRejected(); writeRejected.destIndex = message.sourceIndex; writeRejected.sourceIndex = channelIndex; // Send the rejection message.txReplyChannel.write(writeRejected); } } return null; } else { Object obj = fromNetIn.read(); while (obj instanceof LinkLost) { LinkLost cl = (LinkLost)obj; cl.txChannel.write(cl); // acknowlegement. obj = fromNetIn.read(); } return obj; } } /** * Handle this link. Gets data and sends acknowlegements. * Runs forever. */ public void run() { boolean stop = false; while (stop == false) { // Read a message from TCP/IP. Object obj = readFromNetChannel(); if(obj == null) { stop = true; Node.info.log(this, "NetChanInProc stopping"); } else if (obj instanceof ChannelMessage.Data) { // Deal with it. ChannelMessage.Data message = (ChannelMessage.Data)obj; // Output the data (will block until the user process reads it) try { out.out().write(message.data); if (message.acknowledged) { // Prepare an acknowlegement message //ChanndelMessage.Ack ack = new ChannelMessage.Ack(); ChannelMessage.Ack ack = null; if(sendAckA) ack = this.ackA; else ack = this.ackB; this.sendAckA = !sendAckA; ack.destIndex = message.sourceIndex; ack.sourceIndex = channelIndex; // Send the acknowlegement message.txReplyChannel.write(ack); } } catch (ChannelDataRejectedException e) { //data never read e.printStackTrace(); if (message.acknowledged) { ChannelMessage.WriteRejected writeRejected = new ChannelMessage.WriteRejected(); writeRejected.destIndex = message.sourceIndex; writeRejected.sourceIndex = channelIndex; // Send the rejection message.txReplyChannel.write(writeRejected); } } } else { Node.err.log(this, "Unexpected message type received: " + obj.getClass()); } } } /** * Our channel index. */ private long channelIndex; /** * Our channel ID. */ private ChannelID channelID; /** * The name of this channel. */ private String name; /** * The channel we use for recieving from the demuxes. */ private AltingChannelInput fromNetIn; private SharedChannelOutput fromNetOut; /** * The channel used for output. */ private RejectableChannel out; private Any2OneChannel stopChannel = Channel.any2one(); private Alternative alt; private transient ChannelMessage.Ack ackA = new ChannelMessage.Ack(); private transient ChannelMessage.Ack ackB = new ChannelMessage.Ack(); private transient boolean sendAckA = true; }jcsp-1.1-rc4.orig/src/org/jcsp/net/Profile.java0000644000000000000000000002000311105701167016165 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.net.settings.*; import java.util.*; /** *

* This class is used to hold profiles of Nodes and Links. *

*

* Node profiles are not currently used. *

* * Profile functionality is still being implemented. * * @author Quickstone Technologies Limited */ public class Profile { static void createNewLinkProfile(String name, Requirement[] requirements, boolean exact) { Profile p = new Profile(name, requirements, exact, false); linkProfiles.put(name, p); } static void createNewNodeProfile(String name, Requirement[] requirements, boolean exact) { Profile p = new Profile(name, requirements, exact, false); nodeProfiles.put(name, p); } /** Returns a link profile of a certain name from a static collection of * link profiles. * @param name the name of the Profile to obtain. * @return a matching link profile or null if no match is found. */ public static Profile getLinkProfile(String name) { return (Profile)linkProfiles.get(name); } /** Returns a Node profile of a certain name from a static collection of * Node profiles. * @param name the name of the Profile to obtain. * @return a matching Node profile or null if no match is found. */ public static Profile getNodeProfile(String name) { return (Profile)nodeProfiles.get(name); } static Profile getAlwaysMatchProfile() { return alwaysMatchProfile; } private static Profile alwaysMatchProfile = new Profile("AlwaysMatchProfile", new Requirement[] {}, false, true); static Profile getProtocolProfile(ProtocolID protocolID) { return new Profile("ProtocolProfile " + protocolID.getPosition(), new Requirement[] { new Requirement(XMLConfigConstants.REQ_NAME_PROTOCOL, XMLConfigConstants.SPEC_NAME_PROTOCOL, XMLConfigConstants.REQ_COMPARATOR_EQUALS, protocolID.getClass().toString()) }, false, true); } private static Hashtable linkProfiles = new Hashtable(); private static Hashtable nodeProfiles = new Hashtable(); private Profile(String name, Requirement[] requirements, boolean exact, boolean system) { this.name = name; this.exact = exact; this.system = system; this.requirements = requirements; Arrays.sort(requirements, new Comparator() { public int compare(Object o1, Object o2) { Requirement r1 = (Requirement) o1; Requirement r2 = (Requirement) o2; return r1.specName.compareTo(r2.specName); } }); } /** * This tests whether a an array of Specification objects meet the * requirements of this profile. * * This method will sort the array of specs in order of name. This sort * will change the original array. * * @returns -1 if the specs do not match, 0 if they do not contradict or * 1 if they are a positive match. */ int matches(Specification[] specs) { //sort the array if(specs == null) { if(requirements == null || requirements.length == 0) return 1; else return 0; } Arrays.sort(specs, new Comparator() { public int compare(Object o1, Object o2) { Specification s1 = (Specification) o1; Specification s2 = (Specification) o2; return s1.name.compareTo(s2.name); } }); int match = 0; int rPos = 0; int sPos = 0; while(rPos < requirements.length && sPos < specs.length && match != -1) { int comparison = requirements[rPos].specName.compareTo(specs[sPos].name); if(comparison == 0) { if(requirements[rPos].matches(specs[sPos])) match++; else //match failed - return as profile definitely doesn't match return -1; rPos++; } else if(comparison < 0) rPos++; else if(comparison > 0) sPos++; } if (match == requirements.length) //every requirement had a match return 1; else //no requirement was contradicted by a specification but //there were insufficient specifications to match //all the requirements return 0; } boolean requiresExactMatch() { return exact; } /** Compares this Profile with another object. * @param o another object to compare with this object. * @return true iff the supplied object is a Profile object that * is exactly equal. */ public boolean equals(Object o) { if(o==null || !(o instanceof Profile)) return false; Profile other = (Profile) o; return name.equals(other.name) && Arrays.equals(requirements, other.requirements) && exact == other.exact && system == other.system; } /** * Returns a hash code for this object that follows the * standard rule for hash codes stated in the Object class. * @return an int hash code for this object. */ public int hashCode() { return name.hashCode(); } private String name; private boolean exact; private boolean system; private Requirement[] requirements; }jcsp-1.1-rc4.orig/src/org/jcsp/net/StandardNetConnectionFactory.java0000644000000000000000000000627311105701167022361 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* This is an implementation of {@link NetConnectionFactory}. *

* * @author Quickstone Technologies Limited */ public class StandardNetConnectionFactory implements NetConnectionFactory { /** * Constructor for StandardNetConnectionFactory. */ public StandardNetConnectionFactory() { super(); } /** * @see org.jcsp.net.NetConnectionFactory#createNet2One() */ public NetAltingConnectionServer createNet2One() { return NetAltingConnectionServer.create(); } /** * @see org.jcsp.net.NetConnectionFactory#createNet2Any() */ public NetSharedConnectionServer createNet2Any() { return NetSharedConnectionServerImpl.create(); } /** * @see org.jcsp.net.NetConnectionFactory#createOne2Net(NetChannelLocation) */ public NetAltingConnectionClient createOne2Net(NetChannelLocation serverLoc) { return NetAltingConnectionClient.create(serverLoc); } /** * @see org.jcsp.net.NetConnectionFactory#createAny2Net(NetChannelLocation) */ public NetSharedAltingConnectionClient createAny2Net(NetChannelLocation serverLoc) { return NetSharedAltingConnectionClient.create(serverLoc); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetChannelEnd.java0000644000000000000000000001141511105701167017242 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.util.ChannelDataStore; /** *

* This class provides static factory methods for constructing * Networked channel ends. *

*

* The methods are equivalent to the methods defined in * {@link NetChannelEndFactory}. *

* * @author Quickstone Technologies Limited */ public class NetChannelEnd { private static StandardNetChannelEndFactory factory = StandardNetChannelEndFactory.getDefaultInstance(); private NetChannelEnd() { //private constructor to prevent instantiation } /** * @see org.jcsp.net.NetChannelEndFactory#createNet2One() */ public static NetAltingChannelInput createNet2One() { return factory.createNet2One(); } /** * @see org.jcsp.net.NetLabelledChannelEndFactory#createNet2One(String) */ public static NetAltingChannelInput createNet2One(String label) { return factory.createNet2One(label); } /** * @see org.jcsp.net.NetBufferedChannelEndFactory#createNet2One(ChannelDataStore) */ public static NetAltingChannelInput createNet2One(ChannelDataStore buffer) { return factory.createNet2One(buffer); } /** * @see org.jcsp.net.NetLabelledBufferedChannelEndFactory#createNet2One(String, ChannelDataStore) */ public static NetAltingChannelInput createNet2One(String label, ChannelDataStore buffer) { return factory.createNet2One(label, buffer); } /** * @see org.jcsp.net.NetChannelEndFactory#createNet2Any() */ public static NetSharedChannelInput createNet2Any() { return factory.createNet2Any(); } /** * @see org.jcsp.net.NetLabelledChannelEndFactory#createNet2Any(String) */ public static NetSharedChannelInput createNet2Any(String label) { return factory.createNet2Any(label); } /** * @see org.jcsp.net.NetBufferedChannelEndFactory#createNet2Any(ChannelDataStore) */ public static NetSharedChannelInput createNet2Any(ChannelDataStore buffer) { return factory.createNet2Any(buffer); } /** * @see org.jcsp.net.NetLabelledBufferedChannelEndFactory#createNet2Any(String, ChannelDataStore) */ public static NetSharedChannelInput createNet2Any(String label, ChannelDataStore buffer) { return factory.createNet2Any(label, buffer); } /** * @see org.jcsp.net.NetChannelEndFactory#createOne2Net(NetChannelLocation) */ public static NetChannelOutput createOne2Net(NetChannelLocation loc) { return factory.createOne2Net(loc); } /** * @see org.jcsp.net.NetChannelEndFactory#createAny2Net(NetChannelLocation) */ public static NetSharedChannelOutput createAny2Net(NetChannelLocation loc) { return factory.createAny2Net(loc); } }jcsp-1.1-rc4.orig/src/org/jcsp/net/DeserializeChannelFilter.java0000644000000000000000000001113111105701167021466 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.io.*; import org.jcsp.util.filter.*; // Not sure if this class should be public /** * This class is used in the dynamic class loading mechanism. * Instances of the class extract Message objects from SerializedMessage objects. * Dynamic class loading can be enabled by using the constructor which takes a ClassManager. * If dynamic class loading is enabled and a DynamicClassLoaderMessage is filtered, * the ClassManager object is supplied to the Message object and the underlying message extracted. * Any classes that need loading from the remote Node are requested and loaded as necessary. * * @author Quickstone Technologies Limited */ class DeserializeChannelFilter implements Filter { /* 5 Jun 2002 * * This class was originally used by the dynamic class loading * mechanism as well as the LoopBackLink * * Have now moved dynamic class loading mechanism into separate * package and so have modified this class just to be used * by LoopbackLink. * DeserializeChannelFilter(ClassManager cm) { this.cm = cm; this.dynamic = true; } */ DeserializeChannelFilter() { } /** This method takes an object and substitutes it for another object based upon the following rules: * * If the object is an instance of the DynamicClassLoaderMessage class and dynamic class loading is enabled, * then the filter will return the object returned by the supplied object's get method. A ClassManager will be * supplied to the method. * * If the object is an instance of the SerializedMessage class then the object's get * method will be called. The message being held by the SerializedMessage will be deserialized * but classes will not be dynamically loaded. * * If the object is not a SerializedMessage object, then the object itself will be returned without * modification. * @param object The object to filter. * @return the substituted object. */ public Object filter(Object object) { try { if (object instanceof SerializedMessage) return ((SerializedMessage)object).get(); else return object; } catch (ClassNotFoundException e) { Node.err.log(this, e); } catch (IOException e) { Node.err.log(this, e); } //return object at the moment decide later - this is only prototype version return object; } }jcsp-1.1-rc4.orig/src/org/jcsp/net/cns.xml0000644000000000000000000000102410520670125015230 0ustar
jcsp-1.1-rc4.orig/src/org/jcsp/net/NodeKey.java0000644000000000000000000000437611105701167016142 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** *

* An object that is returned when the Node is initialized. It * is required for any Node management operations. *

* * @author Quickstone Technologies Limited */ public final class NodeKey { /** * This should only be constructed in the Node class. * */ NodeKey() { } }jcsp-1.1-rc4.orig/src/org/jcsp/net/ChannelIndexMap.java0000644000000000000000000001431211105701167017571 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.util.Enumeration; import java.util.NoSuchElementException; import org.jcsp.lang.ChannelOutput; import org.jcsp.lang.SharedChannelOutput; /** * * @author Quickstone Technologies Limited. */ class ChannelIndexMap { public ChannelIndexMap(int size, float loadFactor) { this.size = size; this.loadFactor = loadFactor; this.threshold = (int)(size * loadFactor); this.count = 0; data = new Entry[size]; } public ChannelOutput get(long key) { int dataIndex = (int)(key % size); if(data[dataIndex] != null) { for(Entry e = data[dataIndex]; e != null; e = e.next) if(e.key == key) return e.value; } return null; } /** * Puts a value into the index if the key does not already exist. * * */ public boolean put(long key, SharedChannelOutput value) { count++; if(count > threshold) rehash(); final int dataIndex = (int) (key % size); final Entry head = data[dataIndex]; for(Entry e = head; e != null; e = e.next) if(e.key == key) return false; //There is no matching key if(entryPool == null) //no entries in pool - create one data[dataIndex] = new Entry(key,value,head); else { //take an entry from the pool Entry e = entryPool; entryPool = e.next; e.key = key; e.value = value; e.next = head; data[dataIndex] = e; } return true; } public boolean remove(long key, SharedChannelOutput ch) { int dataIndex = (int) (key % size); Entry prev = null; for(Entry e = data[dataIndex]; e != null; e = e.next) { if(e.key == key) { if(e.value != ch) return false; if(prev == null) data[dataIndex] = e.next; else prev.next = e.next; e.next = entryPool; entryPool = e; entryPool.value = null; count--; return true; } else prev = e; } return false; } private void rehash() { Entry oldMap[] = data; int oldCapacity = size; //update size with the new capacity size = oldCapacity * 2 + 1; Entry newMap[] = new Entry[size]; threshold = (int)(size * loadFactor); data = newMap; for (int i = oldCapacity ; i-- > 0 ;) { for (Entry old = oldMap[i] ; old != null ; ) { Entry e = old; old = old.next; int index = (int)(e.key % size); e.next = newMap[index]; newMap[index] = e; } } } public Enumeration getChannels() { return new Enumeration() { public boolean hasMoreElements() { return returnCount < count; } public Object nextElement() { while(nextEntry == null && bucketIndex < data.length) { bucketIndex++; nextEntry = data[bucketIndex]; } if(nextEntry == null) throw new NoSuchElementException(); ChannelOutput value = nextEntry.value; nextEntry = nextEntry.next; returnCount++; return value; } int bucketIndex = -1; int returnCount = 0; Entry nextEntry = null; }; } public void emptyPool() { entryPool = null; } private int threshold; private int count; private float loadFactor; private int size; private Entry[] data; private Entry entryPool = null; private static class Entry { long key; ChannelOutput value; Entry next; Entry(long key,ChannelOutput value,Entry next) { this.key = key; this.value = value; this.next = next; } Entry(long key,ChannelOutput value) { this.key = key; this.value = value; } } }jcsp-1.1-rc4.orig/src/org/jcsp/net/NetChannelInput.java0000644000000000000000000000546611105701167017644 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import org.jcsp.lang.ChannelInput; /** *

* An interface implemented by classes wishing to be Networked * ChannelInput objects. *

*

* Implementing this interface does not guarantee that the input * end can be used by multiple concurrent processes nor can it * necessarily be ALTed over. *

* @see NetAltingChannelInput * * @author Quickstone Technologies Limited */ public interface NetChannelInput extends ChannelInput, Networked { /** *

* Returns a Class file of the factory used to construct the * channel end. *

* * @return the Class of the factory class. */ public Class getFactoryClass(); /** *

* Destroys the channel end and frees any resources within * the JCSP.NET infrastructure. *

*/ public void destroyReader(); }jcsp-1.1-rc4.orig/src/org/jcsp/net/IndexManager.java0000644000000000000000000001701111105701167017134 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; import java.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.util.filter.*; /** * * @author Quickstone Technologies Limited. */ class IndexManager { /*-------------------Singleton Class Instance---------------------------------*/ private static IndexManager instance = new IndexManager(); /*-------------------Private Constructor--------------------------------------*/ IndexManager() { } /*----------------------Methods-----------------------------------------------*/ public static IndexManager getInstance() { return instance; } synchronized ChannelAndIndex getNewChannel(String label) { long index = indexValue++; while(channels.get(index) != null) index = indexValue++; FilteredAny2OneChannel fromNet = FilteredChannel.createAny2One(new InfiniteBuffer()); channels.put(index, fromNet.out()); ChannelAndIndex toReturn = new ChannelAndIndex(fromNet, index); if (label != null) { // a label must be assigned to the channel index if (labelToIndexMap.containsKey(label)) throw new DuplicateChannelLabelException("Channel already exists with VCN label of " + label); Long longVal = new Long(index); labelToIndexMap.put(label, longVal); indexToLabelMap.put(longVal, label); } return toReturn; } synchronized ChannelAndIndex getNewReplyChannel(One2NetChannel writer) { long index = indexValue++; while(channels.get(index) != null) index = indexValue++; FilteredAny2OneChannel fromNet = FilteredChannel.createAny2One(new AcknowledgementsBuffer()); channels.put(index, fromNet.out()); ChannelAndIndex toReturn = new ChannelAndIndex(fromNet, index); replyChannels.put(fromNet.out(), writer); return toReturn; } synchronized void removeChannel(long channelIndex, SharedChannelOutput currentChannel) { replyChannels.remove(currentChannel); if (channels.remove(channelIndex, currentChannel)) { try { FilteredChannelOutput filtered = (FilteredChannelOutput) currentChannel; filtered.addWriteFilter(POISON_FILTER); } catch (ClassCastException e) { e.printStackTrace(); } Object label = indexToLabelMap.remove(new Long(channelIndex)); if (label != null) labelToIndexMap.remove(label); } else Node.err.log(this, "Request to remove channel from IndexManager failed."); } synchronized void addReservedChannel(SharedChannelOutput channel, long channelIndex) { if (channel == null) throw new NullPointerException(); //This returns false if the channelIndex has already been used if(!channels.put(channelIndex, channel)) throw new IllegalArgumentException("Channel index " + channelIndex + " is not a reserved channel"); } synchronized ChannelOutput getRxChannel(long channelIndex) { return channels.get(channelIndex); } synchronized ChannelOutput getRxChannel(String vcnLabel) { Long channelIndex = (Long) labelToIndexMap.get(vcnLabel); if (channelIndex != null) return getRxChannel(channelIndex.longValue()); return null; } synchronized int broadcast(Object message) { int count = 0; for (Enumeration en = channels.getChannels(); en.hasMoreElements();) { ChannelOutput ch = (ChannelOutput)en.nextElement(); if (ch != null) { count++; ch.write(message); } } return count; } /** * Reply channels have their destroyWriter method called. Other channels get sent the * broadcast message. */ synchronized int broadcastLinkLost(Object message) { int count = 0; for (Enumeration en = channels.getChannels(); en.hasMoreElements();) { ChannelOutput ch = (ChannelOutput)en.nextElement(); if (ch != null) { One2NetChannel nco = (One2NetChannel)replyChannels.get(ch); if (nco != null) nco.linkFailed(((LinkLost)message).address); else { count++; ch.write(message); } } } return count; } static boolean checkIndexIsValid(long vcn) { return (vcn != -1); } static long getInvalidVCN() { return -1; } /*----------------------Attributes--------------------------------------------*/ //a load factor of three seems quite efficient private ChannelIndexMap channels = new ChannelIndexMap(23, 3f); private long indexValue = 0; //private DeserializeChannelFilter dcf; private Hashtable labelToIndexMap = new Hashtable(); private Hashtable indexToLabelMap = new Hashtable(); private Hashtable replyChannels = new Hashtable(); public static final long CNS_CHANNEL_INDEX = 0; private static final PoisonFilter POISON_FILTER = new PoisonFilter("Channel disabled by IndexManager"); static class ChannelAndIndex { public ChannelAndIndex(Any2OneChannel channel, long index) { this.channel = channel; this.index = index; } public final Any2OneChannel channel; public final long index; } } jcsp-1.1-rc4.orig/src/org/jcsp/net/NetConnectionLocation.java0000644000000000000000000000556311105701167021042 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.net; /** * Instances of this class take two NetConnectionLocation * objects. One for a connection's server channel and one for a * connection's further request channel. * * Instances of this class can be used as the open channel's * NetChannelLocation object while the further request * channel's can be obtained by calling * getRequestChannelLocation(). * * @author Quickstone Technologies Limited */ class NetConnectionLocation extends NetChannelLocation { private NetChannelLocation reqLoc; /** * Constructor for NetConnectionLocation. * @param other * @throws IllegalArgumentException */ public NetConnectionLocation(NetChannelLocation open, NetChannelLocation req) throws IllegalArgumentException { super(open); this.reqLoc = req; } public NetChannelLocation getRequestChannelLocation() { return this.reqLoc; } }jcsp-1.1-rc4.orig/src/org/jcsp/test/0000755000000000000000000000000011410045043014111 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/test/WriterProcess.java0000644000000000000000000000332510657566574017627 0ustar package org.jcsp.test; import java.security.InvalidParameterException; import java.util.Arrays; import java.util.List; import org.jcsp.lang.AltingBarrier; import org.jcsp.lang.CSProcess; import org.jcsp.lang.ChannelOutput; /** * A process that writes out a list of values, synchronizing on the corresponding barrier after each. * * * @author N.C.C. Brown * */ public class WriterProcess implements CSProcess { private ChannelOutput out; private List values; private AltingBarrier[][] events; public WriterProcess(ChannelOutput out,List values,AltingBarrier[][] events) { if (values.size() != events.length) { throw new InvalidParameterException("Values must be the same length as Events"); } this.out = out; this.values = values; this.events = events; } public WriterProcess(ChannelOutput out,List values,AltingBarrier event) { this.out = out; this.values = values; this.events = new AltingBarrier[values.size()][]; Arrays.fill(this.events,new AltingBarrier[] {event}); } public void run() { for (int i = 0;i < events.length;i++) { AltingBarrier[] barriers = events[i]; for (int j = 0;j < barriers.length;j++) { AltingBarrier barrier = barriers[j]; if (barrier != null) { barrier.mark(); } } } for (int i = 0;i < values.size();i++) { out.write(values.get(i)); AltingBarrier[] barriers = events[i]; for (int j = 0;j < barriers.length;j++) { AltingBarrier barrier = barriers[j]; if (barrier != null) { barrier.sync(); } } } } } jcsp-1.1-rc4.orig/src/org/jcsp/test/ExtendedReaderSyncInt.java0000644000000000000000000000417110657566574021207 0ustar package org.jcsp.test; import java.security.InvalidParameterException; import java.util.Arrays; import org.jcsp.lang.AltingBarrier; import org.jcsp.lang.CSProcess; import org.jcsp.lang.ChannelInputInt; /** * A process that performs a set number of extended inputs, syncing on a barrier * as its extended action for each * * @author N.C.C. Brown * */ public class ExtendedReaderSyncInt implements CSProcess { private AltingBarrier[][] events; private ChannelInputInt input; private int iterations; private int[] valuesRead; public ExtendedReaderSyncInt(AltingBarrier[][] barriers, ChannelInputInt in, int iterations) { if (barriers.length != iterations) { throw new InvalidParameterException("Barriers must be the same length as iterations"); } this.events = barriers; this.input = in; this.iterations = iterations; valuesRead = new int[iterations]; } public ExtendedReaderSyncInt(AltingBarrier barrier, ChannelInputInt in, int iterations) { this.events = new AltingBarrier[iterations][]; Arrays.fill(this.events,new AltingBarrier[] {barrier}); this.input = in; this.iterations = iterations; valuesRead = new int[iterations]; } public void run() { for (int i = 0;i < events.length;i++) { AltingBarrier[] barriers = events[i]; for (int j = 0;j < barriers.length;j++) { AltingBarrier barrier = barriers[j]; if (barrier != null) { barrier.mark(); } } } for (int i = 0;i < iterations;i++) { valuesRead[i] = input.startRead(); AltingBarrier[] barriers = events[i]; if (barriers.length > 0) { AltingBarrier barrier = barriers[0]; if (barrier != null) { barrier.sync(); } } input.endRead(); if (barriers.length > 1) { AltingBarrier barrier = barriers[1]; if (barrier != null) { barrier.sync(); } } } } public int[] getValuesRead() { return valuesRead; } } jcsp-1.1-rc4.orig/src/org/jcsp/test/ExtendedReaderSync.java0000644000000000000000000000416010657566574020532 0ustar package org.jcsp.test; import java.security.InvalidParameterException; import java.util.Arrays; import org.jcsp.lang.AltingBarrier; import org.jcsp.lang.CSProcess; import org.jcsp.lang.ChannelInput; /** * A process that performs a set number of extended inputs, syncing on a barrier * as its extended action for each * * @author N.C.C. Brown * */ public class ExtendedReaderSync implements CSProcess { private AltingBarrier[][] events; private ChannelInput input; private int iterations; private Object[] valuesRead; public ExtendedReaderSync(AltingBarrier[][] barriers, ChannelInput in, int iterations) { if (barriers.length != iterations) { throw new InvalidParameterException("Barriers must be the same length as iterations"); } this.events = barriers; this.input = in; this.iterations = iterations; valuesRead = new Object[iterations]; } public ExtendedReaderSync(AltingBarrier barrier, ChannelInput in, int iterations) { this.events = new AltingBarrier[iterations][]; Arrays.fill(this.events,new AltingBarrier[] {barrier}); this.input = in; this.iterations = iterations; valuesRead = new Object[iterations]; } public void run() { for (int i = 0;i < events.length;i++) { AltingBarrier[] barriers = events[i]; for (int j = 0;j < barriers.length;j++) { AltingBarrier barrier = barriers[j]; if (barrier != null) { barrier.mark(); } } } for (int i = 0;i < iterations;i++) { valuesRead[i] = input.startRead(); AltingBarrier[] barriers = events[i]; if (barriers.length > 0) { AltingBarrier barrier = barriers[0]; if (barrier != null) { barrier.sync(); } } input.endRead(); if (barriers.length > 1) { AltingBarrier barrier = barriers[1]; if (barrier != null) { barrier.sync(); } } } } public Object[] getValuesRead() { return valuesRead; } } jcsp-1.1-rc4.orig/src/org/jcsp/test/AltTest.java0000644000000000000000000001044311113671251016344 0ustar /******************************************************************************* * * $Archive: /jcsp/src/test/jcsp/AltTest.java $ * * $Date: 1998/07/21 14:17:09 $ * * $Revision: 1.1 $ * * (C) Copyright 1997/8 Paul Austin * University of Kent Canterbury ******************************************************************************/ import org.jcsp.lang.*; import org.jcsp.plugNplay.*; /** *

Process Diagram

*

External View

*
 *  _________
 * |         |
 * | AltTest |
 * |_________|
 * 
*

Internal View

*
 *  ________________________________________________
 * |      _____           _____           _____     |
 * |     |     |         |     |         |     |    |
 * |     | Nos |         | Nos |         | Nos |    |
 * |     |_____|         |_____|         |_____|    |
 * |        |               |               |       |
 * |      a v             b v             c v       |
 * |  ______|_____    ______|_____    ______|_____  |
 * | |            |  |            |  |            | |
 * | | FixedDelay |  | FixedDelay |  | FixedDelay | |
 * | |____________|  |____________|  |____________| |
 * |        |               |               |       |
 * |      d v             e v             f v       |
 * |        |               |               |       |
 * |        +----->-----+   |   +-----<-----+       |
 * |                  __|___|___|_       _________  |
 * |                 |            |  g  |         | |
 * |                 |            |-->--| Printer | |
 * |                 |____________|     |_________| |
 * |                                                |
 * |                                        AltTest |
 * |________________________________________________|
 * 
*

*

Description

* The AltTest process is designed to test the Alternative class. *

* Each of the fixed delay processes have a delay time of 100, 200 or 300 * microseconds. *

* The anonymous CSProcess has an infinite loop which will ALT on the * channels d, e & f. When one of these Channels becomes ready with data * the process will write the index of the Channel and the data value down * the g Channel. * * @author P.D. Austin */ public class AltTest implements CSProcess { /** * The main body of this process. */ public void run () { One2OneChannel a = Channel.one2one (); One2OneChannel b = Channel.one2one (); One2OneChannel c = Channel.one2one (); final One2OneChannel d = Channel.one2one (); final One2OneChannel e = Channel.one2one (); final One2OneChannel f = Channel.one2one (); final One2OneChannel g = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Numbers (b.out ()), new Numbers (c.out ()), new FixedDelay (100, a.in (), d.out ()), new FixedDelay (200, b.in (), e.out ()), new FixedDelay (300, c.in (), f.out ()), new CSProcess () { public void run () { Guard[] chans = {d.in (), e.in (), f.in ()}; Alternative alt = new Alternative (chans); while (true) { switch (alt.select ()) { case 0: g.out ().write ("Channel 0 read " + d.in ().read () + "\n"); break; case 1: g.out ().write (" Channel 1 read " + e.in ().read () + "\n"); break; case 2: g.out ().write (" Channel 2 read " + f.in ().read () + "\n"); break; } } } }, new Printer (g.in ()) } ).run (); } /** * Main entry point for the application. */ public static void main (String argv[]) { new AltTest ().run (); } } jcsp-1.1-rc4.orig/src/org/jcsp/test/TestExtendedRendezvous.java0000644000000000000000000003440211103430320021437 0ustar package org.jcsp.test; import java.util.Arrays; import java.util.Collections; import junit.framework.TestCase; import org.jcsp.lang.AltingBarrier; import org.jcsp.lang.Any2AnyChannel; import org.jcsp.lang.Any2AnyChannelInt; import org.jcsp.lang.Any2OneChannel; import org.jcsp.lang.Any2OneChannelInt; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Channel; import org.jcsp.lang.ChannelInput; import org.jcsp.lang.ChannelInputInt; import org.jcsp.lang.ChannelInt; import org.jcsp.lang.ChannelOutput; import org.jcsp.lang.ChannelOutputInt; import org.jcsp.lang.Guard; import org.jcsp.lang.One2AnyChannel; import org.jcsp.lang.One2AnyChannelInt; import org.jcsp.lang.One2OneChannel; import org.jcsp.lang.One2OneChannelInt; import org.jcsp.lang.Parallel; import org.jcsp.lang.Sequence; import org.jcsp.util.Buffer; import org.jcsp.util.OverFlowingBuffer; import org.jcsp.util.ints.BufferInt; public class TestExtendedRendezvous extends TestCase { /** * Asserts that the two arrays are equal. The arrays are equal iff * they are the same length, and the Object references in them * are the same references (and in the same order) */ public void assertArraysEqual(Object[] a,Object[] b) { assertEquals(a.length,b.length); for (int i = 0;i < a.length;i++) { assertSame(a[i],b[i]); } } public void assertArraysEqual(int[] a,int[] b) { assertEquals(a.length,b.length); for (int i = 0;i < a.length;i++) { assertEquals(a[i],b[i]); } } public void helper_testChannelOneWriter(ChannelInput in,ChannelOutput out) { /* * This test checks that the reads and writes occur in the right order during an extended rendezvous * * Specifically , it checks that the extended action always occurs before the write has finished * * The event-recorder offers a read event, a write event and a terminate event * The terminate event is only done (by the BarrierSyncer) once the other processes have finished * * The writer offers the write event *after* each write. * The reader offers the single read event during each extended rendezvous. * * Therefore the events should be in lock-step: * read,write,read,write... */ AltingBarrier[] terminateEvent = AltingBarrier.create(2); AltingBarrier[] writeEvent = AltingBarrier.create(2); AltingBarrier[] readEvent = AltingBarrier.create(2); EventRecorder recorder; new Parallel( new CSProcess[] { recorder = new EventRecorder(new Guard[] {writeEvent[0],readEvent[0],terminateEvent[0]},2), new Sequence(new CSProcess[] { new Parallel( new CSProcess[] { new WriterProcess(out,Collections.nCopies(100,null),writeEvent[1]), new ExtendedReaderSync(readEvent[1],in,100) }), new BarrierSyncer(terminateEvent[1]) }) }).run(); Guard[] expectedEvents = new Guard[201]; for (int i = 0;i < 100;i++) { expectedEvents[i*2 + 0] = readEvent[0]; expectedEvents[i*2 + 1] = writeEvent[0]; } expectedEvents[200] = terminateEvent[0]; assertArraysEqual(expectedEvents,recorder.getObservedEvents()); } public void testNormalOne2OneChannel() { One2OneChannel chan = Channel.one2one(); helper_testChannelOneWriter(chan.in(), chan.out()); } public void testNormalAny2OneChannel() { Any2OneChannel chan = Channel.any2one(); helper_testChannelOneWriter(chan.in(), chan.out()); } public void testNormalOne2AnyChannel() { One2AnyChannel chan = Channel.one2any(); helper_testChannelOneWriter(chan.in(), chan.out()); } public void testNormalAny2AnyChannel() { Any2AnyChannel chan = Channel.any2any(); helper_testChannelOneWriter(chan.in(), chan.out()); } public void helper_testIntChannelOneWriter(ChannelInputInt in,ChannelOutputInt out) { /* * This test checks that the reads and writes occur in the right order during an extended rendezvous * * Specifically , it checks that the extended action always occurs before the write has finished * * The event-recorder offers a read event, a write event and a terminate event * The terminate event is only done (by the BarrierSyncer) once the other processes have finished * * The writer offers the write event *after* each write. * The reader offers the single read event during each extended rendezvous. * * Therefore the events should be in lock-step: * read,write,read,write... */ AltingBarrier[] terminateEvent = AltingBarrier.create(2); AltingBarrier[] writeEvent = AltingBarrier.create(2); AltingBarrier[] readEvent = AltingBarrier.create(2); EventRecorder recorder; new Parallel( new CSProcess[] { recorder = new EventRecorder(new Guard[] {writeEvent[0],readEvent[0],terminateEvent[0]},2), new Sequence(new CSProcess[] { new Parallel( new CSProcess[] { new WriterProcessInt(out,new int[100],writeEvent[1]), new ExtendedReaderSyncInt(readEvent[1],in,100) }), new BarrierSyncer(terminateEvent[1]) }) }).run(); Guard[] expectedEvents = new Guard[201]; for (int i = 0;i < 100;i++) { expectedEvents[i*2 + 0] = readEvent[0]; expectedEvents[i*2 + 1] = writeEvent[0]; } expectedEvents[200] = terminateEvent[0]; assertArraysEqual(expectedEvents,recorder.getObservedEvents()); } public void testNormalOne2OneChannelInt() { One2OneChannelInt chan = Channel.one2oneInt(); helper_testIntChannelOneWriter(chan.in(), chan.out()); } public void testNormalAny2OneChannelInt() { Any2OneChannelInt chan = ChannelInt.any2one(); helper_testIntChannelOneWriter(chan.in(), chan.out()); } public void testNormalOne2AnyChannelInt() { One2AnyChannelInt chan = ChannelInt.one2any(); helper_testIntChannelOneWriter(chan.in(), chan.out()); } public void testNormalAny2AnyChannelInt() { Any2AnyChannelInt chan = ChannelInt.any2any(); helper_testIntChannelOneWriter(chan.in(), chan.out()); } public void helper_testFIFOChannelOneWriter(ChannelInput in,ChannelOutput out) { /* * Since the reads and writes are fairly independent, this test instead checks * that all the data flows in the correct write order without getting lost, even when the * reader is slower than the writer * */ AltingBarrier[] delayEvent = AltingBarrier.create(2); ExtendedReaderSync reader; Object[] values = new Object[100]; for (int i = 0;i < 100;i++) { values[i] = new Object(); } new Parallel( new CSProcess[] { new DelaySyncer(delayEvent[0],5,100), new WriterProcess(out,Arrays.asList(values),(AltingBarrier)null), reader = new ExtendedReaderSync(delayEvent[1],in,100) }).run(); assertArraysEqual(values,reader.getValuesRead()); } public void testFIFO_One2OneChannel() { One2OneChannel chan4 = Channel.one2one(new Buffer(4)); helper_testFIFOChannelOneWriter(chan4.in(), chan4.out()); One2OneChannel chan1 = Channel.one2one(new Buffer(1)); helper_testFIFOChannelOneWriter(chan1.in(), chan1.out()); } public void testFIFO_Any2OneChannel() { Any2OneChannel chan4 = Channel.any2one(new Buffer(4)); helper_testFIFOChannelOneWriter(chan4.in(), chan4.out()); Any2OneChannel chan1 = Channel.any2one(new Buffer(1)); helper_testFIFOChannelOneWriter(chan1.in(), chan1.out()); } public void testFIFO_One2AnyChannel() { One2AnyChannel chan4 = Channel.one2any(new Buffer(4)); helper_testFIFOChannelOneWriter(chan4.in(), chan4.out()); One2AnyChannel chan1 = Channel.one2any(new Buffer(1)); helper_testFIFOChannelOneWriter(chan1.in(), chan1.out()); } public void testFIFO_Any2AnyChannel() { Any2AnyChannel chan4 = Channel.any2any(new Buffer(4)); helper_testFIFOChannelOneWriter(chan4.in(), chan4.out()); Any2AnyChannel chan1 = Channel.any2any(new Buffer(1)); helper_testFIFOChannelOneWriter(chan1.in(), chan1.out()); } //The given channel should be using a FIFO buffer (of any size >= 1) public void helper_testFIFOChannelOneWriterInt(ChannelInputInt in,ChannelOutputInt out) { /* * Since the reads and writes are fairly independent, this test instead checks * that all the data flows in the correct write order without getting lost, even when the * reader is slower than the writer * */ AltingBarrier[] delayEvent = AltingBarrier.create(2); ExtendedReaderSyncInt reader; int[] values = new int[100]; for (int i = 0;i < 100;i++) { values[i] = i; } new Parallel( new CSProcess[] { new DelaySyncer(delayEvent[0],5,100), new WriterProcessInt(out,values,(AltingBarrier)null), reader = new ExtendedReaderSyncInt(delayEvent[1],in,100) }).run(); assertArraysEqual(values,reader.getValuesRead()); } public void testFIFO_One2OneChannelInt() { One2OneChannelInt chan4 = Channel.one2oneInt(new BufferInt(4)); helper_testFIFOChannelOneWriterInt(chan4.in(), chan4.out()); One2OneChannelInt chan1 = Channel.one2oneInt(new BufferInt(1)); helper_testFIFOChannelOneWriterInt(chan1.in(), chan1.out()); } public void testFIFO_Any2OneChannelInt() { Any2OneChannelInt chan4 = Channel.any2oneInt(new BufferInt(4)); helper_testFIFOChannelOneWriterInt(chan4.in(), chan4.out()); Any2OneChannelInt chan1 = Channel.any2oneInt(new BufferInt(1)); helper_testFIFOChannelOneWriterInt(chan1.in(), chan1.out()); } public void testFIFO_One2AnyChannelInt() { One2AnyChannelInt chan4 = Channel.one2anyInt(new BufferInt(4)); helper_testFIFOChannelOneWriterInt(chan4.in(), chan4.out()); One2AnyChannelInt chan1 = Channel.one2anyInt(new BufferInt(1)); helper_testFIFOChannelOneWriterInt(chan1.in(), chan1.out()); } public void testFIFO_Any2AnyChannelInt() { Any2AnyChannelInt chan4 = Channel.any2anyInt(new BufferInt(4)); helper_testFIFOChannelOneWriterInt(chan4.in(), chan4.out()); Any2AnyChannelInt chan1 = ChannelInt.any2anyInt(new BufferInt(1)); helper_testFIFOChannelOneWriterInt(chan1.in(), chan1.out()); } public void testOverflowingFIFOOne2OneChannel() { /* * This test checks that the buffer does overflow if the reader is in the middle * of an extended rendezvous * * The buffer is size 4. We let the writer send 4 times, then send our fifth item before syncing * (the fifth should overflow and be lost) with the reader's sync during the 1st item. * Repeat until 100 items have been sent (80 received) */ One2OneChannel chan = Channel.one2one(new OverFlowingBuffer(4)); AltingBarrier[] syncEvent = AltingBarrier.create(2); Object[] sendValues = new Object[100]; Object[] expValues = new Object[80]; AltingBarrier[][] readerSync = new AltingBarrier[80][]; AltingBarrier[][] writerSync = new AltingBarrier[100][]; /* * The syncs are confusing. We need this to happen: * * WRITE} * WRITE} * WRITE}begin READ * WRITE} * WRITE} * end READ * READ * READ * READ * WRITE} * WRITE} * WRITE}begin READ * WRITE} * WRITE} * end READ * READ * READ * READ * * Therefore we use these syncs: * * WRITE} * WRITE} * WRITE}begin READ * WRITE} * WRITE} * sync sync * end READ * READ * READ * READ * sync sync * WRITE} * WRITE} * WRITE}begin READ * WRITE} * WRITE} * sync sync * READ * READ * READ * READ * ... * WRITE} * WRITE} * WRITE}begin READ * WRITE} * WRITE} * sync sync * READ * READ * READ * READ * sync sync * DONE DONE * */ for (int i = 0;i < 100;i++) { sendValues[i] = new Object(); if (i % 5 == 4) { writerSync[i] = new AltingBarrier[] {syncEvent[1] , syncEvent[1]}; } else { writerSync[i] = new AltingBarrier[0]; } } for (int i = 0;i < 80;i++) { if (i % 4 == 0) { readerSync[i] = new AltingBarrier[] {syncEvent[0]}; } else if (i % 4 == 3) { readerSync[i] = new AltingBarrier[] {null,syncEvent[0]}; } else { readerSync[i] = new AltingBarrier[0]; } expValues[i] = sendValues[((i / 4) * 5) + (i % 4)]; } ExtendedReaderSync reader; new Parallel( new CSProcess[] { new WriterProcess(chan.out(),Arrays.asList(sendValues),writerSync), reader = new ExtendedReaderSync(readerSync,chan.in(),80) }).run(); assertArraysEqual(expValues,reader.getValuesRead()); } public void testOverwritingOldestOne2OneChannel() { //This buffer should over-write the oldest item //If a write is made during an extended rendezvous that would over-write the //most recent item, it should succeed but the item should not be removed by the //reader at the end of the sync //Imagine a buffer of size 3. If the writer writes 0, and then the reader starts an //extended rendezvous, if the writer then writes 1,2,3 and then the reader finishes //the rendezvous, the buffer should still contain 1,2,3. //TODO work out what the expected behaviour is! } } jcsp-1.1-rc4.orig/src/org/jcsp/test/WriterProcessInt.java0000644000000000000000000000332110660321725020253 0ustar package org.jcsp.test; import java.security.InvalidParameterException; import java.util.Arrays; import org.jcsp.lang.AltingBarrier; import org.jcsp.lang.CSProcess; import org.jcsp.lang.ChannelOutputInt; /** * A process that writes out a list of values, synchronizing on the corresponding barrier after each. * * * @author N.C.C. Brown * */ public class WriterProcessInt implements CSProcess { private ChannelOutputInt out; private int[] values; private AltingBarrier[][] events; public WriterProcessInt(ChannelOutputInt out,int[] values,AltingBarrier[][] events) { if (values.length != events.length) { throw new InvalidParameterException("Values must be the same length as Events"); } this.out = out; this.values = values; this.events = events; } public WriterProcessInt(ChannelOutputInt out,int[] values,AltingBarrier event) { this.out = out; this.values = values; this.events = new AltingBarrier[values.length][]; Arrays.fill(this.events,new AltingBarrier[] {event}); } public void run() { for (int i = 0;i < events.length;i++) { AltingBarrier[] barriers = events[i]; for (int j = 0;j < barriers.length;j++) { AltingBarrier barrier = barriers[j]; if (barrier != null) { barrier.mark(); } } } for (int i = 0;i < values.length;i++) { out.write(values[i]); AltingBarrier[] barriers = events[i]; for (int j = 0;j < barriers.length;j++) { AltingBarrier barrier = barriers[j]; if (barrier != null) { barrier.sync(); } } } } } jcsp-1.1-rc4.orig/src/org/jcsp/test/BarrierSyncer.java0000644000000000000000000000076210657566574017570 0ustar package org.jcsp.test; import org.jcsp.lang.AltingBarrier; import org.jcsp.lang.CSProcess; /** * A process that syncs on one alting barrier and finishes * * * @author N.C.C. Brown * */ public class BarrierSyncer implements CSProcess { private AltingBarrier barrier; public BarrierSyncer(AltingBarrier barrier) { super(); this.barrier = barrier; } public void run() { barrier.mark(); barrier.sync(); } } jcsp-1.1-rc4.orig/src/org/jcsp/test/DelaySyncer.java0000644000000000000000000000124310657566574017233 0ustar package org.jcsp.test; import org.jcsp.lang.AltingBarrier; import org.jcsp.lang.CSProcess; import org.jcsp.lang.CSTimer; public class DelaySyncer implements CSProcess { AltingBarrier barrier; CSTimer timer; int milliSeconds; int iterations; public DelaySyncer(AltingBarrier barrier, int milliSeconds,int iterations) { this.barrier = barrier; timer = new CSTimer(); this.milliSeconds = milliSeconds; this.iterations = iterations; } public void run() { barrier.mark(); for (int i = 0;i < iterations;i++) { timer.sleep(milliSeconds); barrier.sync(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/test/EventRecorder.java0000644000000000000000000000220310657566574017555 0ustar package org.jcsp.test; import java.util.LinkedList; import java.util.List; import org.jcsp.lang.Alternative; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Guard; /** * A class that listens out for many guards, and records the order in which they occur * * Note: do not pass in channel guards, as the process will not perform the necessary * input after the guard is selected * * @author nccb * */ class EventRecorder implements CSProcess { private Guard originalGuards[]; private int stopOnGuard; private List observedGuards = new LinkedList(); public EventRecorder(Guard[] guards, int terminateEvent) { originalGuards = guards; stopOnGuard = terminateEvent; } public Guard[] getObservedEvents() { return (Guard[])observedGuards.toArray(new Guard[observedGuards.size()]); } public void run() { Alternative alt = new Alternative(originalGuards); int selected; do { selected = alt.select(); observedGuards.add(originalGuards[selected]); } while (selected != stopOnGuard); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/0000755000000000000000000000000011410045055014112 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/util/ChannelDataStore.java0000644000000000000000000001743511105701167020152 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util; /** * This is the interface for object channel plug-ins that define their buffering * characteristics. *

Description

* ChannelDataStore defines the interface to optional logic used by * channels defined in the org.jcsp.lang package to manage the data * being communicated. * Implementations are provided yielding a range of buffering properties * (e.g. {@link Buffer fixed sized (block when full)}, * {@link OverWriteOldestBuffer fixed size (overwrite oldest data when full)}, * {@link OverFlowingBuffer fixed size (accept but discard new data when full)}, * {@link InfiniteBuffer infinitely expandable}). *

* Channels are constructed using the static construction methods of {@link org.jcsp.lang.Channel}. * By default, channels will be constructed with standard CSP semantics – * no buffering and full synchronisation between reading and writing processes * (e.g. {@link org.jcsp.lang.Channel#one2one()}). * To construct buffered channels, plug in the appropriate ChannelDataStore * (e.g. {@link org.jcsp.lang.Channel#one2one(org.jcsp.util.ChannelDataStore)}). *

* Note: JCSP users should not normally need to define their own implementations * of this interface. * However, implementors may assume that ChannelDataStore methods * are always invoked (by the various channel classes within org.org.jcsp.lang) * in a thread-safe way – i.e. that there will be no race hazards between invocations * of {@link #get() get} and {@link #put(java.lang.Object) put}). * They may also assume that the documented pre-conditions for invoking the get * and put methods will be met. * ChannelDataStore is only intended for defining the behaviour of buffers – * it is not intended for any other purpose (e.g. for data-processing or filtering channels). * * * @see org.jcsp.util.ZeroBuffer * @see org.jcsp.util.Buffer * @see org.jcsp.util.OverWriteOldestBuffer * @see org.jcsp.util.OverWritingBuffer * @see org.jcsp.util.OverFlowingBuffer * @see org.jcsp.util.InfiniteBuffer * @see org.jcsp.lang.Channel * * @author P.D. Austin */ public interface ChannelDataStore extends Cloneable { /** Indicates that the ChannelDataStore is empty * -- it can accept only a put. */ public final static int EMPTY = 0; /** * Indicates that the ChannelDataStore is neither empty nor full * -- it can accept either a put or a get call. */ public final static int NONEMPTYFULL = 1; /** Indicates that the ChannelDataStore is full * -- it can accept only a get. */ public final static int FULL = 2; /** * Returns the current state of the ChannelDataStore. * * @return the current state of the ChannelDataStore (EMPTY, * NONEMPTYFULL or FULL) */ public abstract int getState(); /** * Puts a new Object into the ChannelDataStore. *

* Pre-condition: getState must not currently return FULL. * * @param value the Object to put into the ChannelDataStore */ public abstract void put(Object value); /** * Returns an Object from the ChannelDataStore. *

* Pre-condition: getState must not currently return EMPTY. * * @return an Object from the ChannelDataStore */ public abstract Object get(); /** * Begins an extended read on the buffer, returning the data for the extended read. *

* Pre-condition: getState must not currently return EMPTY. *

* The exact behaviour of this method depends on your buffer. When a process performs an * extended rendezvous on a buffered channel, it will first call this method, then the * {@link #endGet} method. *

* A FIFO buffer would implement this method as returning the value from the front of the buffer * and the next call would remove the value. An overflowing buffer would do the same. *

* However, for an overwriting buffer it is more complex. Refer to the documentation for * {@link OverWritingBuffer#startGet} and {@link OverWriteOldestBuffer#startGet} * for details * * @return The object to be read from the channel at the beginning of the extended rendezvous * * @see #endGet */ public abstract Object startGet(); /** * Ends an extended read on the buffer. * * The channels guarantee that this method will be called exactly once after each * {@link #startGet startGet} call. * During the period between {@link #startGet startGet} and * {@link #endGet endGet}, it is possible that * {@link #put put} will be called, but not {@link #get get}. * * @see #startGet */ public abstract void endGet(); /** * Returns a new (and EMPTY) ChannelDataStore with the same * creation parameters as this one. *

* Note: Only the size and structure of the ChannelDataStore should * be cloned, not any stored data. * * @return the cloned instance of this ChannelDataStore. */ public abstract Object clone(); /** * Deletes all items in the buffer, leaving it empty. * */ public abstract void removeAll(); } jcsp-1.1-rc4.orig/src/org/jcsp/util/Buffer.java0000644000000000000000000001502511105701167016175 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util; import java.io.Serializable; /** * This is used to create a buffered object channel that never loses data. *

Description

* Buffer is an implementation of ChannelDataStore that yields * a blocking FIFO buffered semantics for a channel. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2one(org.jcsp.util.ChannelDataStore)} etc.). *

* The getState method returns EMPTY, NONEMPTYFULL or * FULL according to the state of the buffer. * * @see org.jcsp.util.ZeroBuffer * @see org.jcsp.util.OverWriteOldestBuffer * @see org.jcsp.util.OverWritingBuffer * @see org.jcsp.util.OverFlowingBuffer * @see org.jcsp.util.InfiniteBuffer * @see org.jcsp.lang.Channel * * @author P.D. Austin */ public class Buffer implements ChannelDataStore, Serializable { /** The storage for the buffered Objects */ private final Object[] buffer; /** The number of Objects stored in the Buffer */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; /** * Construct a new Buffer with the specified size. * * @param size the number of Objects the Buffer can store. * @throws BufferSizeError if size is negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public Buffer(int size) { if (size < 0) throw new BufferSizeError("\n*** Attempt to create a buffered channel with negative capacity"); buffer = new Object[size + 1]; // the extra one is a subtlety needed by // the current channel algorithms. } /** * Returns the oldest Object from the Buffer and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the Buffer */ public Object get() { Object value = buffer[firstIndex]; buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Returns the oldest object from the buffer but does not remove it. * * Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the Buffer */ public Object startGet() { return buffer[firstIndex]; } /** * Removes the oldest object from the buffer. */ public void endGet() { buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; } /** * Puts a new Object into the Buffer. *

* Pre-condition: getState must not currently return FULL. * * @param value the Object to put into the Buffer */ public void put(Object value) { buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; counter++; } /** * Returns the current state of the Buffer. * * @return the current state of the Buffer (EMPTY, * NONEMPTYFULL or FULL) */ public int getState() { if (counter == 0) return EMPTY; else if (counter == buffer.length) return FULL; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) Buffer with the same * creation parameters as this one. *

* Note: Only the size and structure of the Buffer is * cloned, not any stored data. * * @return the cloned instance of this Buffer */ public Object clone() { return new Buffer(buffer.length - 1); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; for (int i = 0;i < buffer.length;i++) { //Null the objects so they can be garbage collected: buffer[i] = null; } } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/0000755000000000000000000000000011410045055015377 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredSharedChannelOutput.java0000644000000000000000000000473511105701167023656 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.SharedChannelOutput; /** * Interface for an output channel end that supports filtering operations and can be shared by multiple * concurrent processes. * * @see org.jcsp.lang.SharedChannelOutput * @see org.jcsp.util.filter.WriteFiltered * * @author Quickstone Technologies Limited */ public interface FilteredSharedChannelOutput extends SharedChannelOutput, FilteredChannelOutput { } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/ReadFiltered.java0000644000000000000000000001210411105701167020576 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; /** *

Interface for a channel end supporting read filtering operations. A channel end that implements this * interface can have instances of the Filter interface installed to apply transformations * on data as it is read from the channel.

* *

Multiple filters can be installed and referenced by a zero-based index to specify a specific * ordering.

* *

If multiple filters are installed, they are applied in order of increasing index. For example:

* *
 *   FilteredChannelInput in = ...;
 *
 *   Filter f1 = ...;
 *   Filter f2 = ...;
 *
 *   in.addReadFilter (f1, 0);
 *   in.addReadFilter (f2, 1);
 * 
* *

The in.read() method will return f2.filter (f1.filter (obj)) where * obj is the data value that would have been delivered in the absence of filters.

* * @see org.jcsp.util.filter.Filter * @see org.jcsp.util.filter.FilteredChannelInput * * @author Quickstone Technologies Limited */ public interface ReadFiltered { /** * Installs a read filter defining a transformation to be applied by the read method of the * channel end. The filter will be appended to the end of the current list, making it the last to * be applied. * * @param filter the filter to be installed; may not be null. */ public void addReadFilter(Filter filter); /** * Installs a read filter defining a transformation to be applied by the read method of the * channel end at a specific index. If there is already a filter at that index position the existing * filters are shifted to make room. If the index is greater than the number of filters already * installed the filter is placed at the end. * * @param filter the filter to be installed; may not be null. * @param index the zero based index; may not be negative. */ public void addReadFilter(Filter filter, int index); /** * Removes the first read filter (lowest index) matching the filter given as a parameter. The filter * removed, r, will satisfy the condition r.equals (filter). The remaining * filters are shifted to close the gap in the index allocation. * * @param filter the filter to be removed; may not be null. */ public void removeReadFilter(Filter filter); /** * Removes the read filter installed at the given index. The remaining filters are shifted to close the * gap in the index allocation. * * @param index zero-based index of the filter to be removed. */ public void removeReadFilter(int index); /** * Returns the read filter installed at the given index. * * @param index zero-based index of the filter to return. * @return the filter at that position. */ public Filter getReadFilter(int index); /** * Returns the number of read filters currently installed. */ public int getReadFilterCount(); } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredSharedChannelInput.java0000644000000000000000000000466211105701167023454 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.SharedChannelInput; /** * Interface for a channel input end that supports filtering and can be shared by multiple processes. * * @see org.jcsp.lang.SharedChannelInput * @see org.jcsp.util.filter.ReadFiltered * * @author Quickstone Technologies Limited */ public interface FilteredSharedChannelInput extends SharedChannelInput, FilteredChannelInput { } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredOne2OneChannel.java0000644000000000000000000000530611105701167022467 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * Interface for a One2One channel that supports filtering operations at each end. * * @see org.jcsp.lang.One2OneChannel * @see org.jcsp.util.filter.ReadFiltered * @see org.jcsp.util.filter.WriteFiltered * * @author Quickstone Technologies Limited */ public interface FilteredOne2OneChannel extends One2OneChannel { /** * Returns the control interface for configuring the read filters on the channel. */ public ReadFiltered inFilter(); /** * Returns the control interface for configuring the write filters on the channel. */ public WriteFiltered outFilter(); } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/package.html0000644000000000000000000000101111077340707017664 0ustar

This defines filtering channels that can apply transformations to objects as they are read and/or written. A completely filtered channel can be created using the FilteredChannel factory, or a filtered end can be created for an existing channel.

Only a PoisonFilter is included in this package. User-defined filters can be created by implementing the Filter interface to define the transformation operation to apply on data objects.

jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/Filter.java0000644000000000000000000000576611105701167017511 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; /** * Interface for channel plug-ins that define filtering operations - * transformations on the data as it is read or written. A channel (or channel end) that supports * filtering will implement the ReadFiltered or WriteFiltered interface which * allows instances of Filter to be installed or removed from the channel. * * @see org.jcsp.util.filter.FilteredChannel * @see org.jcsp.util.filter.FilteredChannelEnd * @see org.jcsp.util.filter.ReadFiltered * @see org.jcsp.util.filter.WriteFiltered * * @author Quickstone Technologies Limited */ public interface Filter { /** * Applies the filter operation. The object given can be modified and returned or another object * substituted in its place. * * @param obj the original object in the channel communication. * @return the modified/substituted object after filtration. */ public Object filter(Object obj); } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredAny2AnyChannelImpl.java0000644000000000000000000000617711105701167023334 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * This wraps up an Any2AnyChannel object so that its * input and output ends are separate objects. Both ends of the channel * have filtering enabled. * * @author Quickstone Technologies Limited */ class FilteredAny2AnyChannelImpl implements FilteredAny2AnyChannel { /** * The input end of the channel. */ private FilteredSharedChannelInput in; /** * The output end of the channel. */ private FilteredSharedChannelOutput out; /** * Constructs a new filtered channel object based on an existing channel. */ FilteredAny2AnyChannelImpl(Any2AnyChannel chan) { in = new FilteredSharedChannelInputWrapper(chan.in()); out = new FilteredSharedChannelOutputWrapper(chan.out()); } public SharedChannelInput in() { return in; } public SharedChannelOutput out() { return out; } public ReadFiltered inFilter() { return in; } public WriteFiltered outFilter() { return out; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/WriteFiltered.java0000644000000000000000000001220011105701167021012 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; /** *

Interface for a channel end supporting write filtering operations. A channel end that implements this * interface can have instances of the Filter interface installed to apply transformations * on data as it is written to the channel.

* *

Multiple filters can be installed and referenced by a zero-based index to specify a specific * ordering.

* *

If multiple filters are installed, they are applied in order of increasing index. For example:

* *
 *   FilteredChannelOutput out = ...;
 *
 *   Filter f1 = ...;
 *   Filter f2 = ...;
 *
 *   out.addWriteFilter (f1, 0);
 *   out.addWriteFilter (f2, 1);
 * 
* *

The out.write() method will deliver f2.filter (f1.filter (obj)) to * the reader of the channel where obj is the data value that would have been delivered in * the absence of filters.

* * @see org.jcsp.util.filter.Filter * @see org.jcsp.util.filter.FilteredChannelOutput * * @author Quickstone Technologies Limited */ public interface WriteFiltered { /** * Installs a write filter defining a transformation to be applied by the write method of * the channel end. The filter will be appended to the end of the current list, making it the last to * be applied. * * @param filter the filter to be installed; may not be null. */ public void addWriteFilter(Filter filter); /** * Installs a write filter defining a transformation to be applied by the write method of the * channel end at a specific index. If there is already a filter at that index position the existing * filters are shifted to make room. If the index is greater than the number of filters already * installed the filter is placed at the end. * * @param filter the filter to be installed; may not be null. * @param index the zero based index; may not be negative. */ public void addWriteFilter(Filter filter, int index); /** * Removes the first write filter (lowest index) matching the filter given as a parameter. The filter * removed, r, will satisfy the condition r.equals (filter). The remaining * filters are shifted to close the gap in the index allocation. * * @param filter the filter to be removed; may not be null. */ public void removeWriteFilter(Filter filter); /** * Removes the write filter installed at the given index. The remaining filters are shifted to close the * gap in the index allocation. * * @param index zero-based index of the filter to be removed. */ public void removeWriteFilter(int index); /** * Returns the write filter installed at the given index. * * @param index zero-based index of the filter to return. * @return the filter at that position. */ public Filter getWriteFilter(int index); /** * Returns the number of write filters currently installed. */ public int getWriteFilterCount(); } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredChannelInput.java0000644000000000000000000000444211105701167022321 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.ChannelInput; /** * Interface for a channel input end that supports filtering operations. * * @author Quickstone Technologies Limited */ public interface FilteredChannelInput extends ChannelInput, ReadFiltered { } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredAny2AnyChannel.java0000644000000000000000000000525411105701167022505 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.Any2AnyChannel; /** * Interface for an Any2Any channel that has support for filtering at both ends. * * @see org.jcsp.lang.Any2AnyChannel * @see org.jcsp.util.filter.ReadFiltered * @see org.jcsp.util.filter.WriteFiltered * * @author Quickstone Technologies Limited */ public interface FilteredAny2AnyChannel extends Any2AnyChannel { /** * Returns an interface for configuring read filters on the channel. */ public ReadFiltered inFilter(); /** * Returns an interface for configuring write filters on the channel. */ public WriteFiltered outFilter(); } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredChannelEnd.java0000644000000000000000000001116411105701167021727 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * Static factory for creating channel end wrappers that support filtering. * * @author Quickstone Technologies Limited */ public class FilteredChannelEnd { /** * The default factory for creating the channel ends. */ private static final FilteredChannelEndFactory factory = new FilteredChannelEndFactory(); /** * Private constructor to prevent any instances of this static factory from being created. */ private FilteredChannelEnd() { // Noone's creating one of these } /** * Creates a new filtered input channel end around an existing input channel end. The channel end * can be used as a guard in an Alternative. * * @param in the existing channel end to create a filtered form of. * @return the new channel end with filtering ability. */ public static FilteredAltingChannelInput createFiltered(AltingChannelInput in) { return factory.createFiltered(in); } /** * Creates a new filtered input channel end around an existing input channel end. * * @param in the existing channel end to create a filtered form of. * @return the new channel end with filtering ability. */ public static FilteredChannelInput createFiltered(ChannelInput in) { return factory.createFiltered(in); } /** * Creates a new filtered input channel end around an existing input channel end that can be * shared by multiple processes. * * @param in the existing channel end to create a filtered form of, * @return the new channel end with filtering ability. */ public static FilteredSharedChannelInput createFiltered(SharedChannelInput in) { return factory.createFiltered(in); } /** * Creates a new filtered output channel end around an existing output channel end. * * @param out the existing channel end to create a filtered form of. */ public static FilteredChannelOutput createFiltered(ChannelOutput out) { return factory.createFiltered(out); } /** * Creates a new filtered output channel end around an existing output channel end that can be * shared by multiple processes. * * @param out the existing channel end to create a filtered form of. * @return the new channel end with filtering ability. */ public static FilteredSharedChannelOutput createFiltered(SharedChannelOutput out) { return factory.createFiltered(out); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredOne2AnyChannel.java0000644000000000000000000000505411105701167022475 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.One2AnyChannel; /** * Interface for an Any2Any channel that supports both read and write filters. * * @author Quickstone Technologies Limited */ public interface FilteredOne2AnyChannel extends One2AnyChannel { /** * Returns the control interface to manipulate the read filters. */ public ReadFiltered inFilter(); /** * Returns the control interface to manipulate the write filters. */ public WriteFiltered outFilter(); } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/PoisonFilter.java0000644000000000000000000000575511105701167020677 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; /** * This filter will throw a PoisonException * when filter(Object) is called. This can be * used to prevent a channel from being written to or read from. * * @author Quickstone Technologies Limited */ public class PoisonFilter implements Filter { /** * The message to be placed in the PoisonException raised. */ private String message; /** * Default message. */ private static String defaultMessage = "Channel end has been poisoned."; /** * Constructs a new filter with the default message. */ public PoisonFilter() { this(defaultMessage); } /** * Constructs a new filter with a specific message. */ public PoisonFilter(String message) { this.message = message; } public Object filter(Object obj) { throw new PoisonFilterException(this.message); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredSharedChannelInputWrapper.java0000644000000000000000000001003011105701167024777 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * This is wrapper for a SharedChannelInput that adds * read filtering. Instances of this class can be safely used by * multiple concurrent processes. * * @author Quickstone Technologies Limited */ public class FilteredSharedChannelInputWrapper extends FilteredChannelInputWrapper implements FilteredSharedChannelInput { /** * The object used for synchronization by the methods here to protect the readers from each other * when manipulating the filters and reading data. */ private Object synchObject; /** * Constructs a new wrapper for the given channel input end. * * @param in the existing channel end. */ public FilteredSharedChannelInputWrapper(SharedChannelInput in) { super(in); synchObject = new Object(); } public Object read() { synchronized (synchObject) { return super.read(); } } public void addReadFilter(Filter filter) { synchronized (synchObject) { super.addReadFilter(filter); } } public void addReadFilter(Filter filter, int index) { synchronized (synchObject) { super.addReadFilter(filter, index); } } public void removeReadFilter(Filter filter) { synchronized (synchObject) { super.removeReadFilter(filter); } } public void removeReadFilter(int index) { synchronized (synchObject) { super.removeReadFilter(index); } } public Filter getReadFilter(int index) { synchronized (synchObject) { return super.getReadFilter(index); } } public int getReadFilterCount() { synchronized (synchObject) { return super.getReadFilterCount(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredChannelFactory.java0000644000000000000000000003255111105701167022633 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; import org.jcsp.util.ChannelDataStore; /** *

This class is used for constructing Filtered Channels. * The objects returned by instances of this class will implement * the appropriate Filtered Channel interfaces even though the return * types are not declared as being Filtered Channels. This is so * that this class can implement the ChannelFactory and * ChannelArrayFactory interfaces. Instances of this class * can therefore be used in place of the standard channel factory classes.

* *

A set of read and/or write filters can be specified so that all of the channels created by this * factory will have the same buffering properties.

* * @author Quickstone Technologies Limited */ public class FilteredChannelFactory implements ChannelFactory, ChannelArrayFactory, BufferedChannelFactory, BufferedChannelArrayFactory { /** * Underlying factory for creating the base channels. */ private StandardChannelFactory factory; /** * Read filters to install in channels created by this factory. */ private Filter[] readFilters; /** * Write filters to install in channels created by this factory. */ private Filter[] writeFilters; /** * All channels constructed with a Factory constructed with this * constructor will default to having no pre-installed filters. * */ public FilteredChannelFactory() { factory = new StandardChannelFactory(); } /** *

All channels constructed with this Factory instance will have the * specified Filter objects inserted into them. The same * instances of the filters will be inserted into each channel.

* *

Either of the parameters may be null if read/write filters are not required.

* * @param readFilters optional read filters to install in new channels. * @param writeFilters optional write filters to install in new channels. */ public FilteredChannelFactory(Filter[] readFilters, Filter[] writeFilters) { this(); this.readFilters = readFilters; this.writeFilters = writeFilters; } /** * Installs the filters currently set for this factory into the read/write channel ends supplied. * * @param readFiltered optional control interface for the read end of a filtered channel. * @param writeFiltered optional control interface for the write end of a filtered channel. */ private void installFilters(ReadFiltered readFiltered, WriteFiltered writeFiltered) { if (readFilters != null) for (int i = 0; i < readFilters.length; i++) readFiltered.addReadFilter(readFilters[i]); if (writeFilters != null) for (int i = 0; i < writeFilters.length; i++) writeFiltered.addWriteFilter(writeFilters[i]); } /** * Creates a new One2One channel with the filtering options set for this factory. * * @return the created channel with the filters installed. */ public One2OneChannel createOne2One() { FilteredOne2OneChannelImpl toReturn = new FilteredOne2OneChannelImpl(factory.createOne2One()); installFilters(toReturn.inFilter(), toReturn.outFilter()); return toReturn; } /** * Creates a new Any2One channel with the filtering options set for this factory. * * @return the created channel with the filters installed. */ public Any2OneChannel createAny2One() { FilteredAny2OneChannelImpl toReturn = new FilteredAny2OneChannelImpl(factory.createAny2One()); installFilters(toReturn.inFilter(), toReturn.outFilter()); return toReturn; } /** * Creates a new One2Any channel with the filtering options set for this factory. * * @return the created channel with the filters installed. */ public One2AnyChannel createOne2Any() { FilteredOne2AnyChannelImpl toReturn = new FilteredOne2AnyChannelImpl(factory.createOne2Any()); installFilters(toReturn.inFilter(), toReturn.outFilter()); return toReturn; } /** * Creates a new Any2Any channel with the filtering options set for this factory. * * @return the created channel with the filters installed. */ public Any2AnyChannel createAny2Any() { FilteredAny2AnyChannelImpl toReturn = new FilteredAny2AnyChannelImpl(factory.createAny2Any()); installFilters(toReturn.inFilter(), toReturn.outFilter()); return toReturn; } /** * Constructs and returns an array of One2OneChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2One(int) */ public One2OneChannel[] createOne2One(int n) { One2OneChannel[] toReturn = new One2OneChannel[n]; for (int i = 0; i < n; i++) { toReturn[i] = createOne2One(); } return toReturn; } /** * Constructs and returns an array of Any2OneChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2One(int) */ public Any2OneChannel[] createAny2One(int n) { Any2OneChannel[] toReturn = new Any2OneChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2One(); return toReturn; } /** * Constructs and returns an array of One2AnyChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2Any(int) */ public One2AnyChannel[] createOne2Any(int n) { One2AnyChannel[] toReturn = new One2AnyChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2Any(); return toReturn; } /** * Constructs and returns an array of Any2AnyChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2Any(int) */ public Any2AnyChannel[] createAny2Any(int n) { Any2AnyChannel[] toReturn = new Any2AnyChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2Any(); return toReturn; } /** * Creates a new One2One channel with the filtering options set for this factory and the specified * data buffer. * * @param buffer the buffer implementation to use. * @return the created filtered channel. */ public One2OneChannel createOne2One(ChannelDataStore buffer) { FilteredOne2OneChannelImpl toReturn = new FilteredOne2OneChannelImpl(factory.createOne2One(buffer)); installFilters(toReturn.inFilter(), toReturn.outFilter()); return toReturn; } /** * Creates a new Any2One channel with the filtering options set for this factory and the specified * data buffer. * * @param buffer the buffer implementation to use. * @return the created filtered channel. */ public Any2OneChannel createAny2One(ChannelDataStore buffer) { FilteredAny2OneChannelImpl toReturn = new FilteredAny2OneChannelImpl(factory.createAny2One(buffer)); installFilters(toReturn.inFilter(), toReturn.outFilter()); return toReturn; } /** * Creates a new One2Any channel with the filtering options set for this factory and the specified * data buffer. * * @param buffer the buffer implementation to use. * @return the created filtered channel. */ public One2AnyChannel createOne2Any(ChannelDataStore buffer) { FilteredOne2AnyChannelImpl toReturn = new FilteredOne2AnyChannelImpl(factory.createOne2Any(buffer)); installFilters(toReturn.inFilter(), toReturn.outFilter()); return toReturn; } /** * Creates a new Any2Any channel with the filtering options set for this factory and the specified * data buffer. * * @param buffer the buffer implementation to use. * @return the created filtered channel. */ public Any2AnyChannel createAny2Any(ChannelDataStore buffer) { FilteredAny2AnyChannelImpl toReturn = new FilteredAny2AnyChannelImpl(factory.createAny2Any(buffer)); installFilters(toReturn.inFilter(), toReturn.outFilter()); return toReturn; } /** * Constructs and returns an array of One2OneChannel * objects with a given buffering behaviour. * * @param n the size of the array of channels. * @param buffer the buffer implementation to use. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2One(int) */ public One2OneChannel[] createOne2One(ChannelDataStore buffer, int n) { One2OneChannel[] toReturn = new One2OneChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2One(buffer); return toReturn; } /** * Constructs and returns an array of Any2OneChannel * objects with a given buffering behaviour. * * @param n the size of the array of channels. * @param buffer the buffer implementation to use. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2One(int) */ public Any2OneChannel[] createAny2One(ChannelDataStore buffer, int n) { Any2OneChannel[] toReturn = new Any2OneChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2One(buffer); return toReturn; } /** * Constructs and returns an array of One2AnyChannel * objects with a given buffering behaviour. * * @param n the size of the array of channels. * @param buffer the buffer implementation to use. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2Any(int) */ public One2AnyChannel[] createOne2Any(ChannelDataStore buffer, int n) { One2AnyChannel[] toReturn = new One2AnyChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2Any(buffer); return toReturn; } /** * Constructs and returns an array of Any2AnyChannel * objects with a given buffering behaviour. * * @param n the size of the array of channels. * @param buffer the buffer implementation to use. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2Any(int) */ public Any2AnyChannel[] createAny2Any(ChannelDataStore buffer, int n) { Any2AnyChannel[] toReturn = new Any2AnyChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2Any(buffer); return toReturn; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredOne2OneChannelImpl.java0000644000000000000000000000614111105701167023307 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * Implements a One2One channel that supports filtering at each end. * * @author Quickstone Technologies Limited */ class FilteredOne2OneChannelImpl implements FilteredOne2OneChannel { /** * The filtered input end of the channel. */ private FilteredAltingChannelInput in; /** * The filtered output end of the channel. */ private FilteredChannelOutput out; /** * Constructs a new filtered channel based on an existing channel. * * @param chan the existing channel. */ public FilteredOne2OneChannelImpl(One2OneChannel chan) { in = new FilteredAltingChannelInput(chan.in()); out = new FilteredChannelOutputWrapper(chan.out()); } public AltingChannelInput in() { return in; } public ChannelOutput out() { return out; } public ReadFiltered inFilter() { return in; } public WriteFiltered outFilter() { return out; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredChannelInputWrapper.java0000644000000000000000000000766711105701167023676 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * Wrapper for an input channel end to include read filtering functionality. * * @author Quickstone Technologies Limited */ class FilteredChannelInputWrapper extends ChannelInputWrapper implements FilteredChannelInput { /** * Set of read filters installed. */ private FilterHolder filters = null; /** * Constructs a new FilteredChannelInputWrapper around the existing channel end. * * @param in channel end to create the wrapper around. */ FilteredChannelInputWrapper(ChannelInput in) { super(in); } public Object read() { Object toFilter = super.read(); for (int i = 0; filters != null && i < filters.getFilterCount(); i++) toFilter = filters.getFilter(i).filter(toFilter); return toFilter; } public void addReadFilter(Filter filter) { if (filters == null) filters = new FilterHolder(); filters.addFilter(filter); } public void addReadFilter(Filter filter, int index) { if (filters == null) filters = new FilterHolder(); filters.addFilter(filter, index); } public void removeReadFilter(Filter filter) { if (filters == null) filters = new FilterHolder(); filters.removeFilter(filter); } public void removeReadFilter(int index) { if (filters == null) filters = new FilterHolder(); filters.removeFilter(index); } public Filter getReadFilter(int index) { if (filters == null) filters = new FilterHolder(); return filters.getFilter(index); } public int getReadFilterCount() { if (filters == null) return 0; return filters.getFilterCount(); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilterHolder.java0000644000000000000000000001517211105701167020637 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; /** * Storage scheme for a set of filters that is dynamically sized and supports insert and remove * operations to keep the filters in a contiguous block. * * @author Quickstone Technologies Limited */ class FilterHolder { /** * The array of filters. The installed filters are in a block at the start of the array. */ private Filter[] filters; /** * Number of filters currently installed. */ private int count = 0; /** * Constructs a new FilterHolder with an intial capacity of 2. */ FilterHolder() { this(2); } /** * Constructs a new FilterHolder with the given initial capacity. * * @param initialSize the initial size for the array. */ FilterHolder(int initialSize) { filters = new Filter[initialSize]; } /** * Adds a filter to the end of the array, possibly enlarging it if it is full. * * @param filter the filter to add. */ public void addFilter(Filter filter) { makeSpace(); filters[count] = filter; count++; } /** * Adds a filter at the given index. If the index is past the end of the array, the filter is placed * at the end of the array. If the index is in use, filter is inserted, shifting the existing ones. * If necessary, the array may be enlarged. * * @param filter the filter to add. * @param index the position to add the filter. */ public void addFilter(Filter filter, int index) { if (index >= count) //add filter to end addFilter(filter); else { makeSpace(); //shift all elements from specifed index and above along one System.arraycopy(filters, index, filters, index + 1, count - index); filters[index] = filter; count++; } } /** * Removes a filter from the set. The first filter, f, satisfying the condition * f.equals (filter) is removed and the remaining filters shifted to close the gap. * * @param filter the filter to remove. */ public void removeFilter(Filter filter) { if (filter == null) throw new IllegalArgumentException("filter parameter cannot be null"); for (int i = 0; i < count; i++) if (filters[i].equals(filter)) { removeFilter(i); return; } throw new IllegalArgumentException("supplied filter not installed."); } /** * Removes a filter at a given index. The remaining filters are shifted to close the gap. * * @param index the array index to remove the filter. */ public void removeFilter(int index) { if (index > (count - 1) || index < 0) throw new IndexOutOfBoundsException("Invalid filter index."); filters[index] = null; //if filter not the last item in the array //then need to shift all elements after the //specified filter if (index < filters.length - 1) { System.arraycopy(filters, index + 1, filters, index, count - index - 1); count--; } else { count--; compact(); } } /** * Returns a filter at the given array index. */ public Filter getFilter(int index) { return filters[index]; } /** * Returns the number of filters current installed. */ public int getFilterCount() { return count; } /** * Enlarges the size of the array to make room for more filters. Currently the array is doubled * in size. */ private void makeSpace() { //if array of filters is full - double size if (count == filters.length) { Filter[] filters = new Filter[count * 2]; System.arraycopy(this.filters, 0, filters, 0, this.filters.length); this.filters = filters; } } /** * Shrinks the array to save space if it is 75% empty. */ private void compact() { int newSize = count + 1; if (count < (filters.length / 4) && newSize < filters.length) { //create a new array which Filter[] filters = new Filter[newSize]; System.arraycopy(this.filters, 0, filters, 0, count); this.filters = filters; } } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredAny2OneChannelImpl.java0000644000000000000000000000617711105701167023326 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * This wraps up an Any2OneChannel object so that its * input and output ends are separate objects. Both ends of the channel * have filtering enabled. * * @author Quickstone Technologies Limited */ class FilteredAny2OneChannelImpl implements FilteredAny2OneChannel { /** * The input end of the channel. */ private FilteredAltingChannelInput in; /** * The output end of the channel. */ private FilteredSharedChannelOutput out; /** * Constructs a new filtered channel over the top of an existing channel. */ public FilteredAny2OneChannelImpl(Any2OneChannel chan) { in = new FilteredAltingChannelInput(chan.in()); out = new FilteredSharedChannelOutputWrapper(chan.out()); } public AltingChannelInput in() { return in; } public SharedChannelOutput out() { return out; } public ReadFiltered inFilter() { return in; } public WriteFiltered outFilter() { return out; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredChannelOutput.java0000644000000000000000000000445511105701167022526 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.ChannelOutput; /** * Interface for a channel output end that supports write filtering operations. * * @author Quickstone Technologies Limited */ public interface FilteredChannelOutput extends ChannelOutput, WriteFiltered { } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/PoisonFilterException.java0000644000000000000000000000055510660320603022544 0ustar package org.jcsp.util.filter; import org.jcsp.lang.PoisonException; /** * * @deprecated Use poison directly instead */ public class PoisonFilterException extends PoisonException { public PoisonFilterException(String message) { //In lieu of knowing a specific poison strength, //we supply the maximum: super(Integer.MAX_VALUE); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredOne2AnyChannelImpl.java0000644000000000000000000000634611105701167023324 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * Implements an One2Any channel that supports filtering at each end. * * @see org.jcsp.lang.One2AnyChannel * @see org.jcsp.util.filter.ReadFiltered * @see org.jcsp.util.filter.WriteFiltered * * @author Quickstone Technologies Limited */ class FilteredOne2AnyChannelImpl implements FilteredOne2AnyChannel { /** * The filtered input end of the channel. */ private FilteredSharedChannelInput in; /** * The filtered output end of the channel. */ private FilteredChannelOutput out; /** * Constructs a new filtered channel from an existing channel. * * @param chan the existing channel. */ public FilteredOne2AnyChannelImpl(One2AnyChannel chan) { in = new FilteredSharedChannelInputWrapper(chan.in()); out = new FilteredChannelOutputWrapper(chan.out()); } public SharedChannelInput in() { return in; } public ChannelOutput out() { return out; } public ReadFiltered inFilter() { return in; } public WriteFiltered outFilter() { return out; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredChannel.java0000644000000000000000000002137711105701167021307 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.util.*; /** * Static factory for creating filtered channels. * * @author Quickstone Technologies Limited */ public class FilteredChannel { /** * Default factory for creating the channels. */ private static FilteredChannelFactory factory = new FilteredChannelFactory(); /** * Private constructor to prevent any instances of this static factory from being created. */ private FilteredChannel() { //private constructor to stop construction } /** * Creates a new One2One filtered channel. * * @return the created channel. */ public static FilteredOne2OneChannel createOne2One() { return (FilteredOne2OneChannel)factory.createOne2One(); } /** * Creates a new Any2One filtered channel. * * @return the created channel. */ public static FilteredAny2OneChannel createAny2One() { return (FilteredAny2OneChannel)factory.createAny2One(); } /** * Creates a new One2Any filtered channel. * * @return the created channel. */ public static FilteredOne2AnyChannel createOne2Any() { return (FilteredOne2AnyChannel)factory.createOne2Any(); } /** * Creates a new Any2Any filtered channel. * * @return the created channel. */ public static FilteredAny2AnyChannel createAny2Any() { return (FilteredAny2AnyChannel)factory.createAny2Any(); } /** * Constructs and returns an array of One2OneChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2One(int) */ public static FilteredOne2OneChannel[] createOne2One(int n) { return (FilteredOne2OneChannel[])factory.createOne2One(n); } /** * Constructs and returns an array of Any2OneChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2One(int) */ public static FilteredAny2OneChannel[] createAny2One(int n) { return (FilteredAny2OneChannel[])factory.createAny2One(n); } /** * Constructs and returns an array of One2AnyChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2Any(int) */ public static FilteredOne2AnyChannel[] createOne2Any(int n) { return (FilteredOne2AnyChannel[])factory.createOne2Any(n); } /** * Constructs and returns an array of Any2AnyChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2Any(int) */ public static FilteredAny2AnyChannel[] createAny2Any(int n) { return (FilteredAny2AnyChannel[])factory.createAny2Any(n); } /** * Creates a new One2One filtered channel with a given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public static FilteredOne2OneChannel createOne2One(ChannelDataStore buffer) { return (FilteredOne2OneChannel)factory.createOne2One(buffer); } /** * Creates a new Any2One filtered channel with a given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public static FilteredAny2OneChannel createAny2One(ChannelDataStore buffer) { return (FilteredAny2OneChannel)factory.createAny2One(buffer); } /** * Creates a new One2Any filtered channel with a given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public static FilteredOne2AnyChannel createOne2Any(ChannelDataStore buffer) { return (FilteredOne2AnyChannel)factory.createOne2Any(buffer); } /** * Creates a new Any2Any filtered channel with a given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public static FilteredAny2AnyChannel createAny2Any(ChannelDataStore buffer) { return (FilteredAny2AnyChannel)factory.createAny2Any(buffer); } /** * Constructs and returns an array of One2OneChannel * objects using a given buffer. * * @param n the size of the array of channels. * @param buffer the buffer implementation to use. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2One(int) */ public static FilteredOne2OneChannel[] createOne2One(ChannelDataStore buffer, int n) { return (FilteredOne2OneChannel[])factory.createOne2One(buffer, n); } /** * Constructs and returns an array of Any2OneChannel * objects with a given buffer. * * @param n the size of the array of channels. * @param buffer the buffer implementation to use. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2One(int) */ public static FilteredAny2OneChannel[] createAny2One(ChannelDataStore buffer, int n) { return (FilteredAny2OneChannel[])factory.createAny2One(buffer, n); } /** * Constructs and returns an array of One2AnyChannel * objects with a given buffer. * * @param n the size of the array of channels. * @param buffer the buffer implementation to use. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2Any(int) */ public static FilteredOne2AnyChannel[] createOne2Any(ChannelDataStore buffer, int n) { return (FilteredOne2AnyChannel[])factory.createOne2Any(buffer, n); } /** * Constructs and returns an array of Any2AnyChannel * objects with a given buffer. * * @param n the size of the array of channels. * @param buffer the buffer implementation to use. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2Any(int) */ public static FilteredAny2AnyChannel[] createAny2Any(ChannelDataStore buffer, int n) { return (FilteredAny2AnyChannel[]) factory.createAny2Any(buffer, n); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredAny2OneChannel.java0000644000000000000000000000525511105701167022500 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.Any2OneChannel; /** * Interface for an Any2One channel that supports filtering operations at each end. * * @see org.jcsp.lang.Any2OneChannel * @see org.jcsp.util.filter.ReadFiltered * @see org.jcsp.util.filter.WriteFiltered * * @author Quickstone Technologies Limited */ public interface FilteredAny2OneChannel extends Any2OneChannel { /** * Returns an interface for configuring read filters on the channel. */ public ReadFiltered inFilter(); /** * Returns an interface for configuring write filters on the channel. */ public WriteFiltered outFilter(); } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredChannelEndFactory.java0000644000000000000000000001067011105701167023260 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** *

Factory for creating filtered channel ends around existing channel ends.

* *

An instance of this class can be created and used, or alternatively the static factory * FilteredChannelEnd may be more convenient.

* * @author Quickstone Technologies Limited */ public class FilteredChannelEndFactory { /** * Constructs a new FilteredChannelEndFactory. */ public FilteredChannelEndFactory() { super(); } /** * Creates a new filtered channel input end around an existing channel end. The created channel end * can be used as a guard in an Alternative. * * @param in the existing channel end. * @return the created channel end. */ public FilteredAltingChannelInput createFiltered(AltingChannelInput in) { return new FilteredAltingChannelInput(in); } /** * Creates a new filtered channel input end around an existing channel end. * * @param in the existing channel end. * @return the created channel end. */ public FilteredChannelInput createFiltered(ChannelInput in) { return new FilteredChannelInputWrapper(in); } /** * Creates a new filtered channel input end around an existing channel end. The created channel end * can be shared by multiple processes. * * @param in the existing channel end. * @return the created channel end. */ public FilteredSharedChannelInput createFiltered(SharedChannelInput in) { return new FilteredSharedChannelInputWrapper(in); } /** * Creates a new filtered channel output end around an existing channel end. * * @param out the existing channel end. * @return the created channel end. */ public FilteredChannelOutput createFiltered(ChannelOutput out) { return new FilteredChannelOutputWrapper(out); } /** * Creates a new filtered channel output end around an existing channel end. The created channel end * can be shared by multiple processes. * * @param out the existing channel end. * @return the created channel end. */ public FilteredSharedChannelOutput createFiltered(SharedChannelOutput out) { return new FilteredSharedChannelOutputWrapper(out); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredAltingChannelInput.java0000644000000000000000000001016311105701167023455 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * Implements an AltingChannelInput channel end that also supports read filters. * * @see org.jcsp.lang.AltingChannelInput * @see org.jcsp.util.filter.ReadFiltered * * @author Quickstone Technologies Limited */ public class FilteredAltingChannelInput extends AltingChannelInputWrapper implements FilteredChannelInput { /** * Holds the filters installed for the read end of this channel. */ private FilterHolder filters = null; /** * Constructs a new channel end that supports filtering by wrapping up an existing channel end. * * @param altingChannelInput the existing channel end. */ FilteredAltingChannelInput(AltingChannelInput altingChannelInput) { super(altingChannelInput); } public Object read() { Object toFilter = super.read(); for (int i = 0; filters != null && i < filters.getFilterCount(); i++) toFilter = filters.getFilter(i).filter(toFilter); return toFilter; } public void addReadFilter(Filter filter) { if (filters == null) filters = new FilterHolder(); filters.addFilter(filter); } public void addReadFilter(Filter filter, int index) { if (filters == null) filters = new FilterHolder(); filters.addFilter(filter, index); } public void removeReadFilter(Filter filter) { if (filters == null) filters = new FilterHolder(); filters.removeFilter(filter); } public void removeReadFilter(int index) { if (filters == null) filters = new FilterHolder(); filters.removeFilter(index); } public Filter getReadFilter(int index) { if (filters == null) filters = new FilterHolder(); return filters.getFilter(index); } public int getReadFilterCount() { if (filters == null) return 0; return filters.getFilterCount(); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredChannelOutputWrapper.java0000644000000000000000000000763411105701167024071 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * Wrapper for an output channel end to include write filtering ability. * * @author Quickstone Technologies Limited */ class FilteredChannelOutputWrapper extends ChannelOutputWrapper implements FilteredChannelOutput { /** * Set of write filters installed. */ private FilterHolder filters = null; /** * Constructs a new FilteredChannelOutputWrapper around the given output channel end. * * @param out the existing output channel. */ public FilteredChannelOutputWrapper(ChannelOutput out) { super(out); } public void write(Object data) { for (int i = 0; filters != null && i < filters.getFilterCount(); i++) data = filters.getFilter(i).filter(data); super.write(data); } public void addWriteFilter(Filter filter) { if (filters == null) filters = new FilterHolder(); filters.addFilter(filter); } public void addWriteFilter(Filter filter, int index) { if (filters == null) filters = new FilterHolder(); filters.addFilter(filter, index); } public void removeWriteFilter(Filter filter) { if (filters == null) filters = new FilterHolder(); filters.removeFilter(filter); } public void removeWriteFilter(int index) { if (filters == null) filters = new FilterHolder(); filters.removeFilter(index); } public Filter getWriteFilter(int index) { if (filters == null) filters = new FilterHolder(); return filters.getFilter(index); } public int getWriteFilterCount() { if (filters == null) return 0; return filters.getFilterCount(); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/filter/FilteredSharedChannelOutputWrapper.java0000644000000000000000000001002511105701167025204 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.filter; import org.jcsp.lang.*; /** * This is wrapper for a SharedChannelOutput that adds * write filtering. Instances of this class can be safely used by * multiple concurrent processes. * * @author Quickstone Technologies Limited */ public class FilteredSharedChannelOutputWrapper extends FilteredChannelOutputWrapper implements FilteredSharedChannelOutput { /** * The synchronization object to protect the writers from each other when they read data or update * the write filters. */ private Object synchObject; /** * Constructs a new wrapper for the given channel output end. * * @param out the existing channel end. */ public FilteredSharedChannelOutputWrapper(SharedChannelOutput out) { super(out); synchObject = new Object(); } public void write(Object data) { synchronized (synchObject) { super.write(data); } } public void addWriteFilter(Filter filter) { synchronized (synchObject) { super.addWriteFilter(filter); } } public void addWriteFilter(Filter filter, int index) { synchronized (synchObject) { super.addWriteFilter(filter, index); } } public void removeWriteFilter(Filter filter) { synchronized (synchObject) { super.removeWriteFilter(filter); } } public void removeWriteFilter(int index) { synchronized (synchObject) { super.removeWriteFilter(index); } } public Filter getWriteFilter(int index) { synchronized (synchObject) { return super.getWriteFilter(index); } } public int getWriteFilterCount() { synchronized (synchObject) { return super.getWriteFilterCount(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/util/BufferSizeError.java0000644000000000000000000000675511105701167020054 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util; /** * This is thrown if an attempt is made to create some variety of buffered channel * with a zero or negative sized buffer. * *

Description

* Buffered channels must have (usually non-zero) positive sized buffers. * The following constructions will all throw this {@link java.lang.Error}: *
 *   One2OneChannel c = Channel.one2one (new Buffer (-42));                 // must be >= 0
 *   One2OneChannel c = Channel.one2one (new OverFlowingBuffer (-42));      // must be > 0
 *   One2OneChannel c = Channel.one2one (new OverWriteOldestBuffer (-42));  // must be > 0
 *   One2OneChannel c = Channel.one2one (new OverWritingBuffer (-42));      // must be > 0
 *   One2OneChannel c = Channel.one2one (new InfiniteBuffer (-42));         // must be > 0
 * 
* Zero-buffered non-overwriting channels are, of course, the default channel semantics. * The following constructions are all legal and equivalent: *
 *   One2OneChannel c = Channel.one2one ();
 *   One2OneChannel c = Channel.one2one (new ZeroBuffer ());    // less efficient
 *   One2OneChannel c = Channel.one2one (new Buffer (0));       // less efficient
 * 
* No action should be taken to catch BufferSizeError. * Application code generating it is in error and needs correcting. * * @author P.H. Welch */ public class BufferSizeError extends Error { public BufferSizeError (String s) { super (s); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/package.html0000644000000000000000000000175611077376055016424 0ustar This provides classes and interfaces to customise the semantics of Object channels.

By default, channels are zero-buffered and fully synchronised: both a reader and a writer have to be ready for a communication to proceed. Whoever gets to the communication point first has to wait for the other party.

This package provides a variety of classes conforming to the {@link org.jcsp.util.ChannelDataStore} interface. These classes can be used as plug-ins to the static {@link org.jcsp.lang.Channel} manufacturing methods to customise their semantics. Classes are provided for blocking FIFO buffers, overwriting buffers (losing either the newest or oldest data) and infinite (within the realms of your virtual memory) buffers.

Users may write and use their own implementations of the {@link org.jcsp.util.ChannelDataStore} interface, but great care must be taken to specify its semantics. It should not normally be necessary to do this. jcsp-1.1-rc4.orig/src/org/jcsp/util/OverWriteOldestBuffer.java0000644000000000000000000002071311105701167021217 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util; import java.io.Serializable; /** * This is used to create a buffered object channel that always accepts input, * overwriting its oldest data if full. *

Description

* OverWriteOldestBuffer is an implementation of ChannelDataStore that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * When full, a writer will overwrite the oldest item left unread in the channel. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2one(org.jcsp.util.ChannelDataStore)} etc.). *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. * * @see org.jcsp.util.ZeroBuffer * @see org.jcsp.util.Buffer * @see org.jcsp.util.OverWritingBuffer * @see org.jcsp.util.OverFlowingBuffer * @see org.jcsp.util.InfiniteBuffer * @see org.jcsp.lang.Channel * * @author P.D. Austin */ public class OverWriteOldestBuffer implements ChannelDataStore, Serializable { /** The storage for the buffered Objects */ private final Object[] buffer; /** The number of Objects stored in the Buffer */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; private boolean valueWrittenWhileFull = false; /** * Construct a new OverWriteOldestBuffer with the specified size. * * @param size the number of Objects the OverWriteOldestBuffer can store. * @throws BufferSizeError if size is zero or negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public OverWriteOldestBuffer(int size) { if (size <= 0) throw new BufferSizeError ("\n*** Attempt to create an overwriting buffered channel with negative or zero capacity"); buffer = new Object[size]; } /** * Returns the oldest Object from the OverWriteOldestBuffer and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the OverWriteOldestBuffer */ public Object get() { Object value = buffer[firstIndex]; buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Begins an extended rendezvous by the reader. * The semantics of an extended rendezvous on an overwrite-oldest buffer are slightly * complicated, but hopefully intuitive. *

* When a reader begins an extended rendezvous, the oldest value is returned from the buffer * (as it would be for a call to {@link #get()}). While an extended rendezvous is ongoing, the * writer may (repeatedly) write to the buffer, without ever blocking. *

* When the reader finishes an extended rendezvous, the following options are possible: *

    *
  • The writer has not written to the channel during the rendezvous. In this case, * the value that was read at the start of the rendezvous is removed from the buffer.
  • *
  • The writer has written to the channel during the rendezvous, but has not over-written * the value that was read at the start of the rendezvous. In this case, the value that * was read at the start of the rendezvous is removed from the buffer.
  • *
  • The writer has written to the channel during the rendezvous, and has over-written * (perhaps repeatedly) the value that was read at the start of the rendezvous. In this case, * the value that was read at the start of the rendezvous is no longer in the buffer, and hence * nothing is removed.
  • *
* * @return The oldest value in the buffer at this time */ public Object startGet() { valueWrittenWhileFull = false; return buffer[firstIndex]; } /** * This ends an extended rendezvous by the reader. * * @see #startGet() */ public void endGet() { if (false == valueWrittenWhileFull) { //Our data hasn't been over-written so remove it: buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; } } /** * Puts a new Object into the OverWriteOldestBuffer. *

* If OverWriteOldestBuffer is full, the oldest item * left unread in the buffer will be overwritten. * * @param value the Object to put into the OverWriteOldestBuffer */ public void put(Object value) { if (counter == buffer.length) { firstIndex = (firstIndex + 1) % buffer.length; valueWrittenWhileFull = true; } else { counter++; } buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; } /** * Returns the current state of the OverWriteOldestBuffer. * * @return the current state of the OverWriteOldestBuffer (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) OverWriteOldestBuffer with the same * creation parameters as this one. *

* Note: Only the size and structure of the OverWriteOldestBuffer is * cloned, not any stored data. * * @return the cloned instance of this OverWriteOldestBuffer. */ public Object clone() { return new OverWriteOldestBuffer(buffer.length); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; for (int i = 0;i < buffer.length;i++) { //Null the objects so they can be garbage collected: buffer[i] = null; } } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/0000755000000000000000000000000011410045055015067 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/package.html0000644000000000000000000000177211077376055017377 0ustar This provides classes and interfaces to customise the semantics of int channels.

By default, channels are zero-buffered and fully synchronised: both a reader and a writer have to be ready for a communication to proceed. Whoever gets to the communication point first has to wait for the other party.

This package provides a variety of classes conforming to the {@link org.jcsp.util.ints.ChannelDataStoreInt} interface. These classes can be used as plug-ins to the static {@link org.jcsp.lang.Channel} manufacturing methods to customise their semantics. Classes are provided for blocking FIFO buffers, overwriting buffers (losing either the newest or oldest data) and infinite (within the realms of your virtual memory) buffers.

Users may write and use their own implementations of the {@link org.jcsp.util.ints.ChannelDataStoreInt} interface, but great care must be taken to specify its semantics. It should not normally be necessary to do this. jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/OverWriteOldestBufferInt.java0000644000000000000000000002045011105701167022645 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.ints; import java.io.Serializable; /** * This is used to create a buffered integer channel that always accepts input, * overwriting its oldest data if full. *

Description

* OverWriteOldestBufferInt is an implementation of ChannelDataStoreInt that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * When full, a writer will overwrite the oldest item left unread in the channel. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt)} etc.). *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. * * @see org.jcsp.util.ints.ZeroBufferInt * @see org.jcsp.util.ints.BufferInt * @see org.jcsp.util.ints.OverWritingBufferInt * @see org.jcsp.util.ints.OverFlowingBufferInt * @see org.jcsp.util.ints.InfiniteBufferInt * @see org.jcsp.lang.ChannelInt * * @author P.D. Austin */ //}}} public class OverWriteOldestBufferInt implements ChannelDataStoreInt, Serializable { /** The storage for the buffered ints */ private final int[] buffer; /** The number of ints stored in the Buffer */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; private boolean valueWrittenWhileFull = false; /** * Construct a new OverWriteOldestBufferInt with the specified size. * * @param size the number of ints the OverWriteOldestBufferInt can store. * @throws BufferIntSizeError if size is zero or negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public OverWriteOldestBufferInt(int size) { if (size <= 0) throw new BufferIntSizeError ("\n*** Attempt to create an overwriting buffered channel with negative or zero capacity"); buffer = new int[size]; } /** * Returns the oldest int from the OverWriteOldestBufferInt and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest int from the OverWriteOldestBufferInt */ public int get() { int value = buffer[firstIndex]; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Begins an extended rendezvous by the reader. * * The semantics of an extended rendezvous on an overwrite-oldest buffer are slightly * complicated, but hopefully intuitive. * * When a reader begins an extended rendezvous, the oldest value is returned from the buffer * (as it would be for a call to {@link #get()}). While an extended rendezvous is ongoing, the * writer may (repeatedly) write to the buffer, without ever blocking. * * When the reader finishes an extended rendezvous, the following options are possible: *

    *
  • The writer has not written to the channel during the rendezvous. In this case, * the value that was read at the start of the rendezvous is removed from the buffer.
  • *
  • The writer has written to the channel during the rendezvous, but has not over-written * the value that was read at the start of the rendezvous. In this case, the value that * was read at the start of the rendezvous is removed from the buffer.
  • *
  • The writer has written to the channel during the rendezvous, and has over-written * (perhaps repeatedly) the value that was read at the start of the rendezvous. In this case, * the value that was read at the start of the rendezvous is no longer in the buffer, and hence * nothing is removed.
  • *
* * @return The oldest value in the buffer at this time */ public int startGet() { valueWrittenWhileFull = false; return buffer[firstIndex]; } /** * See {@link #startGet()} for a description of the semantics of this method. */ public void endGet() { if (false == valueWrittenWhileFull) { //Our data hasn't been over-written so remove it: firstIndex = (firstIndex + 1) % buffer.length; counter--; } } /** * Puts a new int into the OverWriteOldestBufferInt. *

* If OverWriteOldestBufferInt is full, the oldest item * left unread in the buffer will be overwritten. * * @param value the int to put into the OverWriteOldestBufferInt */ public void put(int value) { if (counter == buffer.length) { firstIndex = (firstIndex + 1) % buffer.length; valueWrittenWhileFull = true; } else { counter++; } buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; } /** * Returns the current state of the OverWriteOldestBufferInt. * * @return the current state of the OverWriteOldestBufferInt (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) OverWriteOldestBufferInt with the same * creation parameters as this one. *

* Note: Only the size and structure of the OverWriteOldestBufferInt is * cloned, not any stored data. * * @return the cloned instance of this OverWriteOldestBufferInt. */ public Object clone() { return new OverWriteOldestBufferInt(buffer.length); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/BufferInt.java0000644000000000000000000001431511105701167017626 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.ints; import java.io.Serializable; /** * This is used to create a buffered integer channel that never loses data. *

Description

* BufferInt is an implementation of ChannelDataStoreInt that yields * a blocking FIFO buffered semantics for a channel. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt)} etc.). *

* The getState method returns EMPTY, NONEMPTYFULL or * FULL according to the state of the buffer. * * @see org.jcsp.util.ints.ZeroBufferInt * @see org.jcsp.util.ints.OverWriteOldestBufferInt * @see org.jcsp.util.ints.OverWritingBufferInt * @see org.jcsp.util.ints.OverFlowingBufferInt * @see org.jcsp.util.ints.InfiniteBufferInt * @see org.jcsp.lang.ChannelInt * * @author P.D. Austin */ public class BufferInt implements ChannelDataStoreInt, Serializable { /** The storage for the buffered ints */ private final int[] buffer; /** The number of ints stored in the BufferInt */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; /** * Construct a new BufferInt with the specified size. * * @param size the number of ints the BufferInt can store. * @throws BufferIntSizeError if size is negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public BufferInt (int size) { if (size < 0) { throw new BufferIntSizeError ( "\n*** Attempt to create a buffered channel with negative capacity" ); } buffer = new int[size + 1]; // the extra one is a subtlety needed by // the current channel algorithms. } /** * Returns the oldest int from the BufferInt and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest int from the BufferInt */ public int get () { int value = buffer[firstIndex]; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Returns the oldest integer from the buffer but does not remove it. * * Pre-condition: getState must not currently return EMPTY. * * @return the oldest int from the Buffer */ public int startGet() { return buffer[firstIndex]; } /** * Removes the oldest integer from the buffer. */ public void endGet() { firstIndex = (firstIndex + 1) % buffer.length; counter--; } /** * Puts a new int into the BufferInt. *

* Pre-condition: getState must not currently return FULL. * * @param value the int to put into the BufferInt */ public void put (int value) { buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; counter++; } /** * Returns the current state of the BufferInt. * * @return the current state of the BufferInt (EMPTY, * NONEMPTYFULL or FULL) */ public int getState () { if (counter == 0) { return EMPTY; } else if (counter == buffer.length) { return FULL; } else { return NONEMPTYFULL; } } /** * Returns a new (and EMPTY) BufferInt with the same * creation parameters as this one. *

* Note: Only the size and structure of the BufferInt is * cloned, not any stored data. * * @return the cloned instance of this BufferInt */ public Object clone () { return new BufferInt (buffer.length - 1); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/BufferIntSizeError.java0000644000000000000000000000733211105701167021474 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.ints; /** * This is thrown if an attempt is made to create some variety of buffered channel * with a zero or negative sized buffer. * *

Description

* Buffered channels must have (usually non-zero) positive sized buffers. * The following constructions will all throw this {@link java.lang.Error}: *
 *   One2OneChannelInt c = Channel.one2oneInt (new BufferInt (-42));                 // must be >= 0
 *   One2OneChannelInt c = Channel.one2oneInt (new OverFlowingBufferInt (-42));      // must be > 0
 *   One2OneChannelInt c = Channel.one2oneInt (new OverWriteOldestBufferInt (-42));  // must be > 0
 *   One2OneChannelInt c = Channel.one2oneInt (new OverWritingBufferInt (-42));      // must be > 0
 *   One2OneChannelInt c = Channel.one2oneInt (new InfiniteBufferInt (-42));         // must be > 0
 * 
* Zero-buffered non-overwriting channels are, of course, the default channel semantics. * The following constructions are all legal and equivalent: *
 *   One2OneChannelInt c = Channel.one2oneInt ();
 *   One2OneChannelInt c = Channel.one2oneInt (new ZeroBufferInt ());      // less efficient
 *   One2OneChannelInt c = Channel.one2oneInt (new BufferInt (0));         // less efficient
 * 
* No action should be taken to catch BufferSizeError. * Application code generating it is in error and needs correcting. * * @author P.H. Welch */ public class BufferIntSizeError extends Error { /** * Constructs a new BufferIntSizeError with the specified detail message. * * @param s the detail message. */ public BufferIntSizeError(String s) { super(s); } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/InfiniteBufferInt.java0000644000000000000000000001711111105701167021311 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.ints; import java.io.Serializable; /** * This is used to create a buffered integer channel that always accepts and * never loses any input. *

Description

* InfiniteBufferInt is an implementation of ChannelDataStoreInt that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * However, its capacity is infinite (expanding to whatever is needed so far as * the underlying memory system will permit). So, it never gets full and blocks * a writer. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt)} etc.). *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. *

* An initial size for the buffer can be specified during construction. * * @see org.jcsp.util.ints.ZeroBufferInt * @see org.jcsp.util.ints.BufferInt * @see org.jcsp.util.ints.OverWriteOldestBufferInt * @see org.jcsp.util.ints.OverWritingBufferInt * @see org.jcsp.util.ints.OverFlowingBufferInt * @see org.jcsp.lang.ChannelInt * * @author P.D. Austin */ //}}} public class InfiniteBufferInt implements ChannelDataStoreInt, Serializable { /** The default size of the buffer */ private static final int DEFAULT_SIZE = 8; /** The initial size of the buffer */ private int initialSize; /** The storage for the buffered ints */ private int[] buffer; /** The number of ints stored in the InfiniteBufferInt */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; /** * Construct a new InfiniteBufferInt with the default size (of 8). */ public InfiniteBufferInt() { this(DEFAULT_SIZE); } /** * Construct a new InfiniteBufferInt with the specified initial size. * * @param initialSize the number of ints * the InfiniteBufferInt can initially store. * @throws BufferIntSizeError if initialSize is zero or negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public InfiniteBufferInt(int initialSize) { if (initialSize <= 0) throw new BufferIntSizeError ("\n*** Attempt to create a buffered channel with an initially negative or zero capacity"); this.initialSize = initialSize; buffer = new int[initialSize]; } /** * Returns the oldest int from the InfiniteBufferInt and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest int from the InfiniteBufferInt */ public int get() { int value = buffer[firstIndex]; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Returns the oldest integer from the buffer but does not remove it. * * Pre-condition: getState must not currently return EMPTY. * * @return the oldest int from the Buffer */ public int startGet() { return buffer[firstIndex]; } /** * Removes the oldest integer from the buffer. */ public void endGet() { firstIndex = (firstIndex + 1) % buffer.length; counter--; } /** * Puts a new int into the InfiniteBufferInt. *

* Implementation note: if InfiniteBufferInt is full, a new internal * buffer with double the capacity is constructed and the old data copied across. * * @param value the int to put into the InfiniteBufferInt */ public void put(int value) { if (counter == buffer.length) { int[] temp = buffer; buffer = new int[buffer.length * 2]; System.arraycopy(temp, firstIndex, buffer, 0, temp.length - firstIndex); System.arraycopy(temp, 0, buffer, temp.length - firstIndex, firstIndex); firstIndex = 0; lastIndex = temp.length; } buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; counter++; } /** * Returns the current state of the InfiniteBufferInt. * * @return the current state of the InfiniteBufferInt (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) InfiniteBufferInt with the same * creation parameters as this one. *

* Note: Only the initial size and structure of the InfiniteBufferInt * is cloned, not any stored data. * * @return the cloned instance of this InfiniteBufferInt. */ public Object clone() { return new InfiniteBufferInt(initialSize); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/ZeroBufferInt.java0000644000000000000000000001241411105701167020464 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.ints; import java.io.Serializable; /** * This is used to create a zero-buffered integer channel that never loses data. *

Description

* ZeroBufferInt is an implementation of ChannelDataStoreInt that yields * the standard CSP semantics for a channel -- that is zero buffered with * direct synchronisation between reader and writer. Unless specified otherwise, * this is the default behaviour for channels. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt)} etc.). *

* The getState method will return FULL if there is an output * waiting on the channel and EMPTY if there is not. * * @see org.jcsp.util.ints.BufferInt * @see org.jcsp.util.ints.OverWriteOldestBufferInt * @see org.jcsp.util.ints.OverWritingBufferInt * @see org.jcsp.util.ints.OverFlowingBufferInt * @see org.jcsp.util.ints.InfiniteBufferInt * @see org.jcsp.lang.ChannelInt * * @author P.D. Austin */ //}}} public class ZeroBufferInt implements ChannelDataStoreInt, Serializable { /** The current state */ private int state = EMPTY; /** The int */ private int value; /** * Returns the int from the ZeroBufferInt. *

* Pre-condition: getState must not currently return EMPTY. * * @return the int from the ZeroBufferInt */ public int get() { state = EMPTY; int o = value; return o; } /** * Begins an extended rendezvous - simply returns the next integer in the buffer. * This function does not remove the integer. * * Pre-condition: getState must not currently return EMPTY. * * @return The integer in the buffer. */ public int startGet() { return value; } /** * Ends the extended rendezvous by clearing the buffer. */ public void endGet() { state = EMPTY; } /** * Puts a new int into the ZeroBufferInt. *

* Pre-condition: getState must not currently return FULL. * * @param value the int to put into the ZeroBufferInt */ public void put(int value) { state = FULL; this.value = value; } /** * Returns the current state of the ZeroBufferInt. * * @return the current state of the ZeroBufferInt (EMPTY * or FULL) */ public int getState() { return state; } /** * Returns a new (and EMPTY) ZeroBufferInt with the same * creation parameters as this one. *

* Note: Only the size and structure of the ZeroBufferInt is * cloned, not any stored data. * * @return the cloned instance of this ZeroBufferInt. */ public Object clone() { return new ZeroBufferInt(); } public void removeAll() { state = EMPTY; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/OverFlowingBufferInt.java0000644000000000000000000001517211105701167022012 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.ints; import java.io.Serializable; /** * This is used to create a buffered integer channel that always accepts input, * discarding its last entered data if full. *

Description

* OverFlowingBufferInt is an implementation of ChannelDataStoreInt that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * When full, a writer will be accepted but the written value overflows the buffer * and is lost to the channel. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt)} etc.). *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. * * @see org.jcsp.util.ints.ZeroBufferInt * @see org.jcsp.util.ints.BufferInt * @see org.jcsp.util.ints.OverWriteOldestBufferInt * @see org.jcsp.util.ints.OverWritingBufferInt * @see org.jcsp.util.ints.InfiniteBufferInt * @see org.jcsp.lang.ChannelInt * * @author P.D. Austin */ public class OverFlowingBufferInt implements ChannelDataStoreInt, Serializable { /** The storage for the buffered ints */ private final int[] buffer; /** The number of ints stored in the Buffer */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; /** * Construct a new OverFlowingBufferInt with the specified size. * * @param size the number of ints the OverFlowingBufferInt can store. * @throws BufferIntSizeError if size is zero or negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public OverFlowingBufferInt(int size) { if (size <= 0) throw new BufferIntSizeError ("\n*** Attempt to create an overflowing buffered channel with negative or zero capacity"); buffer = new int[size]; } /** * Returns the oldest int from the OverFlowingBufferInt and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest int from the OverFlowingBufferInt */ public int get() { int value = buffer[firstIndex]; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Returns the oldest integer from the buffer but does not remove it. * * Pre-condition: getState must not currently return EMPTY. * * @return the oldest int from the Buffer */ public int startGet() { return buffer[firstIndex]; } /** * Removes the oldest integer from the buffer. */ public void endGet() { firstIndex = (firstIndex + 1) % buffer.length; counter--; } /** * Puts a new int into the OverFlowingBufferInt. *

* If OverFlowingBufferInt is full, the item is discarded. * * @param value the int to put into the OverFlowingBufferInt */ public void put(int value) { if (counter < buffer.length) { buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; counter++; } } /** * Returns the current state of the OverFlowingBufferInt. * * @return the current state of the OverFlowingBufferInt (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) OverFlowingBufferInt with the same * creation parameters as this one. *

* Note: Only the size and structure of the OverFlowingBufferInt is * cloned, not any stored data. * * @return the cloned instance of this OverFlowingBufferInt. */ public Object clone() { return new OverFlowingBufferInt(buffer.length); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/OverWritingBufferInt.java0000644000000000000000000001743711105701167022036 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.ints; import java.io.Serializable; import org.jcsp.util.OverWriteOldestBuffer; //{{{ javadoc /** * This is used to create a buffered integer channel that always accepts input, * overwriting its last entered data if full. *

Description

* OverWritingBufferInt is an implementation of ChannelDataStoreInt that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * When full, a writer will overwrite the latest item written to the channel. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt)} etc.). *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. * * @see org.jcsp.util.ints.ZeroBufferInt * @see org.jcsp.util.ints.BufferInt * @see org.jcsp.util.ints.OverWriteOldestBufferInt * @see org.jcsp.util.ints.OverFlowingBufferInt * @see org.jcsp.util.ints.InfiniteBufferInt * @see org.jcsp.lang.ChannelInt * * @author P.D. Austin */ //}}} public class OverWritingBufferInt implements ChannelDataStoreInt, Serializable { /** The storage for the buffered ints */ private final int[] buffer; /** The number of ints stored in the Buffer */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; private boolean valueWrittenWhileFull = false; /** * Construct a new OverWritingBufferInt with the specified size. * * @param size the number of ints the OverWritingBufferInt can store. * @throws BufferIntSizeError if size is zero or negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public OverWritingBufferInt(int size) { if (size <= 0) throw new BufferIntSizeError ("\n*** Attempt to create an overwriting buffered channel with negative or zero capacity"); buffer = new int[size]; } /** * Returns the oldest int from the OverWritingBufferInt and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest int from the OverWritingBufferInt */ public int get() { int value = buffer[firstIndex]; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Begins an extended rendezvous by the reader. * * The semantics of an extended rendezvous on an overwrite-newest buffer are slightly * complicated, but hopefully intuitive. * * If the buffer is of size 2 or larger, the semantics are as follows. * Beginning an extended rendezvous will return the oldest value in the buffer, but not remove it. * If the writer writes to the buffer during the rendezvous, it will grow the buffer and end up * overwriting the newest value as normal. At the end of the extended rendezvous, the oldest * value is removed. * * If the buffer is of size 1, the semantics are identical to those of an {@link OverWriteOldestBuffer}. * For a complete description, refer to the documentation for the {@link OverWriteOldestBuffer#startGet()} method. * * @return The oldest value in the buffer at this time */ public int startGet() { valueWrittenWhileFull = false; return buffer[firstIndex]; } /** * See {@link #startGet()} for a description of the semantics of this method. */ public void endGet() { if (false == valueWrittenWhileFull || buffer.length != 1) { //Our data hasn't been over-written so remove it: firstIndex = (firstIndex + 1) % buffer.length; counter--; } } /** * Puts a new int into the OverWritingBufferInt. *

* If OverWritingBufferInt is full, the last item * previously put into the buffer will be overwritten. * * @param value the int to put into the OverWritingBufferInt */ public void put(int value) { if (counter == buffer.length) { buffer[(lastIndex - 1 + buffer.length) % buffer.length] = value; valueWrittenWhileFull = true; } else { buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; counter++; } } /** * Returns the current state of the OverWritingBufferInt. * * @return the current state of the OverWritingBufferInt (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) OverWritingBufferInt with the same * creation parameters as this one. *

* Note: Only the size and structure of the OverWritingBufferInt is * cloned, not any stored data. * * @return the cloned instance of this OverWritingBufferInt. */ public Object clone() { return new OverWritingBufferInt(buffer.length); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ints/ChannelDataStoreInt.java0000644000000000000000000001572611105701167021603 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util.ints; import org.jcsp.util.OverWriteOldestBuffer; import org.jcsp.util.OverWritingBuffer; /** * This is the interface for integer channel plug-ins that define their buffering * characteristics. *

Description

* ChannelDataStoreInt defines the interface to the logic used by * the integer channels defined in the org.jcsp.lang package to manage * the data being communicated. *

* This enables that logic to be varied by creating channels specifying * a particular implementation of this interface. This reduces the number of * classes that would otherwise need to be defined. The default channel * constructor (with no parameters) uses the ZeroBuffer implementation, * which gives the standard CSP semantics -- no buffering and full synchronisation * between reading and writing processes. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt)} etc.). *

* Note: instances of ChannelDataStoreInt implementations are * used by the various channel classes within org.jcsp.lang * in a thread-safe way. They are not intended for any other purpose. * Developers of new ChannelDataStoreInt implementations, * therefore, do not need to worry about thread safety (e.g. by making its * methods synchronized). Also, developers can assume that * the documented pre-conditions for invoking the get * and put methods will be met. * * @see org.jcsp.util.ints.ZeroBufferInt * @see org.jcsp.util.ints.BufferInt * @see org.jcsp.util.ints.OverWriteOldestBufferInt * @see org.jcsp.util.ints.OverWritingBufferInt * @see org.jcsp.util.ints.OverFlowingBufferInt * @see org.jcsp.util.ints.InfiniteBufferInt * @see org.jcsp.lang.ChannelInt * * @author P.D. Austin */ //}}} public interface ChannelDataStoreInt extends Cloneable { /** Indicates that the ChannelDataStoreInt is empty * -- it can accept only a put. */ public final static int EMPTY = 0; /** * Indicates that the ChannelDataStoreInt is neither empty nor full * -- it can accept either a put or a get call. */ public final static int NONEMPTYFULL = 1; /** Indicates that the ChannelDataStoreInt is full * -- it can accept only a get. */ public final static int FULL = 2; /** * Returns the current state of the ChannelDataStoreInt. * * @return the current state of the ChannelDataStoreInt (EMPTY, * NONEMPTYFULL or FULL) */ public abstract int getState (); /** * Puts a new int into the ChannelDataStoreInt. *

* Pre-condition: getState must not currently return FULL. * * @param value the int to put into the ChannelDataStoreInt */ public abstract void put (int value); /** * Returns an int from the ChannelDataStoreInt. *

* Pre-condition: getState must not currently return EMPTY. * * @return an int from the ChannelDataStoreInt */ public abstract int get (); /** * Begins an extended read on the buffer, returning the data for the extended read * * Pre-condition: getState must not currently return EMPTY. * * The exact behaviour of this method depends on your buffer. When a process performs an * extended rendezvous on a buffered channel, it will first call this method, then the * {@link #endGet} method. * * A FIFO buffer would implement this method as returning the value from the front of the buffer * and the next call would remove the value. An overflowing buffer would do the same. * * However, for an overwriting buffer it is more complex. Refer to the documentation for * {@link OverWritingBuffer#startGet} and {@link OverWriteOldestBuffer#startGet} * for details * * @return The int to be read from the channel at the beginning of the extended rendezvous * * @see #endGet */ public abstract int startGet(); /** * Ends an extended read on the buffer. * * The channels guarantee that this method will be called exactly once after each beginExtRead call. * During the period between startGet and endGet, it is possible that {@link #put} will be called, * but not {@link #get}. * * @see #startGet */ public abstract void endGet(); /** * Returns a new (and EMPTY) ChannelDataStoreInt with the same * creation parameters as this one. *

* Note: Only the size and structure of the ChannelDataStoreInt should * be cloned, not any stored data. * * @return the cloned instance of this ChannelDataStoreInt. */ public abstract Object clone (); public abstract void removeAll(); } jcsp-1.1-rc4.orig/src/org/jcsp/util/InfiniteBuffer.java0000644000000000000000000001732611105701167017671 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util; import java.io.Serializable; /** * This is used to create a buffered object channel that always accepts and * never loses any input. *

Description

* InfiniteBuffer is an implementation of ChannelDataStore that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * However, its capacity is infinite (expanding to whatever is needed so far as * the underlying memory system will permit). So, it never gets full and blocks * a writer. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2one(org.jcsp.util.ChannelDataStore)} etc.). *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. *

* An initial size for the buffer can be specified during construction. * * @see org.jcsp.util.ZeroBuffer * @see org.jcsp.util.Buffer * @see org.jcsp.util.OverWriteOldestBuffer * @see org.jcsp.util.OverWritingBuffer * @see org.jcsp.util.OverFlowingBuffer * @see org.jcsp.lang.Channel * * @author P.D. Austin */ public class InfiniteBuffer implements ChannelDataStore, Serializable { /** The default size of the buffer */ private static final int DEFAULT_SIZE = 8; /** The initial size of the buffer */ private int initialSize; /** The storage for the buffered Objects */ private Object[] buffer; /** The number of Objects stored in the InfiniteBuffer */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; /** * Construct a new InfiniteBuffer with the default size (of 8). */ public InfiniteBuffer() { this(DEFAULT_SIZE); } /** * Construct a new InfiniteBuffer with the specified initial size. * * @param initialSize the number of Objects * the InfiniteBuffer can initially store. * @throws BufferSizeError if size is zero or negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public InfiniteBuffer(int initialSize) { if (initialSize <= 0) throw new BufferSizeError ("\n*** Attempt to create a buffered channel with an initially negative or zero capacity"); this.initialSize = initialSize; buffer = new Object[initialSize]; } /** * Returns the oldest Object from the InfiniteBuffer and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the InfiniteBuffer */ public Object get() { Object value = buffer[firstIndex]; buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Returns the oldest object from the buffer but does not remove it. * * Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the Buffer */ public Object startGet() { return buffer[firstIndex]; } /** * Removes the oldest object from the buffer. */ public void endGet() { buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; } /** * Puts a new Object into the InfiniteBuffer. *

* Implementation note: if InfiniteBuffer is full, a new internal * buffer with double the capacity is constructed and the old data copied across. * * @param value the Object to put into the InfiniteBuffer */ public void put(Object value) { if (counter == buffer.length) { Object[] temp = buffer; buffer = new Object[buffer.length * 2]; System.arraycopy(temp, firstIndex, buffer, 0, temp.length - firstIndex); System.arraycopy(temp, 0, buffer, temp.length - firstIndex, firstIndex); firstIndex = 0; lastIndex = temp.length; } buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; counter++; } /** * Returns the current state of the InfiniteBuffer. * * @return the current state of the InfiniteBuffer (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) InfiniteBuffer with the same * creation parameters as this one. *

* Note: Only the initial size and structure of the InfiniteBuffer * is cloned, not any stored data. * * @return the cloned instance of this InfiniteBuffer. */ public Object clone() { return new InfiniteBuffer(initialSize); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; for (int i = 0;i < buffer.length;i++) { //Null the objects so they can be garbage collected: buffer[i] = null; } } } jcsp-1.1-rc4.orig/src/org/jcsp/util/ZeroBuffer.java0000644000000000000000000001262011105701167017033 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util; import java.io.Serializable; //{{{ javadoc /** * This is used to create a zero-buffered object channel that never loses data. *

Description

* ZeroBuffer is an implementation of ChannelDataStore that yields * the standard CSP semantics for a channel -- that is zero buffered with * direct synchronisation between reader and writer. Unless specified otherwise, * this is the default behaviour for channels. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2one(org.jcsp.util.ChannelDataStore)} etc.). *

* The getState method will return FULL if there is an output * waiting on the channel and EMPTY if there is not. * * @see org.jcsp.util.Buffer * @see org.jcsp.util.OverWriteOldestBuffer * @see org.jcsp.util.OverWritingBuffer * @see org.jcsp.util.OverFlowingBuffer * @see org.jcsp.util.InfiniteBuffer * @see org.jcsp.lang.One2OneChannelImpl * @see org.jcsp.lang.Any2OneChannelImpl * @see org.jcsp.lang.One2AnyChannelImpl * @see org.jcsp.lang.Any2AnyChannelImpl * * @author P.D. Austin */ //}}} public class ZeroBuffer implements ChannelDataStore, Serializable { /** The current state */ private int state = EMPTY; /** The Object */ private Object value; /** * Returns the Object from the ZeroBuffer. *

* Pre-condition: getState must not currently return EMPTY. * * @return the Object from the ZeroBuffer */ public Object get() { state = EMPTY; Object o = value; value = null; return o; } /** * Begins an extended rendezvous - simply returns the next object in the buffer. * This function does not remove the object. * * Pre-condition: getState must not currently return EMPTY. * * @return The object in the buffer. */ public Object startGet() { return value; } /** * Ends the extended rendezvous by clearing the buffer. */ public void endGet() { value = null; state = EMPTY; } /** * Puts a new Object into the ZeroBuffer. *

* Pre-condition: getState must not currently return FULL. * * @param value the Object to put into the ZeroBuffer */ public void put(Object value) { state = FULL; this.value = value; } /** * Returns the current state of the ZeroBuffer. * * @return the current state of the ZeroBuffer (EMPTY * or FULL) */ public int getState() { return state; } /** * Returns a new (and EMPTY) ZeroBuffer with the same * creation parameters as this one. *

* Note: Only the size and structure of the ZeroBuffer is * cloned, not any stored data. * * @return the cloned instance of this ZeroBuffer. */ public Object clone() { return new ZeroBuffer(); } public void removeAll() { state = EMPTY; value = null; } } jcsp-1.1-rc4.orig/src/org/jcsp/util/OverWritingBuffer.java0000644000000000000000000001756111105701167020404 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util; import java.io.Serializable; /** * This is used to create a buffered object channel that always accepts input, * overwriting its last entered data if full. *

Description

* It is an implementation of ChannelDataStore that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * When full, a writer will overwrite the latest item written to the channel. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2one(org.jcsp.util.ChannelDataStore)} etc.). *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. * * @see org.jcsp.util.ZeroBuffer * @see org.jcsp.util.Buffer * @see org.jcsp.util.OverWriteOldestBuffer * @see org.jcsp.util.OverFlowingBuffer * @see org.jcsp.util.InfiniteBuffer * @see org.jcsp.lang.Channel * * @author P.D. Austin */ //}}} public class OverWritingBuffer implements ChannelDataStore, Serializable { /** The storage for the buffered Objects */ private final Object[] buffer; /** The number of Objects stored in the Buffer */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; private boolean valueWrittenWhileFull = false; /** * Construct a new OverWritingBuffer with the specified size. * * @param size the number of Objects the OverWritingBuffer can store. * @throws BufferSizeError if size is zero or negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public OverWritingBuffer(int size) { if (size <= 0) throw new BufferSizeError ("\n*** Attempt to create an overwriting buffered channel with negative or zero capacity"); buffer = new Object[size]; } /** * Returns the oldest Object from the OverWritingBuffer and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the OverWritingBuffer */ public Object get() { Object value = buffer[firstIndex]; buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Puts a new Object into the OverWritingBuffer. *

* If OverWritingBuffer is full, the last item * previously put into the buffer will be overwritten. * * @param value the Object to put into the OverWritingBuffer */ public void put(Object value) { if (counter == buffer.length) { buffer[(lastIndex - 1 + buffer.length) % buffer.length] = value; valueWrittenWhileFull = true; } else { buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; counter++; } } /** * This begins an extended rendezvous by the reader. * The semantics of an extended rendezvous on an overwrite-newest buffer are slightly * complicated, but hopefully intuitive. *

* If the buffer is of size 2 or larger, the semantics are as follows. * Beginning an extended rendezvous will return the oldest value in the buffer, but not remove it. * If the writer writes to the buffer during the rendezvous, it will grow the buffer and end up * overwriting the newest value as normal. At the end of the extended rendezvous, the oldest * value is removed. *

* If the buffer is of size 1, the semantics are identical to those of an {@link OverWriteOldestBuffer}. * For a complete description, refer to the documentation for the {@link OverWriteOldestBuffer#startGet()} method. * * @return The oldest value in the buffer at this time */ public Object startGet() { valueWrittenWhileFull = false; return buffer[firstIndex]; } /** * This ends an extended rendezvous by the reader. * * @see #startGet() */ public void endGet() { if (false == valueWrittenWhileFull || buffer.length != 1) { //Our data hasn't been over-written so remove it: buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; } } /** * Returns the current state of the OverWritingBuffer. * * @return the current state of the OverWritingBuffer (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) OverWritingBuffer with the same * creation parameters as this one. *

* Note: Only the size and structure of the OverWritingBuffer is * cloned, not any stored data. * * @return the cloned instance of this OverWritingBuffer. */ public Object clone() { return new OverWritingBuffer(buffer.length); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; for (int i = 0;i < buffer.length;i++) { //Null the objects so they can be garbage collected: buffer[i] = null; } } } jcsp-1.1-rc4.orig/src/org/jcsp/util/OverFlowingBuffer.java0000644000000000000000000001541511105701167020362 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.util; import java.io.Serializable; /** * This is used to create a buffered object channel that always accepts input, * discarding its last entered data if full. *

Description

* It is an implementation of ChannelDataStore that yields * a FIFO buffered semantics for a channel. When empty, the channel blocks readers. * When full, a writer will be accepted but the written value overflows the buffer * and is lost to the channel. * See the static construction methods of {@link org.jcsp.lang.Channel} * ({@link org.jcsp.lang.Channel#one2one(org.jcsp.util.ChannelDataStore)} etc.). *

* The getState method returns EMPTY or NONEMPTYFULL, but * never FULL. * * @see org.jcsp.util.ZeroBuffer * @see org.jcsp.util.Buffer * @see org.jcsp.util.OverWriteOldestBuffer * @see org.jcsp.util.OverWritingBuffer * @see org.jcsp.util.InfiniteBuffer * @see org.jcsp.lang.Channel * * @author P.D. Austin */ public class OverFlowingBuffer implements ChannelDataStore, Serializable { /** The storage for the buffered Objects */ private final Object[] buffer; /** The number of Objects stored in the Buffer */ private int counter = 0; /** The index of the oldest element (when counter > 0) */ private int firstIndex = 0; /** The index of the next free element (when counter < buffer.length) */ private int lastIndex = 0; /** * Construct a new OverFlowingBuffer with the specified size. * * @param size the number of Objects the OverFlowingBuffer can store. * @throws BufferSizeError if size is zero or negative. Note: no action * should be taken to try/catch this exception * - application code generating it is in error and needs correcting. */ public OverFlowingBuffer(int size) { if (size <= 0) { throw new BufferSizeError( "\n*** Attempt to create an overflowing buffered channel with negative or zero capacity" ); } buffer = new Object[size]; } /** * Returns the oldest Object from the OverFlowingBuffer and removes it. *

* Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the OverFlowingBuffer */ public Object get() { Object value = buffer[firstIndex]; buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; return value; } /** * Returns the oldest object from the buffer but does not remove it. * * Pre-condition: getState must not currently return EMPTY. * * @return the oldest Object from the Buffer */ public Object startGet() { return buffer[firstIndex]; } /** * Removes the oldest object from the buffer. */ public void endGet() { buffer[firstIndex] = null; firstIndex = (firstIndex + 1) % buffer.length; counter--; } /** * Puts a new Object into the OverFlowingBuffer. *

* If OverFlowingBuffer is full, the item is discarded. * * @param value the Object to put into the OverFlowingBuffer */ public void put(Object value) { if (counter < buffer.length) { buffer[lastIndex] = value; lastIndex = (lastIndex + 1) % buffer.length; counter++; } } /** * Returns the current state of the OverFlowingBuffer. * * @return the current state of the OverFlowingBuffer (EMPTY or * NONEMPTYFULL) */ public int getState() { if (counter == 0) return EMPTY; else return NONEMPTYFULL; } /** * Returns a new (and EMPTY) OverFlowingBuffer with the same * creation parameters as this one. *

* Note: Only the size and structure of the OverFlowingBuffer is * cloned, not any stored data. * * @return the cloned instance of this OverFlowingBuffer. */ public Object clone() { return new OverFlowingBuffer(buffer.length); } public void removeAll() { counter = 0; firstIndex = 0; lastIndex = 0; for (int i = 0;i < buffer.length;i++) { //Null the objects so they can be garbage collected: buffer[i] = null; } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/0000755000000000000000000000000011410045045014055 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedChannelArrayFactory.java0000644000000000000000000000757411105701167022304 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.*; /** * Defines an interface for a factory that can create arrays of channels with user-definable * buffering semantics. * * @author Quickstone Technologies Limited * * @deprecated These channel factories are deprecated in favour of the new one2one() methods in the Channel class. */ public interface BufferedChannelArrayFactory { /** * Creates a populated array of n One2One channels with the * specified buffering behaviour. * * @param buffer the buffer implementation to use. * @param n the size of the array. * @return the created array of channels. */ public One2OneChannel[] createOne2One(ChannelDataStore buffer, int n); /** * Creates a populated array of n Any2One channels with the specified * buffering behaviour. * * @param buffer the buffer implementation to use. * @param n the size of the array. * @return the created array of channels. */ public Any2OneChannel[] createAny2One(ChannelDataStore buffer, int n); /** * Creates a populated array of n One2Any channels with the specified * buffering behaviour. * * @param buffer the buffer implementation to use. * @param n the size of the array. * @return the created array of channels. */ public One2AnyChannel[] createOne2Any(ChannelDataStore buffer, int n); /** * Creates a populated array of n Any2Any channels with the specified * buffering behaviour. * * @param buffer the buffer implementation to use. * @param n the size of the array. * @return the created array of channels. */ public Any2AnyChannel[] createAny2Any(ChannelDataStore buffer, int n); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Skip.java0000644000000000000000000000671211113406002015626 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is a process that immediately terminates and * a {@link Guard} that is always ready. *

Description

* Skip is a process that starts, engages in no events, performs no * computation and terminates. *

* It can also be used as a {@link Guard} in * an {@link Alternative} that is always ready. * This makes it useful for polling * a set of guards to test if any are ready: * include it as the last element of the guard array and * {@link Alternative#priSelect() priSelect}. *

* Note: the process is also included for completeness – it is one of * the fundamental primitives of CSP, where it is a unit of sequential * composition and parallel interleaving. * In JCSP, it is a unit of {@link Sequence}, {@link Parallel} and {@link PriParallel} . * * @see org.jcsp.lang.Stop * * @author P.D. Austin * @author P.H. Welch * */ public class Skip extends Guard implements CSProcess { /** * Enables this guard. * * @param alt the Alternative doing the enabling. */ boolean enable(Alternative alt) { Thread.yield(); return true; } /** * Disables this guard. */ boolean disable() { return true; } /** * The main body of this process. */ public void run() { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneIntImpl.java0000644000000000000000000000621511113671251017500 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class Any2OneIntImpl implements ChannelInternalsInt, Any2OneChannelInt { private ChannelInternalsInt channel; private final Object writeMonitor = new Object(); Any2OneIntImpl(ChannelInternalsInt _channel) { channel = _channel; } //Begin never used: public void endRead() { channel.endRead(); } public int read() { return channel.read(); } public boolean readerDisable() { return channel.readerDisable(); } public boolean readerEnable(Alternative alt) { return channel.readerEnable(alt); } public boolean readerPending() { return channel.readerPending(); } public void readerPoison(int strength) { channel.readerPoison(strength); } public int startRead() { return channel.startRead(); } //End never used public void write(int n) { synchronized (writeMonitor) { channel.write(n); } } public void writerPoison(int strength) { synchronized (writeMonitor) { channel.writerPoison(strength); } } public AltingChannelInputInt in() { return new AltingChannelInputIntImpl(channel,0); } public SharedChannelOutputInt out() { return new SharedChannelOutputIntImpl(this,0); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingConnectionClientImpl.java0000644000000000000000000001501311105701167022144 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This class does not need to be used by standard JCSP users. It is exposed so that the connection * mechanism can be extended for custom connections. * * @author Quickstone Technologies Limited */ public class AltingConnectionClientImpl extends AltingConnectionClient { private int currentClientState; private static final int CLIENT_STATE_CLOSED = 1; private static final int CLIENT_STATE_MADE_REQ = 2; private static final int CLIENT_STATE_OPEN = 3; private AltingChannelInput fromServer; private ChannelOutput openToServer; private ChannelOutput reqToServer; private ChannelOutput backToClient; private ConnectionClientMessage msg = new ConnectionClientMessage(); private ConnectionClientOpenMessage msgOpen = new ConnectionClientOpenMessage(); /** * Constructs a new instance. This constructor must be called by a subclass which is responsible * for creating the channels used by the connection and must pass them into this constructor. */ protected AltingConnectionClientImpl(AltingChannelInput fromServer, ChannelOutput openToServer, ChannelOutput reqToServer, ChannelOutput backToClient) { super(fromServer); this.fromServer = fromServer; this.openToServer = openToServer; this.reqToServer = reqToServer; this.backToClient = backToClient; currentClientState = CLIENT_STATE_CLOSED; } /** * Sends some data over the connection to server once the * connection has been opened. * * @param data the Object to send to the server. */ public void request(Object data) throws IllegalStateException { if (currentClientState == CLIENT_STATE_MADE_REQ) throw new IllegalStateException ("Cannot call request(Object) twice without calling reply()."); //this will claim the use of the client if (currentClientState == CLIENT_STATE_CLOSED) { claim(); msgOpen.data = data; msgOpen.replyChannel = backToClient; openToServer.write(msgOpen); } else { msg.data = data; reqToServer.write(msg); } currentClientState = CLIENT_STATE_MADE_REQ; } /** * Receives some data back from the server after * request(Object) has been called. * * @return the Object sent from the server. */ public Object reply() throws IllegalStateException { if (currentClientState != CLIENT_STATE_MADE_REQ) throw new IllegalStateException ("Cannot call reply() on a ConnectionClient that is not waiting for a reply."); ConnectionServerMessage serverReply = (ConnectionServerMessage)fromServer.read(); //check whether the server closed the connection currentClientState = serverReply.open ? CLIENT_STATE_OPEN : CLIENT_STATE_CLOSED; if (serverReply.open) currentClientState = CLIENT_STATE_OPEN; else { currentClientState = CLIENT_STATE_CLOSED; release(); } return serverReply.data; } /** * Returns whether the server has kept its end of the Connection open. * This should only be called after a call to reply() and * before any other Connection method is called. * * @return true iff the server has kept the connection * open. */ public boolean isOpen() throws IllegalStateException { if (currentClientState == CLIENT_STATE_MADE_REQ) throw new IllegalStateException ("Can only call isOpen() just after a reply has been received from the server."); return currentClientState == CLIENT_STATE_OPEN; } /** * This claims a lock on the client. * This implementation does nothing as instances of this * class are only meant to be used with One2?Connection objects. * */ protected void claim() { } /** * This releases a lock on the client. * This implementation does nothing as instances of this * class are only meant to be used with One2?Connection objects. * */ protected void release() { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionServerMessage.java0000644000000000000000000000432311105701167021522 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * @author Quickstone Technologies Limited */ class ConnectionServerMessage implements Serializable { boolean open; Object data; } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableBufferedOne2AnyChannel.java0000644000000000000000000000674411105701167023130 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ChannelDataStore; /** *

This implements a one-to-any object channel with user-definable buffering, * safe for use by a single writer and many readers. Refer to {@link One2AnyChannel} for a * description of this behaviour.

* *

Additionally, this channel supports a reject operation. One of the readers may call * the reject method to force any current writer to abort with a * ChannelDataRejectedException (unless there is already a read which will cause * completion of the write). Subsequent read and write attempts will immediately cause a * ChannelDataRejectedException.

* * @author Quickstone Technologies Limited * * @deprecated This channel is superceded by the poison mechanisms, please see {@link PoisonException} */ public class RejectableBufferedOne2AnyChannel implements RejectableChannel { BufferedOne2AnyChannel innerChannel; /** * Constructs a new RejectableBufferedOne2AnyChannel * * @param data the buffer implementation to use. */ public RejectableBufferedOne2AnyChannel(ChannelDataStore data) { innerChannel = (BufferedOne2AnyChannel)Channel.one2any(data); } public RejectableChannelInput in() { return new RejectableChannelInputImpl(innerChannel,0); } public RejectableChannelOutput out() { return new RejectableChannelOutputImpl(innerChannel,0); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyImpl.java0000644000000000000000000001064611113671251017036 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class Any2AnyImpl implements Any2AnyChannel, ChannelInternals { private ChannelInternals channel; /** The mutex on which readers must synchronize */ private final Mutex readMutex = new Mutex(); private final Object writeMonitor = new Object(); Any2AnyImpl(ChannelInternals _channel) { channel = _channel; } public SharedChannelInput in() { return new SharedChannelInputImpl(this,0); } public SharedChannelOutput out() { return new SharedChannelOutputImpl(this,0); } public void endRead() { channel.endRead(); readMutex.release(); } public Object read() { readMutex.claim(); // A poison exception might be thrown, hence the try/finally: try { return channel.read(); } finally { readMutex.release(); } } //begin never used: public boolean readerDisable() { return false; } public boolean readerEnable(Alternative alt) { return false; } public boolean readerPending() { return false; } //end never used public void readerPoison(int strength) { readMutex.claim(); channel.readerPoison(strength); readMutex.release(); } public Object startRead() { readMutex.claim(); try { return channel.startRead(); } catch (RuntimeException e) { channel.endRead(); readMutex.release(); throw e; } } public void write(Object obj) { synchronized (writeMonitor) { channel.write(obj); } } public void writerPoison(int strength) { synchronized (writeMonitor) { channel.writerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedChannelIntArrayFactory.java0000644000000000000000000000765511105701167022757 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.*; /** * Defines an interface for a factory that can create arrays of integer carrying channels with * user-definable buffering semantics. * * @author Quickstone Technologies Limited * * @deprecated These channel factories are deprecated in favour of the new one2one() methods in the Channel class. */ public interface BufferedChannelIntArrayFactory { /** * Creates a populated array of n One2One channels with the * specified buffering behaviour. * * @param buffer the buffer implementation to use. * @param n the size of the array. * @return the created array of channels. */ public One2OneChannelInt[] createOne2One(ChannelDataStoreInt buffer, int n); /** * Creates a populated array of n Any2One channels with the * specified buffering behaviour. * * @param buffer the buffer implementation to use. * @param n the size of the array. * @return the created array of channels. */ public Any2OneChannelInt[] createAny2One(ChannelDataStoreInt buffer, int n); /** * Creates a populated array of n One2Any channels with the * specified buffering behaviour. * * @param buffer the buffer implementation to use. * @param n the size of the array. * @return the created array of channels. */ public One2AnyChannelInt[] createOne2Any(ChannelDataStoreInt buffer, int n); /** * Creates a populated array of n Any2Any channels with the * specified buffering behaviour. * * @param buffer the buffer implementation to use. * @param n the size of the array. * @return the created array of channels. */ public Any2AnyChannelInt[] createAny2Any(ChannelDataStoreInt buffer, int n); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedChannelOutput.java0000644000000000000000000000473111113671251020651 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is the same as {@link ChannelOutput} except that it is guaranteed * safe to pass on to more than one internal process for parallel writing. *

* A writing-end, obtained from an any-one or any-any * channel by invoking its in() method, will implement this interface. * * @author Quickstone Technologies Limited */ public interface SharedChannelOutput extends ChannelOutput { } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingConnectionClient.java0000644000000000000000000001327711105701167021334 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

* This class is sub-classed by JCSP.NET classes * to provide ConnectionClient objects which can * have their receive() method alted over. *

*

* Although JCSP users could sub-class this class, under most * circumstances, there is no need. AltingConnectionClient * objects can be constructed using one of the Connection factory * mechanisms. See {@link Connection} and * {@link StandardConnectionFactory}. *

* * @author Quickstone Technologies Limited */ public abstract class AltingConnectionClient extends Guard implements ConnectionClient { /** * The channel used to ALT over. */ private AltingChannelInput altingChannel; /** *

* Constructor. *

*

* Note that this is only intended for use by JCSP, and should * not be called by user processes. Users should use one of the * subclasses. *

* @param altingChannel The channel used to implement the Guard */ protected AltingConnectionClient(AltingChannelInput altingChannel) { this.altingChannel = altingChannel; } /** *

* Returns the channel used to implement the Guard. *

*

* Note that this method is only intended for use by * JCSP, and should not be called by user processes. *

*

* Concrete subclasses should override this method to * return null, to ensure that the alting channel is * kept private. *

* @return The channel passed to the constructor. */ protected AltingChannelInput getAltingChannel() { return this.altingChannel; } /** *

* ConnectionServer implementations are likely to be * implemented over channels. Multiple channels from the client * to server may be used; one could be used for the initial * connection while another one could be used for data requests. *

*

* This method allows sub-classes to specify which channel should * be the next one to be alted over. *

* * @param chan the channel to be ALTed over. */ protected void setAltingChannel(AltingChannelInput chan) { this.altingChannel = chan; } /** *

* Returns true if the event is ready. Otherwise, this enables the guard * for selection and returns false. *

*

* Note: this method should only be called by the Alternative class *

* @param alt the Alternative class that is controlling the selection * @return true if and only if the event is ready */ boolean enable(Alternative alt) { return altingChannel.enable(alt); } /** *

* Disables the guard for selection. Returns true if the event was ready. *

*

* Note: this method should only be called by the Alternative class *

* @return true if and only if the event was ready */ boolean disable() { return altingChannel.disable(); } /** *

* Returns whether there is an open() pending on this connection.

*

*

* Note: if there is, it won't go away until you accept it. But if * there isn't, there may be one by the time you check the result of * this method. *

* @return true only if open() will complete without blocking. */ public boolean pending() { return altingChannel.pending(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AlternativeError.java0000644000000000000000000000417511105701167020224 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This is thrown for an illegal operation on an Alternative. * *

Description

* Currently, there is only one cause: we cannot invoke 'priSelect' when there is * an AltingBarrier in the Guard array. * * @author P.H. Welch */ //}}} public class AlternativeError extends Error { public AlternativeError (String s) { super (s); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Stop.java0000644000000000000000000000700311113406002015637 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This is a process that starts, engages in no events, performs no * computation but refuses to terminate. *

Description

* Stop is a process that starts, engages in no events, performs no * computation but refuses to terminate. *

* It can also be used as a {@link Guard} in an {@link Alternative} that is * never ready. * Of course, this is equivalent to it (and its defended process) not being * there at all! *

* Note: this process is included for completeness – it is one of the fundamental * primitives of CSP, where it represents a broken process and is a unit of * external choice. * In JCSP, it is a unit of {@link Alternative}. * * @see org.jcsp.lang.Skip * * @author P.D. Austin and P.H. Welch * */ //}}} public class Stop extends Guard implements CSProcess { /** * Enables this guard. * * @param alt the Alternative doing the enabling. */ boolean enable (Alternative alt) { Thread.yield (); return false; } /** * Disables this guard. */ boolean disable () { return false; } /** * This process starts, engages in no events, performs no computation * and refuses to terminate. *

*/ public void run () { Object lock = new Object (); synchronized (lock) { try { lock.wait (); while (true) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.StopRun); } lock.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from Stop.run ()\n" + e.toString ()); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/StandardChannelIntFactory.java0000644000000000000000000003214111105701167021762 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.ChannelDataStoreInt; /** *

This class acts as a Factory for creating * channels. It can create non-buffered and buffered channels * and also arrays of non-buffered and buffered channels.

* *

The Channel objects created by this Factory are formed of * separate objects for the read and write ends. Therefore the * ChannelInput object cannot be cast into the * ChannelOutput object and vice-versa.

* *

The current implementation uses an instance of the * RiskyChannelIntFactory to construct the underlying * raw channels.

* * @author Quickstone Technologies Limited */ public class StandardChannelIntFactory implements ChannelIntFactory, ChannelIntArrayFactory, BufferedChannelIntFactory, BufferedChannelIntArrayFactory { /** * Constructs a new factory. */ public StandardChannelIntFactory() { super(); } /** * Constructs and returns a One2OneChannelInt object. * * @return the channel object. * * @see org.jcsp.lang.ChannelIntFactory#createOne2One() */ public One2OneChannelInt createOne2One() { return new One2OneChannelIntImpl(); } /** * Constructs and returns an Any2OneChannelInt object. * * @return the channel object. * * @see org.jcsp.lang.ChannelIntFactory#createAny2One() */ public Any2OneChannelInt createAny2One() { return new Any2OneChannelIntImpl(); } /** * Constructs and returns a One2AnyChannelInt object. * * @return the channel object. * * @see org.jcsp.lang.ChannelIntFactory#createOne2Any() */ public One2AnyChannelInt createOne2Any() { return new One2AnyChannelIntImpl(); } /** * Constructs and returns an Any2AnyChannelInt object. * * @return the channel object. * * @see org.jcsp.lang.ChannelIntFactory#createAny2Any() */ public Any2AnyChannelInt createAny2Any() { return new Any2AnyChannelIntImpl(); } /** * Constructs and returns an array of One2OneChannelInt * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelIntArrayFactory#createOne2One(int) */ public One2OneChannelInt[] createOne2One(int n) { One2OneChannelInt[] toReturn = new One2OneChannelInt[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2One(); return toReturn; } /** * Constructs and returns an array of Any2OneChannelInt * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelIntArrayFactory#createAny2One(int) */ public Any2OneChannelInt[] createAny2One(int n) { Any2OneChannelInt[] toReturn = new Any2OneChannelInt[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2One(); return toReturn; } /** * Constructs and returns an array of One2AnyChannelInt * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelIntArrayFactory#createOne2Any(int) */ public One2AnyChannelInt[] createOne2Any(int n) { One2AnyChannelInt[] toReturn = new One2AnyChannelInt[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2Any(); return toReturn; } /** * Constructs and returns an array of Any2AnyChannelInt * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelIntArrayFactory#createAny2Any(int) */ public Any2AnyChannelInt[] createAny2Any(int n) { Any2AnyChannelInt[] toReturn = new Any2AnyChannelInt[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2Any(); return toReturn; } /** *

Constructs and returns a One2OneChannelInt object which * uses the specified ChannelDataStoreInt object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStoreInt to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelIntFactory#createOne2One(org.jcsp.util.ints.ChannelDataStoreInt) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public One2OneChannelInt createOne2One(ChannelDataStoreInt buffer) { return new BufferedOne2OneChannelIntImpl(buffer); } /** *

Constructs and returns a Any2OneChannelInt object which * uses the specified ChannelDataStoreInt object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStoreInt to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelIntFactory#createAny2One(org.jcsp.util.ints.ChannelDataStoreInt) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public Any2OneChannelInt createAny2One(ChannelDataStoreInt buffer) { return new BufferedAny2OneChannelIntImpl(buffer); } /** *

Constructs and returns a One2AnyChannelInt object which * uses the specified ChannelDataStoreInt object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStoreInt to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelIntFactory#createOne2Any(org.jcsp.util.ints.ChannelDataStoreInt) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public One2AnyChannelInt createOne2Any(ChannelDataStoreInt buffer) { return new BufferedOne2AnyChannelIntImpl(buffer); } /** *

Constructs and returns a Any2AnyChannelInt object which * uses the specified ChannelDataStoreInt object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStoreInt to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelIntFactory#createAny2Any(org.jcsp.util.ints.ChannelDataStoreInt) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public Any2AnyChannelInt createAny2Any(ChannelDataStoreInt buffer) { return new BufferedAny2AnyChannelIntImpl(buffer); } /** *

Constructs and returns an array of One2OneChannelInt objects * which use the specified ChannelDataStoreInt object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStoreInt to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelIntArrayFactory#createOne2One(org.jcsp.util.ints.ChannelDataStoreInt,int) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public One2OneChannelInt[] createOne2One(ChannelDataStoreInt buffer, int n) { One2OneChannelInt[] toReturn = new One2OneChannelInt[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2One(buffer); return toReturn; } /** *

Constructs and returns an array of Any2OneChannelInt objects * which use the specified ChannelDataStoreInt object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStoreInt to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelIntArrayFactory#createAny2One(org.jcsp.util.ints.ChannelDataStoreInt,int) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public Any2OneChannelInt[] createAny2One(ChannelDataStoreInt buffer, int n) { Any2OneChannelInt[] toReturn = new Any2OneChannelInt[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2One(buffer); return toReturn; } /** *

Constructs and returns an array of One2AnyChannelInt objects * which use the specified ChannelDataStoreInt object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStoreInt to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelIntArrayFactory#createOne2Any(org.jcsp.util.ints.ChannelDataStoreInt,int) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public One2AnyChannelInt[] createOne2Any(ChannelDataStoreInt buffer, int n) { One2AnyChannelInt[] toReturn = new One2AnyChannelInt[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2Any(buffer); return toReturn; } /** *

Constructs and returns an array of Any2AnyChannelInt objects * which use the specified ChannelDataStoreInt object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStoreInt to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelIntArrayFactory#createAny2Any(org.jcsp.util.ints.ChannelDataStoreInt,int) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public Any2AnyChannelInt[] createAny2Any(ChannelDataStoreInt buffer, int n) { Any2AnyChannelInt[] toReturn = new Any2AnyChannelInt[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2Any(buffer); return toReturn; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableAny2AnyChannelImpl.java0000644000000000000000000000417611113671251022344 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class PoisonableAny2AnyChannelImpl extends Any2AnyImpl { PoisonableAny2AnyChannelImpl(int _immunity) { super(new PoisonableOne2OneChannelImpl(_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionWithSharedAltingServer.java0000644000000000000000000000426611105701167023345 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * @author Quickstone Technologies Limited */ interface ConnectionWithSharedAltingServer { public SharedConnectionServer server(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableOne2AnyChannel.java0000644000000000000000000000653311105701167021461 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

This implements a one-to-any object channel, * safe for use by a single writer and many readers. Refer to {@link One2AnyChannel} for a * description of this behaviour.

* *

Additionally, this channel supports a reject operation. One of the readers may call * the reject method to force any current writer to abort with a * ChannelDataRejectedException (unless there is already a read which will cause * completion of the write). Subsequent read and write attempts will immediately cause a * ChannelDataRejectedException.

* * @author Quickstone Technologies Limited * * @deprecated This channel is superceded by the poison mechanisms, please see {@link PoisonException}. It remains only because it is used by some of the networking features. */ public class RejectableOne2AnyChannel implements RejectableChannel { One2AnyChannelImpl innerChannel; /** * Constructs a new channel. */ public RejectableOne2AnyChannel() { innerChannel = (One2AnyChannelImpl)Channel.one2any(); } public RejectableChannelInput in() { return new RejectableChannelInputImpl(innerChannel,0); } public RejectableChannelOutput out() { return new RejectableChannelOutputImpl(innerChannel,0); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneChannelImpl.java0000644000000000000000000000476611105701167020330 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements an any-to-one object channel, * safe for use by many writers and one reader. Refer to the {@link Any2OneChannel} interface for * more details. * * @see org.jcsp.lang.One2OneChannelImpl * @see org.jcsp.lang.One2AnyChannelImpl * @see org.jcsp.lang.Any2AnyChannelImpl * * @author P.D. Austin and P.H. Welch */ class Any2OneChannelImpl extends Any2OneImpl { Any2OneChannelImpl() { super(new One2OneChannelImpl()); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionClient.java0000644000000000000000000001354511105701167020173 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

This is an interface to be implemented by classes that wish * to act as a client to connect to a ConnectionServer.

* *

Users of classes implementing this interface should call * request(Object) to initiate a conversation and to send some * data to the server. Implementations may decide to return immediately or * to wait until the server accepts the connection and then return. The * Connection is not guaranteed to be open until a call to reply() * has returned. The reply() method should be called soon * after the call to reqeust(Object). Some computation may be * done between the calls but any external process synchronization is * potentially hazardous.

* *

After calling reply(), clients can check whether * the server closed the connection by calling isOpen(). * If it returns true, then the connection has been kept * open. If the connection has been kept open then the client may assume * that a call to request(Object) will not block and that * the connection will soon be dealt with by the server.

* *

This is an example of typical code structure for using a * ConnectionClient:

* *
 * //have a variable client of type ConnectionClient
 * do {
 *     client.request(some_data);
 *     some_variable = client.receive();
 * } while (client.isOpen())
 * 
* * @author Quickstone Technologies Limited */ public interface ConnectionClient { /** *

This method is used to send data to a ConnectionServer in * a client/server conversation. If a connection has not yet been established, * then this method will open the connection as necessary.

* *

Once this method has returned, the client may do some computation but * must then guarantee to call reply(). This will obtain a * server's response to the request. In between calling this method and * reply(), doing pure computation is safe. Performing * synchronization with other process is potentially hazardous.

* *

Once a server replies, if the connection has been kept open, then * this method should be called again to make a further request.

* *

Programs using Connections need to adopt a protocol so that the server * knows when a conversation with a client has finished and will then drop * the connection.

* * @param data the Object to send to the server. * @throws IllegalStateException if the method is called when it is * not meant to be. */ public void request(Object data) throws IllegalStateException; /** *

Receives some data back from the server after * request(Object) has been called.

* *

After calling this method, isOpen() may be called * to establish whether the server dropped the connection after replying.

* *

Implementations may make this operation ALTable.

* * @return the Object sent from the server. * @throws IllegalStateException if the method is called when it is * not meant to be. */ public Object reply() throws IllegalStateException; /** *

Returns whether the server has kept its end of the Connection open. * This should only be called after a call to reply() and * before any other Connection method is called.

* * @return true iff the server has kept the connection * open. */ public boolean isOpen() throws IllegalStateException; } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyCallChannel.java0000644000000000000000000002441011105701167020266 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * This is the super-class for one-to-any interface-specific CALL channels, * safe for use by one client and many servers. *

* Shortcut to the Constructor and Method Summaries. * *

Description

* Please see {@link One2OneCallChannel} for general information about CALL channels. * Documented here is information specific to this 1-any version. * *

Converting a Method Interface into a Variant CALL Channel

* Constructing a 1-any CALL channel for a specific interface * follows exactly the same pattern as in the 1-1 case. Of course, it must * extend One2AnyCallChannel rather than One2OneCallChannel. *

* For example, using the same Foo * interface as before, we derive: *

 * import org.jcsp.lang.*;
 * 
 * public class One2AnyFooChannel extends One2AnyCallChannel implements Foo {
 * 
 *   ...  same body as One2OneFooChannel
 * 
 * }
 * 
* *

Calling a CALL Channel

* All the client needs to see is the method interface * implemented by the CALL channel. So far as the client is concerned, therefore, * there is no difference between any of the varieties of CALL channel * - it just makes the call. * *

Accepting a CALL Channel

* The mechanics of accepting a CALL channel are the same for all varieties. * However, the server should declare which kind (or kinds) it allows * to be attached: *
 * import org.jcsp.lang.*;
 * 
 * class B implements CSProcess, Foo {
 * 
 *   private final ChannelAccept in;
 * 
 *   public B (final One2OneFooChannel in) {         // original constructor
 *     this.in = in;
 *   }
 * 
 *   public B (final One2AnyFooChannel in) {        // additional constructor
 *     this.in = in;
 *   }
 * 
 *   ...  rest as before
 * 
 * }
 * 
* When wrapping the above to hide its raw method interface, don't forget to include * the extra constructor(s): *
 * import org.jcsp.lang.*;
 * 
 * public class B2 implements CSProcess {            // no Foo interface
 * 
 *   private final B b;
 * 
 *   public B2 (final One2OneFooChannel in) {        // original constructor
 *     b = new B (in);
 *   }
 * 
 *   public B2 (final One2AnyFooChannel in) {       // additional constructor
 *     b = new B (in);
 *   }
 * 
 *   public void run () {
 *     b.run ();
 *   }
 * 
 * }
 * 
* *

ALTing on a CALL Channel

* As for ordinary channels, ALTing over 1-Any or Any-Any versions * is not supported. Hence, a server can only choose to {@link #accept accept} * or not to accept a One2AnyFooChannel - it cannot back off because * of some other event. * *

Building a CALL Channel Network

* Network building with CALL channels is the same as building with ordinary * channels. First construct the channels and, then, construct the processes * - plugging in the channels as required and running them in {@link Parallel}. *

* For example, the network consisting of one client and several servers: *

* where A is unchanged from its definition * in
One2OneCallChannel, * is implemented by: *
 *     One2AnyFooChannel c = new One2AnyFooChannel ();
 * 
 *     final B2[] bServers = new B2[n_bClients];
 *     for (int i = 0; i < bServers.length; i++) {
 *       bServers[i] = new B2 (c);
 *     }
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new A (c),
 *         new Parallel (bServers)
 *       }
 *     ).run ();
 * 
* [Reminder: XXX-any channels are not broadcasters of information. * In the above, when A makes a CALL on c, it must not care * which of the B2 servers picks it up. The servers compete * with each other to service the client.] * *

Example

* Please see Any2AnyCallChannel * for an example that includes many clients and many servers competing for * each other's attention. * * @see org.jcsp.lang.One2OneCallChannel * @see org.jcsp.lang.Any2OneCallChannel * @see org.jcsp.lang.Any2AnyCallChannel * @see org.jcsp.lang.Alternative * * @author P.H. Welch */ public abstract class One2AnyCallChannel implements ChannelAccept, Serializable { /** * This is used to synchronise the calling and accepting process. */ final private One2OneChannelImpl c = new One2OneChannelImpl(); /** * This holds a reference to a server process so that a client may * make the call. The reference is only valid between the {@link #join join} * and {@link #fork fork} elements of the standard * calling sequence. * As shown in that sequence, it will need casting up to the relevant interface * supported by the specific CALL channel derived from this class. */ protected CSProcess server; /** * This may be set during the standard calling sequence to record * which method was invoked by a client. It is only safe to do this between * the {@link #join join} and {@link #fork fork} elements of * that sequence. Either all the CALL * channel methods should do this or none - in the latter case, its default * value remains as zero. Its value is returned to a server as the result * the server's invocation of {@link #accept accept}. */ protected int selected = 0; /** * This is invoked by a server when it commits to accepting a CALL * from a client. The parameter supplied must be a reference to this server * - see the example from {@link One2OneCallChannel}. * It will not complete until a CALL has been made. If the derived CALL channel has set * the {@link #selected} field in the way defined by the standard * calling sequence, * the value returned by this method will indicate which method was called. * * @param server the server process receiving the CALL. */ public synchronized int accept(CSProcess server) { this.server = server; c.read(); // ready to ACCEPT the CALL c.read(); // wait until the CALL is complete return selected; } /** * This is invoked by a client during the standard calling * sequence. It will not complete until a server invokes * an {@link #accept accept} on this channel. In turn, that accept * will not complete until the client invokes a {@link #fork fork}, * after having made its CALL on the server. */ protected void join() { c.write(null); } /** * This is invoked by a client during the standard calling * sequence. A server must have invoked an {@link #accept accept} * for the client to have got this far in the sequence - see * the {@link #join join}. This call unblocks that accept, * releasing the server and client to resume separate lives. */ protected void fork() { c.write(null); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelInput.java0000644000000000000000000001005311113671251020452 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This extends {@link Guard} and {@link ChannelInput} * to enable a process to choose between many object input (and other) events. *

* A reading-end, obtained from a one-one or any-one * channel by invoking its in() method, will extend this abstract class. *

Description

* AltingChannelInput extends {@link Guard} and {@link ChannelInput} * to enable a process * to choose between many object input (and other) events. The methods inherited from * Guard are of no concern to users of this package. *

*

Example

*
 * import org.jcsp.lang.*;
 * 
 * public class AltingExample implements CSProcess {
 * 
 *   private final AltingChannelInput in0, in1;
 *   
 *   public AltingExample (final AltingChannelInput in0,
 *                         final AltingChannelInput in1) {
 *     this.in0 = in0;
 *     this.in1 = in1;
 *   }
 * 
 *   public void run () {
 * 
 *     final Guard[] altChans = {in0, in1};
 *     final Alternative alt = new Alternative (altChans);
 * 
 *     while (true) {
 *       switch (alt.select ()) {
 *         case 0:
 *           System.out.println ("in0 read " + in0.read ());
 *         break;
 *         case 1:
 *           System.out.println ("in1 read " + in1.read ());
 *         break;
 *       }
 *     }
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.lang.Guard * @see org.jcsp.lang.Alternative * @author P.D. Austin and P.H. Welch */ public abstract class AltingChannelInput extends Guard implements ChannelInput { // nothing alse to add ... except ... /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. * * @return state of the channel. */ public abstract boolean pending(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingBarrier.java0000644000000000000000000015133111105701167017456 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This is the front-end for a barrier that can be used as * a {@link Guard} in an {@link Alternative}. *

*

Description

* An alting barrier is represented by a family of AltingBarrier * front-ends. Each process using the barrier must do so via its * own front-end. A new alting barrier is created by the static * {@link #create create} method, which returns an array of front-ends. * If new processes need to be enrolled, further front-ends may be made * from an existing one (see {@link #expand(int) expand} and * {@link #contract(AltingBarrier[]) contract}). * A process may temporarilly {@link #resign resign} from a barrier and, later, * re-{@link #enroll enroll}. *

* To use this barrier, a process simply includes its given AltingBarrier * front-end in a {@link Guard} array associated with an {@link Alternative}. * Its index will be selected if and only if all parties (processes) to the barrier * similarly select it (using their own front-ends). *

*

* If a process wishes to commit to this barrier (i.e. not offer it as a choice * in an {@link Alternative}), it may {@link #sync sync} on it. * However, if all parties only do this, a non-alting {@link Barrier} * would be more efficient. * A further shortcut (over using an {@link Alternative}) is provided * to {@link #poll(long) poll} this barrier for completion. *

*

* An AltingBarrier front-end may only be used by one process * at a time (and this is checked at run-time). * A process may communicate a non-resigned front-end to another process; * but the receiving process must {@link #mark mark} it before using it and, * of course, the sending process must not continue to use it. * If a process terminates holding a front-end, it may be recycled * for use by another process via {@link #reset reset}. *

*

Priorities

* These do not -- and cannot -- apply to selection between barriers. * The {@link Alternative#priSelect priSelect()} method works locally for * the process making the offer. * If this were allowed, one process might offer barrier x with higher * priority than barrier y ... and another process might offer them * with its priorities the other way around. * In which case, it would be impossible to resolve a choice in favour of * x or y in any way that satisfied the conflicting * priorities of both processes. *

*

* However, the {@link Alternative#priSelect priSelect()} method is * allowed for choices including barrier guards. It honours the respective * priorities defined between non-barrier guards ... and those * between a barrier guard and non-barrier guards (which * guarantees, for example, immediate response to a timeout from ever-active * barriers). Relative priorities between barrier guards are inoperative. *

*

Misuse

* The implementation defends against misuse, throwing an {@link AltingBarrierError} * error when riled. See the documentation for {@link AltingBarrierError} for * circumstances. *

*

Example 0 (a single alting barrier)

* Here is a simple gadget with two modes of operation, switched by a click * event (operated externally by a button in the application below). * Initially, it is in individual mode -- represented here by incrementing * a number and outputting it (as a String to change the label on * its controlling button) as often as it can. * Its other mode is group, in which it can only work if all associated * gadgets are also in this mode. Group work consists of a single decrement * and output of the number (to its button's label). * It performs group work as often as the group will allow (i.e. until it, or * one of its partner gadgets, is clicked back to individual mode). *
 * import org.jcsp.lang.*;
 * 
 * public class AltingBarrierGadget0 implements CSProcess {
 * 
 *   private final AltingChannelInput click;
 *   private final AltingBarrier group;
 *   private final ChannelOutput configure;
 * 
 *   public AltingBarrierGadget0 (
 *     AltingChannelInput click, AltingBarrier group, ChannelOutput configure
 *   ) {
 *     this.click = click;
 *     this.group = group;
 *     this.configure = configure;
 *   }
 * 
 *   public void run () {
 * 
 *     final Alternative clickGroup =
 *       new Alternative (new Guard[] {click, group});
 * 
 *     final int CLICK = 0, GROUP = 1;
 * 
 *     int n = 0;
 *     configure.write (String.valueOf (n));
 * 
 *     while (true) {
 * 
 *       configure.write (Color.green)                // pretty
 * 
 *       while (!click.pending ()) {                  // individual work mode
 *         n++;                                       // work on our own
 *         configure.write (String.valueOf (n));      // work on our own
 *       }
 *       click.read ();                               // must consume the click
 * 
 *       configure.write (Color.red);                 // pretty
 *       
 *       boolean group = true;                        // group work mode
 *       while (group) {
 *         switch (clickGroup.priSelect ()) {         // offer to work with the group
 *           case CLICK:
 *             click.read ();                         // must consume the click
 *             group = false;                         // back to individual work mode
 *           break;
 *           case GROUP:
 *             n--;                                   // work with the group
 *             configure.write (String.valueOf (n));  // work with the group
 *           break;
 *         }
 *       }
 *       
 *     }
 * 
 *   }
 * 
 * }
 * 
* Here is code for a system of buttons and gadgets, synchronised by * an alting barrier. Note that this single event needs * an array of AltingBarrier front-ends to operate -- * one for each gadget: *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class AltingBarrierGadget0Demo0 {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final int nUnits = 8;
 *
 *     // make the buttons
 * 
 *     final One2OneChannel[] event = Channel.one2oneArray (nUnits);
 *     
 *     final One2OneChannel[] configure = Channel.one2oneArray (nUnits);
 * 
 *     final boolean horizontal = true;
 * 
 *     final FramedButtonArray buttons =
 *       new FramedButtonArray (
 *         "AltingBarrier: Gadget 0, Demo 0", nUnits, 120, nUnits*100,
 *          horizontal, configure, event
 *       );
 * 
 *     // construct an array of front-ends to a single alting barrier
 * 
 *     final AltingBarrier[] group = AltingBarrier.create (nUnits);
 * 
 *     // make the gadgets
 * 
 *     final AltingBarrierGadget0[] gadgets = new AltingBarrierGadget0[nUnits]; 
 *     for (int i = 0; i < gadgets.length; i++) {
 *       gadgets[i] = new AltingBarrierGadget0 (event[i], group[i], configure[i]);
 *     }
 * 
 *     // run everything
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         buttons, new Parallel (gadgets)
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* The very simple "group" work in the above example consists of actions * performed independently by each gadget (decrementing the number on its * button's label). The (alting) barrier synchronisation ensures that * these decrements keep in step with each other. *

* A more interesting gadget would work with other gadgets for group work * that really did require them all to be engaged. * For example, they resume operation of a machine that would be dangerous if * some gadgets (perhaps those responsible for safety aspects) were doing * their individual work. *

*

Example 1 (lots of alting barriers)

* This example derives from a pathological challenge to the management of choice * between multiway synchronisations raised by Michael Goldsmith (Formal * Systems Europe). * There are three processes (P, Q and R) * and theee events (a, b and c). * P offers events a and b; * Q offers events b and c; * and R offers events c and a. * If P and Q synchronise on b, * they do something (possibly together) then start again. * Similarly if Q and R synchronise on c * or if R and P synchronise on a. * In CSP, the expression is trivial: *
 *  P = ((a -> P0); P) [] ((b -> P1); P), and where c is not in the alphabet of P
 *  Q = ((b -> Q0); Q) [] ((c -> Q1); Q), and where a is not in the alphabet of Q
 *  R = ((c -> R0); R) [] ((a -> R1); R), and where b is not in the alphabet of R
 *
 *  SYSTEM = (P || Q || R) \ {a, b, c}
 * 
* To impact their environment (and avoid divergence), the sub-processes * P0, P1, Q0, Q1, * R0 and R1 will engage in external events * (i.e. not just a, b or c). * Additionally, P1 and Q0 * (triggered by b) may engage in other hidden events, * not given in the above. * The same for Q1 and R0 * (triggered by c) and for R1 and P0 * (triggered by a). *

*

* In our version, there are N processes and events arranged (logically) * around a circle. * Each process is either off or on standby, switching between * these states on random timeouts. * Each process is also attached to a personal button that it uses * to indicate its state. * When off, it colours its button black; when on standby, * light gray. *

*

* When on standby, each process offers (span+1) events: * a timeout, the event with it on the circle and the next (span-1) * events going (say) clockwise. * It the timeout occurs, it switches to its off state. * If one of the events (AltingBarrier) occurs, it must have * occured for a consecutive block of span processes (including * this one ... somewhere) around the circle. * This group now go into a playing state. *

*

* Not mentioned before is a rail track, made of channels, running round * the circle. * When playing, the process furthest uptrack choses a colour and sends this to * its partners down the track (to which the mulitway synchronisation ensures * this group has exclusive access). * Each process in the playing group then flashes its button with that colour * a fixed (parametrised) number of times. * The rate of flashing is coordinated by the AltingBarrier * multiway synchronisation event common to the group -- * the furthest uptrack process only keeping time for this. * After playing, the process switches to its off state. *

*

* [Note: the above SYSTEM has N equal to * 3, span equal to 2, no off * state and no timeout on standby. * The channels used to flash the buttons are the external events mentioned * and the rail track channels are the hidden extras.] *

*

* Here is the code for these processes. * As usual, the constructor just saves all parameters: *

 * import org.jcsp.lang.*;
 * import org.jcsp.awt.*;
 * 
 * import java.awt.Color;
 * import java.util.Random;
 * 
 * public class AltingBarrierGadget1 implements CSProcess {
 * 
 *   private final AltingBarrier[] barrier;
 *   private final AltingChannelInput in, click;
 *   private final ChannelOutput out, configure;
 *   private final Color offColour, standbyColour;
 *   private final int offInterval, standbyInterval;
 *   private final int playInterval, flashInterval;
 * 
 *   public AltingBarrierGadget1 (
 *     AltingBarrier[] barrier,
 *     AltingChannelInput in, ChannelOutput out,
 *     AltingChannelInput click, ChannelOutput configure,
 *     Color offColour, Color standbyColour,
 *     int offInterval, int standbyInterval,
 *     int playInterval, int flashInterval
 *   ) {
 *     this.barrier = barrier;
 *     this.in = in;  this.out = out;
 *     this.click = click;  this.configure = configure;
 *     this.offColour = offColour;  this.standbyColour = standbyColour;
 *     this.offInterval = offInterval;  this.standbyInterval = standbyInterval;
 *     this.playInterval = playInterval;  this.flashInterval = flashInterval;
 *   }
 * 
* The barrier array gives this gadget access to * the multiway events shared with adjacent siblings. * The in and out channel ends are part of the * rail track this gadget uses later (when playing). * The click and configure channels * attach this gadget to its button. * The click channel is never used by this gadget -- it's included * for completeness should anyone wish to enhance its behaviour. * The other parameters are just data. *

*

* The run() method controls switching between off, * standby and playing states. * The latter is the choice between all the multiway syncs (and the timeout). * It is handled by a fair select on the {@link Alternative}, * constructed just once (before loop entry): *

 *   public void run () {
 *  
 *     CSTimer tim = new CSTimer ();
 * 
 *     final Random random = new Random ();
 * 
 *     final Guard[] standbyGuard = new Guard[barrier.length + 1];
 *     for (int i = 0; i < barrier.length; i++) {
 *       standbyGuard[i] = barrier[i];
 *     }
 *     standbyGuard[barrier.length] = tim;
 *     final int TIMEOUT = barrier.length;
 *     Alternative standbyAlt = new Alternative (standbyGuard);
 * 
 *     configure.write (Boolean.FALSE);               // disable mouse clicks
 *                                                    // (not used by this gadget)
 *     while (true) {
 * 
 *       configure.write (offColour);
 *       tim.sleep (random.nextInt (offInterval));
 * 
 *       configure.write (standbyColour);
 *       tim.setAlarm (tim.read () + random.nextInt (standbyInterval));
 * 
 *       int choice = standbyAlt.fairSelect ();       // magic synchronisation
 * 
 *       if (choice != TIMEOUT) {
 *         play (choice, random, tim);
 *       }
 *       
 *     }
 *  
 *   }
 * 
* Here is the playing code. * Initially, a colour is chosen and passed down the playing group's section * of rail track, to which it has exclusive access. * The flashing group is coordinated through the group's common event, * with just one of them keeping time. *
 *   private void play (int choice, Random random, CSTimer tim) {
 *     
 *     final boolean RIGHTMOST = (choice == 0);
 *     final boolean LEFTMOST = (choice == (barrier.length - 1));
 * 
 *     Color colour = null;
 *     if (RIGHTMOST) {
 *       colour = new Color (random.nextInt ());
 *     } else {
 *       colour = (Color) in.read ();
 *     }
 *     Color bright = colour.brighter ();
 * 
 *     if (!LEFTMOST) out.write (colour);             // pass it on
 * 
 *     final AltingBarrier focus = barrier[choice];
 * 
 *     final int count = playInterval/flashInterval;
 * 
 *     long timeout = tim.read () + flashInterval;
 *     
 *     boolean bright = true;
 * 
 *     for (int i = 0; i < count; i++) {
 *       configure.write (bright ? brighter : colour);
 *       bright = !bright;
 *       if (RIGHTMOST) {
 *         tim.after (timeout);
 *         timeout += flashInterval;
 *       }
 *       focus.sync ();
 *     }
 * 
 *   }
 * 
 * }
 * 
* Here is code setting up a "circle" of these gadgets, buttons and * alting barriers. * The buttons are laid out in a row, so that the rightmost button is actually * on the "left" of the leftmost button. * Care needs to be taken to distribute the span front-ends * for each AltingBarrier to the correct gadgets -- * see the re-arrangement below: *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.plugNplay.*;
 * 
 * import java.awt.Color;
 * import java.util.Random;
 * 
 * public class AltingBarrierGadget1Demo0 {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final int nUnits = 30, span = 6;
 *     
 *     final int offInterval = 800, standbyInterval = 1000;    // milliseconds
 *     
 *     final int playInterval = 10000, flashInterval = 500;    // milliseconds
 * 
 *     final Color offColour = Color.black, standbyColour = Color.lightGray;
 * 
 *     // make the buttons
 * 
 *     final One2OneChannel[] click =
 *       Channel.one2oneArray (nUnits, new OverWriteOldestBuffer (1));
 * 
 *     final One2OneChannel[] configure = Channel.one2oneArray (nUnits);
 * 
 *     final boolean horizontal = true;
 * 
 *     final FramedButtonArray buttons =
 *       new FramedButtonArray (
 *         "AltingBarrier: Gadget 1, Demo 0", nUnits, 100, nUnits*50,
 *          horizontal, configure, click
 *       );
 * 
 *     // construct nUnits barriers, each with span front-ends ...
 * 
 *     AltingBarrier[][] ab = new AltingBarrier[nUnits][];
 *     for (int i = 0; i < nUnits; i++) {
 *       ab[i] = AltingBarrier.create (span);
 *     }
 * 
 *     // re-arrange front-ends, ready for distribution to processes ...
 * 
 *     AltingBarrier[][]barrier = new AltingBarrier[nUnits][span];
 *     for (int i = 0; i < nUnits; i++) {
 *       for (int j = 0; j < span; j++) {
 *         barrier[i][j] = ab[(i + j) % nUnits][j];
 *       }
 *     }
 * 
 *     // make the track and the gadgets
 * 
 *     One2OneChannel[] track = Channel.one2oneArray (nUnits);
 * 
 *     AltingBarrierGadget1[] gadgets = new AltingBarrierGadget1[nUnits];
 *     for (int i = 0; i < nUnits; i++) {
 *       gadgets[i] =
 *         new AltingBarrierGadget1 (
 *           barrier[i],
 *           track[(i + 1)%nUnits], track[i],
 *           click[i], configure[i],
 *           offColour, standbyColour,
 *           offInterval, standbyInterval,
 *           playInterval, flashInterval
 *         );
 *     }
 * 
 *     // run everything
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         buttons, new Parallel (gadgets)
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* For fun, here is another application program for the same gadget. * It allows a much larger system to be built, laying out the circle * of buttons in a grid, row by row. * The rightmost button on each row is to the left of the leftmost * button on the next row down. * The next row down from the bottom row is the top row. * The buttons and its click and configure channels * are now two dimensional structures. * The barriers, gadgets and rail track are still one dimensional. * Only code differences from the above are shown: *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.plugNplay.*;
 * 
 * import java.awt.Color;
 * import java.util.Random;
 * 
 * public class AltingBarrierGadget1Demo1 {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final int width = 30, depth = 20;
 *     final int nUnits = width*depth;
 *     
 *     ...  the other system parameters (final ints and Colors)
 *     
 *     final One2OneChannel[][] click = new One2OneChannel[depth][];
 *     for (int i = 0; i < depth; i++) {
 *       click[i] = Channel.one2oneArray (width, new OverWriteOldestBuffer (1));
 *     }
 *     
 *     final One2OneChannel[][] configure = new One2OneChannel[depth][];
 *     for (int i = 0; i < depth; i++) {
 *       configure[i] = Channel.one2oneArray (width);
 *     }
 * 
 *     final FramedButtonGrid buttons =
 *       new FramedButtonGrid (
 *         "AltingBarrier: Gadget 1, Demo 1", depth, width,
 *         20 + (depth*50), width*50, configure, click
 *       );
 * 
 *     ...  construct nUnits barriers and the track exactly as before
 * 
 *     AltingBarrierGadget1[] gadgets = new AltingBarrierGadget1[nUnits];
 *     for (int i = 0; i < nUnits; i++) {
 *       gadgets[i] =
 *         new AltingBarrierGadget1 (
 *           barrier[i],
 *           track[(i + 1)%nUnits], track[i],
 *           click[i/width][i%width],
 *           configure[i/width][i%width],
 *           offColour, standbyColour,
 *           offInterval, standbyInterval,
 *           playInterval, flashInterval
 *         );
 *     }
 * 
 *     ...  build and run the buttons and gadgets in parallel
 * 
 *   }
 * 
 * }
 * 
* *

Other Examples

* The alting-barriers directory in jcsp-demos * contains other gadgets in a similar vein. * *

AltingBarrierGadget2

* These are similar to AltingBarrierGadget1, but sit on * a 2-way circular railtrack offering to synchronise in the same * span-groups. * Their difference is the game they play when synchronised: * pass-the-parcel up and down their section of track, with * the parcel's (rapid) progress indicated by writing on the button labels. * These gadgets also enable their buttons when playing and finish their game * when any one, or more, of their buttons is clicked -- or they get bored and * timeout. * *

AltingBarrierGadget3

* Along with their attached buttons, these form a two dimensional structure * covering the surface of a torus. * The gadgets on the top row are adjacent to the gadgets on * the bottom row. * The gadgets on the left column are adjacent to the gadgets on * the right column. * The demonstration program, AltingBarrierGadget3Demo0, * asks the user to choose between various shapes and sizes for * the synchronisation groups (pluses, crosses and * circles) -- but all groups have the same shape and size. *

*

* Creation and distribution of the barriers is not done by the demonstration * program but, more simply, by the gadgets themselves. * Each AltingBarrierGadget3 belongs to many synchronisation * groups, but has lead responsibility for one. * It services the input end of a single channel and is given the (shared) * output ends of the service channels to the other gadgets in the group * it is leading. * [Note: the giver of those output ends is the demonstration program.] * It creates the alting barrier (and some other things -- see below) for * its lead group. * Distribution is by I/O-PAR exchange over their service channels as * the gadgets initialise. * Each gadget sends the things it made to the gadgets in the group it is * leading and receives the same from the leaders of its other synchronisation * groups. * This is the only use they make of these channels. *

*

* A synchronised group plays a simple counting game until one of its buttons * is clicked or the countdown reaches zero. * Termination of the game is, and has to be, simultaneous. * This is managed by a shared termination flag, safely operated * through phased barrier synchronisation (which lets any process * in the group set it in an even phase, with all processes acting * on it in the odd phases). * Shared label and colour variables (for the group's buttons) are operated * similarly. * The shared variables are distributed (as fields of a shared object) by * the leader gadget, along with the group's alting barrier front-ends, * during initialisation. *

*

* The group's AltingBarrier is used to separate the phases. * Alting capability on this barrier enables rapid response to * any button click on the group to end the game. * The lead gadget controls timing: it alts between a countdown timeout, * its button click and a cancel message from the rest of the group (should * any of their buttons be clicked) -- following any of these with the barrier * sync, scheduling the next phase. * The other gadgets alt between their button click and the barrier: * response to a click being the (timeout) cancel message to the leader then * wait for the barrier; response to the barrier being the next phase. *

*

* The Any2One cancel channel is a mulitplexing relay from * the non-lead buttons to the leader gadget. * It is constructed by the lead gadget and distributed to its team alongside * the shared variables. * The cancel channel must be overwriting buffered * to avoid deadlock -- the same as the click channels from buttons. * The cancel channel must be cleared at the start of each game -- same as * the click channels. *

*

* * USER GAME: run the demo program on a 30x20 grid (expand to * full screen), with circle shapes (say), a radius of 3, off and standBy * intervals of 1000 (millisecs), play interval of 10000 (millisecs) and * a count interfavl of 200 (millisecs). * Your challenge is to zap all the coloured shapes away before any of their * counts reach zero and the end of the world happens, :). * How long can you survive?!! *

* *

AltingBarrierGadget4

* These are the same as the previous (AltingBarrierGadget3) * gadgets, except that they do not assume that all the synchronisation groups * to which they belong have the same shape or size. * While they do know the size of the group they lead (from the length of * the channel of output ends they are given), that is all they know. * In particular, they do not know how many items (barriers etc.) to expect * from the leaders of their other groups in the opening exchange. *

*

* This is solved by giving each gadget a global barrier on which their * parallel outputting processes synchronise when they finish their * distribution. * After this synchronisation, all exchanges must have finished and * they can tell their gadgets to proceed. *

*

* The demonstration program for these gadgets just asks for a size for * synchronisation groups and allocates (lead) shapes randomly. * It could randomise the sizes as well, but the smaller patterns would * always emerge dominant in the synchronisations achieved (simply because * they require fewer gadgets to be simultaneously on standby -- * i.e. offering mode) and the consequent games. *

*

* USER GAME: same as before, * except with a span (rather than radius) of 3. *

* *

AltingBarrierGadget5

* These are the same as AltingBarrierGadget4, except for * the technique used to signal the end of the initial exchange of information * amongst the synchronisation groups. * They use a global alting barrier on which both the outputting * and inputting partners in the exchange offer to synchronise -- the former * when finished outputting and the latter as an alternative to inputting. * This is, perhaps, more elegant than the conventional barrier and channel * used by the AltingBarrierGadget4 gadgets and exercises * the {@link #expand()} and {@link #contract()} methods. *

*

* USER GAME: same as before, * except with a span (rather than radius) of 3. *

* *

AltingBarrierGadget6

* The unbuffered service channels used by AltingBarrierGadget3, * AltingBarrierGadget4 and AltingBarrierGadget5 * (in the opening I/O-PAR exchange of information amongst each * playing group) force the leaders to synchronise with each of their * team members. * This is no problem for AltingBarrierGadget3, since all groups * have the same size and it receives as many messages as it sends; knowing * how many messages it is sending, it knows how large its reception arrays * should be. * This is not the case for AltingBarrierGadget4 and * AltingBarrierGadget5, which must first receive into * collection objects that can expand to any size. *

*

* AltingBarrierGadget6 performs an asynchronous opening * exchange of information, using the collection objects directly to buffer * the communication messages and no channels. * Further, no internal parallelism is needed for this exchange: the gadgets * first add all their messages to the collections held by the rest of their * team; then, they synchronise on the global barrier (a non-alting * one, the same as used by AltingBarrierGadget4s); finally, * they extract the information sent by the leaders of the other teams to * which they belong. * As before, the barrier synchronisation is crucial for the correctness of * this exchange, ensuring that all messages are in place before they are * gathered. *

*

* USER GAME: same as before, * except with a span (rather than radius) of 3. *

*

* * * @see org.jcsp.lang.Barrier * @see org.jcsp.lang.Alternative *

* * @author P.H. Welch */ //}}} public class AltingBarrier extends Guard implements MultiwaySynchronisation { /** This references the barrier on which this is enrolled. * Also package visible (nulled by the base.contract methods). */ AltingBarrierBase base; /** Link to the next front-end (used by {@link AltingBarrierBase}). */ AltingBarrier next = null; /** The process offering this barrier (protected by the base monitor). */ private Alternative alt = null; /** Safety check (protected by the base monitor). */ private Thread myThread = null; /** Safety check (protected by the base monitor). * Also package visible (needed by the base.contract(...) method). */ boolean enrolled = true; /** Used to support the {@link #sync() sync} method. */ private Alternative singleAlt = null; /** Used to support the {@link #poll() sync} method. */ private Alternative pollAlt = null; /** Used to support the {@link #poll() sync} method. */ private CSTimer pollTime = null; /** Package-only constructor (used by {@link AltingBarrierBase}). */ AltingBarrier (AltingBarrierBase base, AltingBarrier next) { this.base = base; this.next = next; } /** * This creates a new alting barrier with an (initial) enrollment * count of n. * It provides an array of n front-ends to this barrier. * It is the invoker's responsibility to install one of these (by constructor * or set method) in each process that will be synchronising on * the barrier, before firing up those processes. *

* Note: each process must use a different front-end to * the barrier. Usually, a process retains an AltingBarrier * front-end throughout its lifetime -- however, see {@link #mark mark}. *

* * @param n the number of processes enrolled (initially) on this barrier. *

* * @return an array of n front-ends to this barrier. *

* * @throws IllegalArgumentException if n <= 0. */ public static AltingBarrier[] create (int n) { if (n <= 0) { throw new IllegalArgumentException ( "\n*** An AltingBarrier must have at least one process enrolled, not " + n ); } return new AltingBarrierBase ().expand (n); } /** * This creates a new alting barrier with an (initial) enrollment * count of 1. * It provides a single front-end to the barrier, from which others may * be generated (see {@link #expand() expand()}) -- usually one-at-a-time * to feed processes individually forked (by a {@link ProcessManager}). * It is the invoker's responsibility to install each one (by constructor * or set method) in the process that will be synchronising on * the barrier, before firing up that process. * Usually, a process retains an AltingBarrier front-end * throughout its lifetime -- however, see {@link #mark mark}. *

* Note: if a known number of processes needing the barrier are to be run * (e.g. by a {@link Parallel}), creating the barrier with an array of * front-ends using {@link #create(int) create(n)} would be more convenient. *

* * @return a single front-end for this barrier. */ public static AltingBarrier create () { return new AltingBarrierBase ().expand (); } /** * This expands the number of processes enrolled in this alting barrier. *

* Use it when an enrolled process is about to go {@link Parallel} itself and * some/all of those sub-processes also need to be enrolled. * It returns an array new front-ends for this barrier. * It is the invoker's responsibility to pass these on to those sub-processes. *

*

* Note that if there are x sub-processes to be enrolled, this method * must be invoked with an argument of (x - 1). * Pass the returned AltingBarriers to any (x - 1) * of those sub-processes. * Pass this AltingBarrier to the last one. *

*

* Before using its given front-end to this barrier, each sub-process * must {@link #mark mark} it to take ownership. * [Actually, only the sub-process given the original front-end (which * may be running in a different thread) really has to do this.] *

*

* Following termination of the {@link Parallel}, the original process must * take back ownership of its original AltingBarrier (loaned to one * of the sub-processes, which may have been running on a different thread) * by {@link #mark mark}ing it again. *

*

* Also following termination of the {@link Parallel}, the original process * must contract the number of processes enrolled on the barrier. * To do this, it must have retained the front-end array returned by * this method and pass it to {@link #contract(AltingBarrier[]) contract}. *

*

* * @param n the number of processes to be added to this barrier. *

* * @return an array of new front-ends for this barrier. *

* * @throws IllegalArgumentException if n <= 0. *

* * @throws AltingBarrierError if currently resigned or not owner of this * front-end. */ public AltingBarrier[] expand (int n) { if (n <= 0) { throw new IllegalArgumentException ( "\n*** Expanding an AltingBarrier must be by at least one, not " + n ); } synchronized (base) { if (myThread == null) { myThread = Thread.currentThread (); } else if (myThread != Thread.currentThread ()) { throw new AltingBarrierError ( "\n*** AltingBarrier expand attempted by non-owner." ); } if (!enrolled) { throw new AltingBarrierError ( "\n*** AltingBarrier expand attempted whilst resigned." ); } return base.expand (n); } } /** * This expands by one the number of processes enrolled in this alting * barrier. *

* Use it when an enrolled process is about to fork a new process * (using {@link ProcessManager}) that also needs to be enrolled. * It returns an new front-end for this barrier. * It is the invoker's responsibility to pass it to the new process. *

*

* Before terminating, the forked process should * {@link #contract() contract} (by one) the number of processes * enrolled in this barrier. * Otherwise, no further synchronisations on this barrier would be able * to complete. *

*

* * @return a new front-end for this barrier. *

* * @throws AltingBarrierError if currently resigned or not owner of this * front-end. */ public AltingBarrier expand () { synchronized (base) { if (myThread == null) { myThread = Thread.currentThread (); } else if (myThread != Thread.currentThread ()) { throw new AltingBarrierError ( "\n*** AltingBarrier expand attempted by non-owner." ); } if (!enrolled) { throw new AltingBarrierError ( "\n*** AltingBarrier expand attempted whilst resigned." ); } return base.expand (); } } /** * This contracts the number of processes enrolled in this alting barrier. * The given front-ends are discarded. *

* Use it following termination of a {@link Parallel}, some/all of whose * sub-processes were enrolled by being given front-ends * returned by {@link #expand(int) expand}. * See the documentation for {@link #expand(int) expand}. *

*

* Warning: only the process that went {@link Parallel} should invoke * this method -- never one of the sub-processes. *

*

* Warning: never invoke this method whilst processes using * its argument's front-ends are running. *

*

* Warning: do not attempt to reuse any of the argument elements afterwards * -- they front-end nothing. *

*

* * @param ab the front-ends being discarded from this barrier. * This array must be unaltered from one previously delivered by * an {@link #expand(int) expand}. *

* * @throws IllegalArgumentException if ab is null or zero length. *

* * @throws AltingBarrierError if the given array is not one previously * delivered by an {@link #expand(int) expand(n)}, or the invoking process is * currently resigned or not the owner of this front-end. */ public void contract (AltingBarrier[] ab) { if (ab == null) { throw new IllegalArgumentException ( "\n*** AltingBarrier contract given a null array." ); } if (ab.length == 0) { throw new IllegalArgumentException ( "\n*** AltingBarrier contract given an empty array." ); } synchronized (base) { // if (myThread == null) { // contract on // myThread = Thread.currentThread (); // a virgin AltingBarrier // } // is an error ??? // else // (PHW) if (myThread != Thread.currentThread ()) { throw new AltingBarrierError ( "\n*** AltingBarrier contract attempted by non-owner." ); } if (!enrolled) { throw new AltingBarrierError ( "\n*** AltingBarrier contract attempted whilst resigned." ); } base.contract (ab); } } /** * This contracts by one the number of processes enrolled in this alting * barrier. * This front-end cannot not be used subsequently. *

* This method should be used on individually created front-ends * (see {@link #expand() expand()}) when, and only when, the process holding * it is about to terminate. * Normally, that process would have been forked by the process * creating this barrier. *

*

* Warning: do not try to use this front-end following invocation * of this method -- it no longer fronts anything. *

*

* * @throws AltingBarrierError if currently resigned or not the owner of * this front-end. */ public void contract () { synchronized (base) { // if (myThread == null) { // contract on // myThread = Thread.currentThread (); // a virgin AltingBarrier // } // is an error ??? // else // (PHW) if (myThread != Thread.currentThread ()) { throw new AltingBarrierError ( "\n*** AltingBarrier contract attempted by non-owner." ); } if (!enrolled) { throw new AltingBarrierError ( "\n*** AltingBarrier contract attempted whilst resigned." ); } base.contract (this); } } boolean enable (Alternative a) { // package-only visible synchronized (base) { if (myThread == null) { myThread = Thread.currentThread (); } else if (myThread != Thread.currentThread ()) { throw new AltingBarrierError ( "\n*** AltingBarrier front-end enable by more than one Thread." ); } if (!enrolled) { throw new AltingBarrierError ( "\n*** AltingBarrier front-end enable whilst resigned." ); } if (alt != null) { // in case the same barrier return false; // occurs more than once in } // the same Alternative. if (base.enable ()) { a.setBarrierTrigger (); // let Alternative know we did it return true; } else { alt = a; return false; } } } boolean disable () { // package-only visible synchronized (base) { if (alt == null) { // in case the same barrier return false; // occurs more than once in } // the same Alternative. if (base.disable ()) { alt.setBarrierTrigger (); // let Alternative know we did it alt = null; return true; } else { alt = null; return false; } } } /** * This is the call-back from a successful 'base.enable'. If it was us * that invoked 'base.enable', our 'alt' is null and we don't need to be * scheduled! If we are resigned, ditto. Whoever is calling this 'schedule' * has the 'base' monitor. */ void schedule () { // package-only visible if (alt != null) { alt.schedule (); } } /** * A process may resign only if it is enrolled. * A resigned process may not offer to synchronise on this barrier * (until a subsequent {@link #enroll enroll}). * Other processes can complete the barrier (represented by this front-end) * without participation by the resigned process. *

* Unless all processes synchronising on this barrier terminate in * the same phase, it is usually appropriate for a terminating process * to resign first. Otherwise, its sibling processes will never be * able to complete another synchronisation. *

*

* Note: a process must not transfer its front-end to another * process whilst resigned from the barrier -- see {@link #mark mark}. *

*

* * @throws AltingBarrierError if currently resigned. */ public void resign () { synchronized (base) { if (!enrolled) { throw new AltingBarrierError ( "\n*** AltingBarrier.resign() whilst not enrolled." ); } enrolled = false; base.resign (); } } /** * A process may enroll only if it is resigned. * A re-enrolled process may resume offering to synchronise on this barrier * (until a subsequent {@link #resign resign}). * Other processes cannot complete the barrier (represented by this front-end) * without participation by the re-enrolled process. *

* Note: timing re-enrollment on a barrier usually needs some care. * If the barrier is being used for synchronising phases of execution between * a set of processes, it is crucial that re-enrollment occurs in * an appropriate (not arbitrary) phase. * If the trigger for re-enrollment comes from another enrolled process, * that process should be in such an appropriate phase. * The resigned process should re-enroll and, then, acknowledge the trigger. * The triggering process should wait for that acknowledgement. * If the decision to re-enroll is internal (e.g. following a timeout), * a buddy process, enrolled on the barrier, should be asked to provide * that trigger when in an appropriate phase. * The buddy process, perhaps specially built just for this purpose, polls * a service channel for that question when in that phase. * * @throws AltingBarrierError if currently enrolled. */ public void enroll () { synchronized (base) { if (enrolled) { throw new AltingBarrierError ( "\n*** AltingBarrier.enroll() whilst not resigned." ); } enrolled = true; base.enroll (); } } /** * A process may hand its barrier front-end over to another process, * but the receiving process must invoke this method before using it. * Beware that the process that handed it over must no longer use it. *

*

* Note: a process must not transfer its front-end to another * process whilst resigned from the barrier -- see {@link #resign resign}. * The receiving process assumes this is the case. * This mark will fail if it is not so. *

*

* See {@link #expand(int) expand(n)} for an example pattern of use. *

* * @throws AltingBarrierError if the front-end is resigned. */ public void mark () { synchronized (base) { if (!enrolled) { throw new AltingBarrierError ( "\n*** Attempt to AltingBarrier.mark() a resigned front-end." ); } myThread = Thread.currentThread (); } } /** * This resets a front-end for reuse. * It still fronts the same barrier. * Following this method, this front-end is enrolled on the barrier * and not owned by any process. *

*

* Warning: this should only be used to recycle a front-end * whose process has terminated. * It should not be used to transfer a front-end between running * processes (for which {@link #mark mark} should be used). *

*

* Example: *

   *   AltingBarrier[] action = AltingBarrier.create (n);
   * 
   *   Parallel[] system = new Parallel[n];
   *   for (int i = 0; i < system.length; i++) {
   *     system[i] = new Something (action[i], ...);
   *   }
   * 
   *   while (true) {
   *     // invariant: all 'action' front-ends are enrolled on the barrier.
   *     // invariant: all 'action' front-ends are not yet owned by any process.
   *     system.run ();
   *     // assume: no 'system' process discards (contracts) its 'action' front-end.
   *     // note: some 'system' processes may have resigned their 'action' front-ends.
   *     // note: in the next run of 'system', its processes may be different
   *     //       from the point of view of the 'action' front-ends.
   *     for (int i = 0; i < action.length; i++) {
   *       action[i].reset ();
   *     }
   *     // deduce: loop invariant re-established.
   *   }
   * 
*/ public void reset () { synchronized (base) { if (!enrolled) { enrolled = true; base.enroll (); } myThread = null; } } /** * This is a simple way to perform a committed synchonisation on an * {@link AltingBarrier} without having to set up an {@link Alternative}. * For example, if group is an AltingBarrier, then: *
   *     group.sync ();
   * 
* saves first having to construct the single guarded: *
   *     Alternative groupCommit = new Alternative (new Guard[] {group});
   * 
* and then: *
   *     groupCommit.select ();
   * 
* If this is the only method of synchronisation performed by all parties * to this barrier, a non-alting {@link Barrier} would be more efficient. *

*

* Important note: following a select, priSelect or * fairSelect on an {@link Alternative} that returns the index of * an AltingBarrier, that barrier synchronisation has happened. * Do not proceed to invoke this sync method -- unless, of course, * you want to wait for a second synchronisation. */ public void sync () { if (singleAlt == null) { singleAlt = new Alternative (new Guard[] {this}); } singleAlt.priSelect (); } /** * This is a simple way to poll for synchonisation on an * {@link AltingBarrier} without having to set up an {@link Alternative}. * The parameter specifies how long this poll should leave its offer * to synchronise on the table. * If true is returned, the barrier has completed. * If false, the barrier was unable to complete within * the time specified (i.e. at no time were all parties making * an offer). *

*

* For example, if group is an AltingBarrier, then: *

   *     if (group.poll (offerTime)) {
   *       ...  group synchronisation achieved
   *     } else {
   *       ...  group synchronisation failed (within offerTime millisecs)
   *     }
   * 
* is equivalent to: *
   *     groupTimer.setAlarm (groupTimer.read () + offerTime);
   *     if (groupPoll.priSelect () == 0) {
   *       ...  group synchronisation achieved
   *     } else {
   *       ...  group synchronisation failed (within offerTime millisecs)
   *     }
   * 
* where first would have to have been constructed: *
   *     CSTimer groupTimer = new CSTimer ();
   *     Alternative groupPoll =
   *       new Alternative (new Guard[] {group, groupTimer});
   * 
* Note: polling algorithms should generally be a last resort! * If all parties to this barrier only use this method, synchronisation * depends on all their poll periods coinciding. * An offerTime of zero is allowed: if all other parties * are offering, the barrier will complete -- otherwise, the poll returns * immediately. * However, if more than one party only ever polls like this, * no synchronisation will ever take place. *

*

* * @param offerTime the time (in milliseconds) that this offer to synchronise * should be left on the table. *

* * @return true if and only if the barrier completes within * time specifed. */ public boolean poll (long offerTime) { if (pollAlt == null) { pollTime = new CSTimer (); pollAlt = new Alternative (new Guard[] {this, pollTime}); } pollTime.setAlarm (pollTime.read () + offerTime); return (pollAlt.priSelect () == 0); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedAny2AnyChannel.java0000644000000000000000000001204611105701167021145 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.*; /** * This implements an any-to-any object channel with user-definable buffering, * safe for use by many writers and many readers. *

Description

* BufferedAny2AnyChannel implements an any-to-any object channel with * user-definable buffering. It is safe for use by any number of reading or * writing processes. Reading processes compete with each other to use * the channel. Writing processes compete with each other to use the channel. * Only the reader and one writer will * actually be using the channel at any one time. This is taken care of by * BufferedAny2AnyChannel -- user processes just read from or write to it. *

* Please note that this is a safely shared channel and not * a multicaster. Currently, multicasting has to be managed by * writing active processes (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example of broadcasting). *

* All reading processes and writing processes commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ChannelDataStore ChannelDataStore} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * *

Implementation Note and Caution

* Fair servicing of readers and writers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * any-any channels. * * @see org.jcsp.lang.BufferedOne2OneChannel * @see org.jcsp.lang.BufferedOne2AnyChannel * @see org.jcsp.lang.BufferedAny2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin and P.H. Welch */ class BufferedAny2AnyChannel extends Any2AnyImpl { /** * Constructs a new BufferedAny2AnyChannel with the specified ChannelDataStore. * * @param data The ChannelDataStore used to store the data for the channel */ public BufferedAny2AnyChannel(ChannelDataStore data) { super(new BufferedOne2OneChannel(data)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Channel.java0000644000000000000000000016607411113402355016307 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ChannelDataStore; import org.jcsp.util.ints.ChannelDataStoreInt; /** *

This class provides static factory methods for constructing * all the different types of channel. *

*

* Channels carry either Objects or integers. *

*

* Basic channels are zero-buffered: the writer and reader processes must synchronise. * Buffered channels can be made with various buffering policies: * e.g. fixed size blocking FIFO ({@link org.jcsp.util.Buffer here}), * fixed size overwrite-oldest-when-full ({@link org.jcsp.util.OverWriteOldestBuffer here}), * fixed size discard-when-full ({@link org.jcsp.util.OverFlowingBuffer here}), * infinite sized FIFO ({@link org.jcsp.util.InfiniteBuffer here}). *

*

* Channels can be made {@link Poisonable} with user-chosen immunity * (for the simple and safe shutdown of networks or sub-networks). *

*

* Channels are either one-one (connecting a single writer process * with a single reader), one-any (connecting a single writer process * with any number of readers), any-one (connecting any number of writer processes * with a single reader) or any-any (connecting any number of writer processes * with any number of readers). * Do not misuse them (e.g. use a one-one to connect more than one writer process * to more than one reader). *

*

* Channels are used to construct process networks. * Channel ends, obtained from a channel via its in() * and out() methods, should be plugged into the processes * that need them. * An input-end is used for reading from the channel; * an output-end is used for writing to the channel. * A process should not be given a whole channel – only the end * that it needs. *

*

* Channel input-ends of one-one and any-one channels * may be used as {@link Guard guards} in a {@link Alternative choice}. * Channel input-ends of one-any or any-any channels * may not be so used. *

*

* Channel output-ends of one-one {@link One2OneChannelSymmetric symmetric} channels * may also be used as {@link Guard guards} in a {@link Alternative choice}. * Channel output-ends of all other kinds of channel may not. * Symmetric channels are currently an experiment: buffering and poisoning are not yet supported. *

*

* For convenience, there are also methods for constructing arrays of channels * (and for extracting arrays of channel-ends from arrays of channels). *

* * * @author P.H. Welch */ public class Channel { /** * Private constructor to stop users from instantiating this class. */ private Channel() { //this class should not be instantiated } /** * The factory to be used by this class. The class should implement * ChannelFactory, ChannelArrayFactory, BufferedChannelFactory and BufferedChannelArrayFactory. */ private static final StandardChannelFactory factory = new StandardChannelFactory(); /* New channel construction methods ... */ /** * This constructs an Object carrying channel that * may only be connected to one writer and one reader process at a time. * The channel is zero-buffered – the writer and reader processes must synchronise. * * @return the channel. */ public static One2OneChannel one2one() { return new One2OneChannelImpl(); } /** * This constructs an Object carrying channel that * may only be connected to one writer at a time, * but any number of reader processes. * The readers contend safely with each other to take the next message. * Each message flows from the writer to just one of the readers – * this is not a broadcasting channel. * The channel is zero-buffered – the writer and reader processes must synchronise. * * @return the channel. */ public static One2AnyChannel one2any() { return new One2AnyChannelImpl(); } /** * This constructs an Object carrying channel that * may be connected to any number of writer processes, * but only one reader at a time. * The writers contend safely with each other to send the next message. * Each message flows from just one of the writers to the reader – * this is not a combining channel. * The channel is zero-buffered – the writer and reader processes must synchronise. * * @return the channel. */ public static Any2OneChannel any2one() { return new Any2OneChannelImpl(); } /** * This constructs an Object carrying channel that * may be connected to any number of writer processes * and any number of reader processes. * The writers contend safely with each other to send the next message. * The readers contend safely with each other to take the next message. * Each message flows from just one of the writers to just one of the readers – * this is not a broadcasting-and-combining channel. * The channel is zero-buffered – the writer and reader processes must synchronise. * * @return the channel. */ public static Any2AnyChannel any2any() { return new Any2AnyChannelImpl(); } /** * This constructs a one-one Object channel with user chosen buffering size and policy. * * @param buffer defines size and policy (the channel will clone its own). * @return the channel. */ public static One2OneChannel one2one(ChannelDataStore buffer) { return new BufferedOne2OneChannel(buffer); } /** * This constructs a one-any Object channel with user chosen buffering size and policy. * * @param buffer defines size and policy (the channel will clone its own). * @return the channel. */ public static One2AnyChannel one2any(ChannelDataStore buffer) { return new BufferedOne2AnyChannel(buffer); } /** * This constructs an any-one Object channel with user chosen buffering size and policy. * * @param buffer defines size and policy (the channel will clone its own). * @return the channel. */ public static Any2OneChannel any2one(ChannelDataStore buffer) { return new BufferedAny2OneChannel(buffer); } /** * This constructs an any-any Object channel with user chosen buffering size and policy. * * @param buffer defines size and policy (the channel will clone its own). * @return the channel. */ public static Any2AnyChannel any2any(ChannelDataStore buffer) { return new BufferedAny2AnyChannel(buffer); } /** * This constructs a poisonable one-one Object channel. * * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static One2OneChannel one2one(int immunity) { return new PoisonableOne2OneChannelImpl(immunity); } /** * This constructs a poisonable one-any Object channel. * * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static One2AnyChannel one2any(int immunity) { return new PoisonableOne2AnyChannelImpl(immunity); } /** * This constructs a poisonable any-one Object channel. * * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static Any2OneChannel any2one(int immunity) { return new PoisonableAny2OneChannelImpl(immunity); } /** * This constructs a poisonable any-any Object channel. * * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static Any2AnyChannel any2any(int immunity) { return new PoisonableAny2AnyChannelImpl(immunity); } /** * This constructs a buffered poisonable one-one Object channel. * * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static One2OneChannel one2one(ChannelDataStore buffer, int immunity) { return new PoisonableBufferedOne2OneChannel(buffer, immunity); } /** * This constructs a buffered poisonable one-any Object channel. * * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static One2AnyChannel one2any(ChannelDataStore buffer, int immunity) { return new PoisonableBufferedOne2AnyChannel(buffer, immunity); } /** * This constructs a buffered poisonable any-one Object channel. * * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static Any2OneChannel any2one(ChannelDataStore buffer, int immunity) { return new PoisonableBufferedAny2OneChannel(buffer, immunity); } /** * This constructs a buffered poisonable any-any Object channel. * * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static Any2AnyChannel any2any(ChannelDataStore buffer, int immunity) { return new PoisonableBufferedAny2AnyChannel(buffer, immunity); } /** * This constructs an array of one-one Object channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static One2OneChannel[] one2oneArray(int size) { One2OneChannel[] r = new One2OneChannel[size]; for (int i = 0;i < size;i++) { r[i] = one2one(); } return r; } /** * This constructs an array of one-any Object channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static One2AnyChannel[] one2anyArray(int size) { One2AnyChannel[] r = new One2AnyChannel[size]; for (int i = 0;i < size;i++) { r[i] = one2any(); } return r; } /** * This constructs an array of any-one Object channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static Any2OneChannel[] any2oneArray(int size) { Any2OneChannel[] r = new Any2OneChannel[size]; for (int i = 0;i < size;i++) { r[i] = any2one(); } return r; } /** * This constructs an array of any-any Object channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static Any2AnyChannel[] any2anyArray(int size) { Any2AnyChannel[] r = new Any2AnyChannel[size]; for (int i = 0;i < size;i++) { r[i] = any2any(); } return r; } /** * This constructs an array of poisonable one-one Object channels. * * @param size defines size of the array (must be positive). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static One2OneChannel[] one2oneArray(int size, int immunity) { One2OneChannel[] r = new One2OneChannel[size]; for (int i = 0;i < size;i++) { r[i] = one2one(immunity); } return r; } /** * This constructs an array of poisonable one-any Object channels. * * @param size defines size of the array (must be positive). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static One2AnyChannel[] one2anyArray(int size, int immunity) { One2AnyChannel[] r = new One2AnyChannel[size]; for (int i = 0;i < size;i++) { r[i] = one2any(immunity); } return r; } /** * This constructs an array of poisonable any-one Object channels. * * @param size defines size of the array (must be positive). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static Any2OneChannel[] any2oneArray(int size, int immunity) { Any2OneChannel[] r = new Any2OneChannel[size]; for (int i = 0;i < size;i++) { r[i] = any2one(immunity); } return r; } /** * This constructs an array of poisonable any-any Object channels. * * @param size defines size of the array (must be positive). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static Any2AnyChannel[] any2anyArray(int size, int immunity) { Any2AnyChannel[] r = new Any2AnyChannel[size]; for (int i = 0;i < size;i++) { r[i] = any2any(immunity); } return r; } /** * This constructs an array of buffered one-one Object channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @return the channel array. */ public static One2OneChannel[] one2oneArray(int size, ChannelDataStore buffer) { One2OneChannel[] r = new One2OneChannel[size]; for (int i = 0;i < size;i++) { r[i] = one2one(buffer); } return r; } /** * This constructs an array of buffered one-any Object channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @return the channel array. */ public static One2AnyChannel[] one2anyArray(int size, ChannelDataStore buffer) { One2AnyChannel[] r = new One2AnyChannel[size]; for (int i = 0;i < size;i++) { r[i] = one2any(buffer); } return r; } /** * This constructs an array of buffered any-one Object channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @return the channel array. */ public static Any2OneChannel[] any2oneArray(int size, ChannelDataStore buffer) { Any2OneChannel[] r = new Any2OneChannel[size]; for (int i = 0;i < size;i++) { r[i] = any2one(buffer); } return r; } /** * This constructs an array of buffered any-any Object channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @return the channel array. */ public static Any2AnyChannel[] any2anyArray(int size, ChannelDataStore buffer) { Any2AnyChannel[] r = new Any2AnyChannel[size]; for (int i = 0;i < size;i++) { r[i] = any2any(buffer); } return r; } /** * This constructs an array of buffered poisonable one-one Object channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static One2OneChannel[] one2oneArray(int size, ChannelDataStore buffer, int immunity) { One2OneChannel[] r = new One2OneChannel[size]; for (int i = 0;i < size;i++) { r[i] = one2one(buffer,immunity); } return r; } /** * This constructs an array of buffered poisonable one-any Object channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static One2AnyChannel[] one2anyArray(int size, ChannelDataStore buffer, int immunity) { One2AnyChannel[] r = new One2AnyChannel[size]; for (int i = 0;i < size;i++) { r[i] = one2any(buffer,immunity); } return r; } /** * This constructs an array of buffered poisonable any-one Object channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static Any2OneChannel[] any2oneArray(int size, ChannelDataStore buffer, int immunity) { Any2OneChannel[] r = new Any2OneChannel[size]; for (int i = 0;i < size;i++) { r[i] = any2one(buffer,immunity); } return r; } /** * This constructs an array of buffered poisonable any-any Object channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static Any2AnyChannel[] any2anyArray(int size, ChannelDataStore buffer, int immunity) { Any2AnyChannel[] r = new Any2AnyChannel[size]; for (int i = 0;i < size;i++) { r[i] = any2any(buffer,immunity); } return r; } /** * This constructs an Object carrying channel that * may only be connected to one writer and one reader process at a time. * The channel is zero-buffered – the writer and reader processes must synchronise. *

* The symmetry relates to the use of the channel's ends as {@link Guard guards} * in an {@link Alternative}: both ends may be so used. * * @return the channel. */ public static One2OneChannelSymmetric one2oneSymmetric () { return new BasicOne2OneChannelSymmetric (); } /** * This constructs an array of symmetric one-one Object channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static One2OneChannelSymmetric[] one2oneSymmetricArray(int size) { One2OneChannelSymmetric[] r = new One2OneChannelSymmetric[size]; for (int i = 0;i < size;i++) { r[i] = one2oneSymmetric(); } return r; } /** * This constructs an integer carrying channel that * may only be connected to one writer and one reader process at a time. * The channel is zero-buffered – the writer and reader processes must synchronise. * * @return the channel. */ public static One2OneChannelInt one2oneInt() { return new One2OneChannelIntImpl(); } /** * This constructs an integer carrying channel that * may only be connected to one writer at a time, * but any number of reader processes. * The readers contend safely with each other to take the next message. * Each message flows from the writer to just one of the readers – * this is not a broadcasting channel. * The channel is zero-buffered – the writer and reader processes must synchronise. * * @return the channel. */ public static One2AnyChannelInt one2anyInt() { return new One2AnyChannelIntImpl(); } /** * This constructs an integer carrying channel that * may be connected to any number of writer processes, * but only one reader at a time. * The writers contend safely with each other to send the next message. * Each message flows from just one of the writers to the reader – * this is not a combining channel. * The channel is zero-buffered – the writer and reader processes must synchronise. * * @return the channel. */ public static Any2OneChannelInt any2oneInt() { return new Any2OneChannelIntImpl(); } /** * This constructs an integer carrying channel that * may be connected to any number of writer processes * and any number of reader processes. * The writers contend safely with each other to send the next message. * The readers contend safely with each other to take the next message. * Each message flows from just one of the writers to just one of the readers – * this is not a broadcasting-and-combining channel. * The channel is zero-buffered – the writer and reader processes must synchronise. * * @return the channel. */ public static Any2AnyChannelInt any2anyInt() { return new Any2AnyChannelIntImpl(); } /** * This constructs a one-one integer channel with user chosen buffering size and policy. * * @param buffer defines size and policy (the channel will clone its own). * @return the channel. */ public static One2OneChannelInt one2oneInt(ChannelDataStoreInt buffer) { return new BufferedOne2OneChannelIntImpl(buffer); } /** * This constructs a one-any integer channel with user chosen buffering size and policy. * * @param buffer defines size and policy (the channel will clone its own). * @return the channel. */ public static One2AnyChannelInt one2anyInt(ChannelDataStoreInt buffer) { return new BufferedOne2AnyChannelIntImpl(buffer); } /** * This constructs an any-one integer channel with user chosen buffering size and policy. * * @param buffer defines size and policy (the channel will clone its own). * @return the channel. */ public static Any2OneChannelInt any2oneInt(ChannelDataStoreInt buffer) { return new BufferedAny2OneChannelIntImpl(buffer); } /** * This constructs an any-any integer channel with user chosen buffering size and policy. * * @param buffer defines size and policy (the channel will clone its own). * @return the channel. */ public static Any2AnyChannelInt any2anyInt(ChannelDataStoreInt buffer) { return new BufferedAny2AnyChannelIntImpl(buffer); } /** * This constructs a poisonable one-one integer channel. * * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static One2OneChannelInt one2oneInt(int immunity) { return new PoisonableOne2OneChannelIntImpl(immunity); } /** * This constructs a poisonable one-any integer channel. * * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static One2AnyChannelInt one2anyInt(int immunity) { return new PoisonableOne2AnyChannelIntImpl(immunity); } /** * This constructs a poisonable any-one integer channel. * * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static Any2OneChannelInt any2oneInt(int immunity) { return new PoisonableAny2OneChannelIntImpl(immunity); } /** * This constructs a poisonable any-any integer channel. * * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static Any2AnyChannelInt any2anyInt(int immunity) { return new PoisonableAny2AnyChannelIntImpl(immunity); } /** * This constructs a buffered poisonable one-one integer channel. * * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static One2OneChannelInt one2oneInt(ChannelDataStoreInt buffer, int immunity) { return new PoisonableBufferedOne2OneChannelInt(buffer, immunity); } /** * This constructs a buffered poisonable one-any integer channel. * * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static One2AnyChannelInt one2anyInt(ChannelDataStoreInt buffer, int immunity) { return new PoisonableBufferedOne2AnyChannelInt(buffer, immunity); } /** * This constructs a buffered poisonable any-one integer channel. * * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static Any2OneChannelInt any2oneInt(ChannelDataStoreInt buffer, int immunity) { return new PoisonableBufferedAny2OneChannelInt(buffer, immunity); } /** * This constructs a buffered poisonable any-any integer channel. * * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channel is immune to poison strengths up to and including this level. * @return the channel. */ public static Any2AnyChannelInt any2anyInt(ChannelDataStoreInt buffer, int immunity) { return new PoisonableBufferedAny2AnyChannelInt(buffer, immunity); } /** * This constructs an array of one-one integer channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static One2OneChannelInt[] one2oneIntArray(int size) { One2OneChannelInt[] r = new One2OneChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = one2oneInt(); } return r; } /** * This constructs an array of one-any integer channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static One2AnyChannelInt[] one2anyIntArray(int size) { One2AnyChannelInt[] r = new One2AnyChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = one2anyInt(); } return r; } /** * This constructs an array of any-one integer channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static Any2OneChannelInt[] any2oneIntArray(int size) { Any2OneChannelInt[] r = new Any2OneChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = any2oneInt(); } return r; } /** * This constructs an array of any-any integer channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static Any2AnyChannelInt[] any2anyIntArray(int size) { Any2AnyChannelInt[] r = new Any2AnyChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = any2anyInt(); } return r; } /** * This constructs an array of poisonable one-one integer channels. * * @param size defines size of the array (must be positive). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static One2OneChannelInt[] one2oneIntArray(int size, int immunity) { One2OneChannelInt[] r = new One2OneChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = one2oneInt(immunity); } return r; } /** * This constructs an array of poisonable one-any integer channels. * * @param size defines size of the array (must be positive). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static One2AnyChannelInt[] one2anyIntArray(int size, int immunity) { One2AnyChannelInt[] r = new One2AnyChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = one2anyInt(immunity); } return r; } /** * This constructs an array of poisonable any-one integer channels. * * @param size defines size of the array (must be positive). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static Any2OneChannelInt[] any2oneIntArray(int size, int immunity) { Any2OneChannelInt[] r = new Any2OneChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = any2oneInt(immunity); } return r; } /** * This constructs an array of poisonable any-any integer channels. * * @param size defines size of the array (must be positive). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static Any2AnyChannelInt[] any2anyIntArray(int size, int immunity) { Any2AnyChannelInt[] r = new Any2AnyChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = any2anyInt(immunity); } return r; } /** * This constructs an array of buffered one-one integer channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @return the channel array. */ public static One2OneChannelInt[] one2oneIntArray(int size, ChannelDataStoreInt buffer) { One2OneChannelInt[] r = new One2OneChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = one2oneInt(buffer); } return r; } /** * This constructs an array of buffered one-any integer channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @return the channel array. */ public static One2AnyChannelInt[] one2anyIntArray(int size, ChannelDataStoreInt buffer) { One2AnyChannelInt[] r = new One2AnyChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = one2anyInt(buffer); } return r; } /** * This constructs an array of buffered any-one integer channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @return the channel array. */ public static Any2OneChannelInt[] any2oneIntArray(int size, ChannelDataStoreInt buffer) { Any2OneChannelInt[] r = new Any2OneChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = any2oneInt(buffer); } return r; } /** * This constructs an array of buffered any-any integer channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @return the channel array. */ public static Any2AnyChannelInt[] any2anyIntArray(int size, ChannelDataStoreInt buffer) { Any2AnyChannelInt[] r = new Any2AnyChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = any2anyInt(buffer); } return r; } /** * This constructs an array of buffered poisonable one-one integer channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static One2OneChannelInt[] one2oneIntArray(int size, ChannelDataStoreInt buffer, int immunity) { One2OneChannelInt[] r = new One2OneChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = one2oneInt(buffer,immunity); } return r; } /** * This constructs an array of buffered poisonable one-any integer channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static One2AnyChannelInt[] one2anyIntArray(int size, ChannelDataStoreInt buffer, int immunity) { One2AnyChannelInt[] r = new One2AnyChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = one2anyInt(buffer,immunity); } return r; } /** * This constructs an array of buffered poisonable any-one integer channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static Any2OneChannelInt[] any2oneIntArray(int size, ChannelDataStoreInt buffer, int immunity) { Any2OneChannelInt[] r = new Any2OneChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = any2oneInt(buffer,immunity); } return r; } /** * This constructs an array of buffered poisonable any-any integer channels. * * @param size defines size of the array (must be positive). * @param buffer defines size and policy (the channel will clone its own). * @param immunity the channels are immune to poison strengths up to and including this level. * @return the channel array. */ public static Any2AnyChannelInt[] any2anyIntArray(int size, ChannelDataStoreInt buffer, int immunity) { Any2AnyChannelInt[] r = new Any2AnyChannelInt[size]; for (int i = 0;i < size;i++) { r[i] = any2anyInt(buffer,immunity); } return r; } /** * This constructs an integer carrying channel that * may only be connected to one writer and one reader process at a time. * The channel is zero-buffered – the writer and reader processes must synchronise. *

* The symmetry relates to the use of the channel's ends as {@link Guard guards} * in an {@link Alternative}: both ends may be so used. * * @return the channel. */ public static One2OneChannelSymmetricInt one2oneSymmetricInt () { return new BasicOne2OneChannelSymmetricInt (); } /** * This constructs an array of symmetric one-one integer channels. * * @param size defines size of the array (must be positive). * @return the channel array. */ public static One2OneChannelSymmetricInt[] one2oneSymmetricIntArray(int size) { One2OneChannelSymmetricInt[] r = new One2OneChannelSymmetricInt[size]; for (int i = 0;i < size;i++) { r[i] = one2oneSymmetricInt(); } return r; } /* Helper methods to get arrays of channel ends ... */ /** * This extracts the input-ends from the given channel array. * Each element of the returned array is the input-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of input-ends from the given channel array. */ public static AltingChannelInput[] getInputArray(One2OneChannel[] c) { AltingChannelInput[] in = new AltingChannelInput[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * This extracts the input-ends from the given channel array. * Each element of the returned array is the input-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of input-ends from the given channel array. */ public static SharedChannelInput[] getInputArray(One2AnyChannel[] c) { SharedChannelInput[] in = new SharedChannelInput[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * This extracts the input-ends from the given channel array. * Each element of the returned array is the input-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of input-ends from the given channel array. */ public static AltingChannelInput[] getInputArray(Any2OneChannel[] c) { AltingChannelInput[] in = new AltingChannelInput[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * This extracts the input-ends from the given channel array. * Each element of the returned array is the input-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of input-ends from the given channel array. */ public static SharedChannelInput[] getInputArray(Any2AnyChannel[] c) { SharedChannelInput[] in = new SharedChannelInput[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * This extracts the output-ends from the given channel array. * Each element of the returned array is the output-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of output-ends from the given channel array. */ public static ChannelOutput[] getOutputArray(One2OneChannel[] c) { ChannelOutput[] in = new ChannelOutput[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * This extracts the output-ends from the given channel array. * Each element of the returned array is the output-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of output-ends from the given channel array. */ public static ChannelOutput[] getOutputArray(One2AnyChannel[] c) { ChannelOutput[] in = new ChannelOutput[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * This extracts the output-ends from the given channel array. * Each element of the returned array is the output-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of output-ends from the given channel array. */ public static SharedChannelOutput[] getOutputArray(Any2OneChannel[] c) { SharedChannelOutput[] in = new SharedChannelOutput[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * This extracts the output-ends from the given channel array. * Each element of the returned array is the output-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of output-ends from the given channel array. */ public static SharedChannelOutput[] getOutputArray(Any2AnyChannel[] c) { SharedChannelOutput[] in = new SharedChannelOutput[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * This extracts the input-ends from the given channel array. * Each element of the returned array is the input-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of input-ends from the given channel array. */ public static AltingChannelInputInt[] getInputArray(One2OneChannelInt[] c) { AltingChannelInputInt[] in = new AltingChannelInputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * This extracts the input-ends from the given channel array. * Each element of the returned array is the input-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of input-ends from the given channel array. */ public static SharedChannelInputInt[] getInputArray(One2AnyChannelInt[] c) { SharedChannelInputInt[] in = new SharedChannelInputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * This extracts the input-ends from the given channel array. * Each element of the returned array is the input-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of input-ends from the given channel array. */ public static AltingChannelInputInt[] getInputArray(Any2OneChannelInt[] c) { AltingChannelInputInt[] in = new AltingChannelInputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * This extracts the input-ends from the given channel array. * Each element of the returned array is the input-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of input-ends from the given channel array. */ public static SharedChannelInputInt[] getInputArray(Any2AnyChannelInt[] c) { SharedChannelInputInt[] in = new SharedChannelInputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * This extracts the output-ends from the given channel array. * Each element of the returned array is the output-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of output-ends from the given channel array. */ public static ChannelOutputInt[] getOutputArray(One2OneChannelInt[] c) { ChannelOutputInt[] in = new ChannelOutputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * This extracts the output-ends from the given channel array. * Each element of the returned array is the output-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of output-ends from the given channel array. */ public static ChannelOutputInt[] getOutputArray(One2AnyChannelInt[] c) { ChannelOutputInt[] in = new ChannelOutputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * This extracts the output-ends from the given channel array. * Each element of the returned array is the output-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of output-ends from the given channel array. */ public static SharedChannelOutputInt[] getOutputArray(Any2OneChannelInt[] c) { SharedChannelOutputInt[] in = new SharedChannelOutputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * This extracts the output-ends from the given channel array. * Each element of the returned array is the output-end of the channel * at the corresponding index in the given channel array. * * @param c an array of channels. * @return the array of output-ends from the given channel array. */ public static SharedChannelOutputInt[] getOutputArray(Any2AnyChannelInt[] c) { SharedChannelOutputInt[] in = new SharedChannelOutputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /* Methods that are the same as the Factory Methods (all now deprecated) */ /** * Constructs and returns a One2OneChannel object. * * @return the channel. * * @see org.jcsp.lang.ChannelFactory#createOne2One() * * @deprecated Use the {@link #one2one()} method instead. */ public static One2OneChannel createOne2One() { return factory.createOne2One(); } /** * Constructs and returns an Any2OneChannel object. * * @return the channel. * * @see org.jcsp.lang.ChannelFactory#createAny2One() * * @deprecated Use the {@link #any2one()} method instead. */ public static Any2OneChannel createAny2One() { return factory.createAny2One(); } /** * Constructs and returns a One2AnyChannel object. * * @return the channel. * * @see org.jcsp.lang.ChannelFactory#createOne2Any() * * @deprecated Use the {@link #one2any()} method instead. */ public static One2AnyChannel createOne2Any() { return factory.createOne2Any(); } /** * Constructs and returns an Any2AnyChannel object. * * @return the channel. * * @see org.jcsp.lang.ChannelFactory#createAny2Any() * * @deprecated Use the {@link #any2any()} method instead. */ public static Any2AnyChannel createAny2Any() { return factory.createAny2Any(); } /** * Constructs and returns an array of One2OneChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2One(int) * * @deprecated Use the {@link #one2oneArray(int)} method instead. */ public static One2OneChannel[] createOne2One(int n) { return factory.createOne2One(n); } /** * Constructs and returns an array of Any2OneChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2One(int) * * @deprecated Use the {@link #any2oneArray(int)} method instead. */ public static Any2OneChannel[] createAny2One(int n) { return factory.createAny2One(n); } /** * Constructs and returns an array of One2AnyChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2Any(int) * * @deprecated Use the {@link #one2anyArray(int)} method instead. */ public static One2AnyChannel[] createOne2Any(int n) { return factory.createOne2Any(n); } /** * Constructs and returns an array of Any2AnyChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2Any(int) * * @deprecated Use the {@link #any2anyArray(int)} method instead. */ public static Any2AnyChannel[] createAny2Any(int n) { return factory.createAny2Any(n); } /** *

Constructs and returns a One2OneChannel object which * uses the specified ChannelDataStore object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStore to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelFactory#createOne2One(ChannelDataStore) * @see org.jcsp.util.ChannelDataStore * * @deprecated Use the {@link #one2one(ChannelDataStore)} method instead. */ public static One2OneChannel createOne2One(ChannelDataStore buffer) { return factory.createOne2One(buffer); } /** *

Constructs and returns a Any2OneChannel object which * uses the specified ChannelDataStore object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStore to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelFactory#createAny2One(ChannelDataStore) * @see org.jcsp.util.ChannelDataStore * * @deprecated Use the {@link #any2one(ChannelDataStore)} method instead. */ public static Any2OneChannel createAny2One(ChannelDataStore buffer) { return factory.createAny2One(buffer); } /** *

Constructs and returns a One2AnyChannel object which * uses the specified ChannelDataStore object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStore to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelFactory#createOne2Any(ChannelDataStore) * @see org.jcsp.util.ChannelDataStore * * @deprecated Use the {@link #one2any(ChannelDataStore)} method instead. */ public static One2AnyChannel createOne2Any(ChannelDataStore buffer) { return factory.createOne2Any(buffer); } /** *

Constructs and returns a Any2AnyChannel object which * uses the specified ChannelDataStore object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStore to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelFactory#createAny2Any(ChannelDataStore) * @see org.jcsp.util.ChannelDataStore * * @deprecated Use the {@link #any2any(ChannelDataStore)} method instead. */ public static Any2AnyChannel createAny2Any(ChannelDataStore buffer) { return factory.createAny2Any(buffer); } /** *

Constructs and returns an array of One2OneChannel objects * which use the specified ChannelDataStore object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStore to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelArrayFactory#createOne2One(ChannelDataStore, int) * @see org.jcsp.util.ChannelDataStore * * @deprecated Use the {@link #one2oneArray(int,ChannelDataStore)} method instead. */ public static One2OneChannel[] createOne2One(ChannelDataStore buffer, int n) { return factory.createOne2One(buffer, n); } /** *

Constructs and returns an array of Any2OneChannel objects * which use the specified ChannelDataStore object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStore to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelArrayFactory#createAny2One(ChannelDataStore, int) * @see org.jcsp.util.ChannelDataStore * * @deprecated Use the {@link #any2oneArray(int,ChannelDataStore)} method instead. */ public static Any2OneChannel[] createAny2One(ChannelDataStore buffer, int n) { return factory.createAny2One(buffer, n); } /** *

Constructs and returns an array of One2AnyChannel objects * which use the specified ChannelDataStore object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStore to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelArrayFactory#createOne2Any(ChannelDataStore, int) * @see org.jcsp.util.ChannelDataStore * * @deprecated Use the {@link #one2anyArray(int,ChannelDataStore)} method instead. */ public static One2AnyChannel[] createOne2Any(ChannelDataStore buffer, int n) { return factory.createOne2Any(buffer, n); } /** *

Constructs and returns an array of Any2AnyChannel objects * which use the specified ChannelDataStore object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStore to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelArrayFactory#createAny2Any(ChannelDataStore, int) * @see org.jcsp.util.ChannelDataStore * * @deprecated Use the {@link #any2anyArray(int,ChannelDataStore)} method instead. */ public static Any2AnyChannel[] createAny2Any(ChannelDataStore buffer, int n) { return factory.createAny2Any(buffer, n); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelOutputWrapper.java0000644000000000000000000000612111105701167021057 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines a wrapper to go around a channel output end. This wrapper allows a channel end to be given * away without any risk of the user of that end casting it to a channel input because they cannot * gain access to the actual channel end. * * @deprecated There is no longer any need to use this class, after the 1.1 class reorganisation. * * @author Quickstone Technologies Limited */ public class ChannelOutputWrapper implements ChannelOutput { /** * The actual channel end. */ private ChannelOutput out; /** * Creates a new wrapper for the given channel end. * * @param out the existing channel end. */ public ChannelOutputWrapper(ChannelOutput out) { this.out = out; } /** * Writes a value to the channel. * * @param o the value to write. * @see org.jcsp.lang.ChannelOutput */ public void write(Object o) { out.write(o); } public void poison(int strength) { out.poison(strength); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableChannelInputImpl.java0000644000000000000000000000437511113671251022130 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class RejectableChannelInputImpl extends ChannelInputImpl implements RejectableChannelInput { public RejectableChannelInputImpl(ChannelInternals _channel, int _immunity) { super(_channel, _immunity); } public void reject() { super.poison(Integer.MAX_VALUE); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneChannel.java0000644000000000000000000001321411113671251017471 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines an interface for an any-to-one Object channel, * safe for use by many writers and one reader. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Channels may be {@link Channel#any2one() synchronising}, * {@link Channel#any2one(org.jcsp.util.ChannelDataStore) buffered}, * {@link Channel#any2one(int) poisonable} * or {@link Channel#any2one(org.jcsp.util.ChannelDataStore,int) both} * (i.e. buffered and poisonable). *

*

Description

* Any2OneChannel is an interface for a channel which * is safe for use by many writing processes but only one reader. * Writing processes compete with each other to use the channel. * Only the reader and one writer will * actually be using the channel at any one time. This is managed by the * channel – user processes just read from or write to it. *

*

* Please note that this is a safely shared channel and not a message gatherer. * Currently, gathering has to be managed by writing an active process. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

*

* The default semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

*

* The static methods of {@link Channel} construct channels with * either the default semantics or with buffering to user-specified capacity * and a range of blocking/overwriting policies. * Various buffering plugins are given in the org.jcsp.util package, but * careful users may write their own. *

*

* The {@link Channel} methods also provide for the construction of * {@link Poisonable} channels and for arrays of channels. * *

Implementation Note and Caution

* Fair servicing of writers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * any-1 channels. * * @see org.jcsp.lang.Channel * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.One2OneChannel * @see org.jcsp.lang.One2AnyChannel * @see org.jcsp.lang.Any2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin and P.H. Welch */ public interface Any2OneChannel { /** * Returns the input end of the channel. */ public AltingChannelInput in(); /** * Returns the output end of the channel. */ public SharedChannelOutput out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/TaggedProtocol.java0000644000000000000000000002422711105701167017651 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * TaggedProtocol is the base class for messages carrying * an occam2-like tagged (CASE) protocol over JCSP channels. *

*

Example

*

Protocol Definition

* SampleProtocol illustrates one approach to the passing of different * information structures across the same JCSP channel. It corresponds to the tagged * (CASE) PROTOCOL of occam2.1. The example was invented * by Rick Beton (of Roke Manor Research Ltd.): * *
 * PROTOCOL String IS BYTE::[]BYTE:  -- slight licence here!
 * 
 * DATA TYPE Complex32
 *   RECORD
 *     REAL32 real, imag:
 * :
 * 
 * PROTOCOL SampleProtocol
 *   CASE
 *     NOTHING.IN.PARTICULAR
 *     STRING; String
 *     INTEGER; INT
 *     COMPLEX; Complex32
 *     BOO.TO.A.GOOSE
 * :
 * 
* *
* This corresponds to the (JCSP) Java declaration: * *
 * public class SampleProtocol {
 * 
 *   public static final int NOTHING_IN_PARTICULAR = 0;
 *   public static final int                STRING = 1;
 *   public static final int               INTEGER = 2;
 *   public static final int               COMPLEX = 3;
 *   public static final int        BOO_TO_A_GOOSE = 4;
 * 
 *   static public class NothingInParticular extends TaggedProtocol {
 *     public NothingInParticular () {
 *       super (NOTHING_IN_PARTICULAR);
 *     }
 *   }
 * 
 *   static public class String extends TaggedProtocol {
 *     public final java.lang.String string;
 *     public String (final java.lang.String string) {
 *       super (STRING);
 *       this.string = string;
 *     }
 *   }
 * 
 *   static public class Integer extends TaggedProtocol {
 *     public final int value;
 *     public Integer (final int value) {
 *       super (INTEGER);
 *       this.value = value;
 *     }
 *   }
 * 
 *   static public class Complex extends TaggedProtocol {
 *     public final float real;
 *     public final float imag;
 *     public Complex (final float real, final float imag) {
 *       super (COMPLEX);
 *       this.real = real;
 *       this.imag = imag;
 *     }
 *   }
 * 
 *   static public class BooToAGoose extends TaggedProtocol {
 *     public BooToAGoose () {
 *       super (BOO_TO_A_GOOSE);
 *     }
 *   }
 * 
 * }
 * 
* The emphasis in the above definition is security. The protocol variants * hold only immutable data (whose transmission, therefore, can never lead to race * hazards). Secondly, it is impossible for the user of the protocol to set up * an incorrect tag or misinterpret a correct one without raising an exception. * *

Protocol Use

* This example has a simple pair of CSProcesses communicating over a channel * using the SampleProtocol. *

* First, here is the occam2.1 version. The network is defined * (and started) by: *

 * CHAN OF SampleProtocol c:
 * 
 * PAR
 *   Producer (c)
 *   Consumer (c, screen)
 * 
* where: *
 * PROC Producer (CHAN OF SampleProtocol out)
 * 
 *   VAL []BYTE m1 IS "Hello World ...":
 *   VAL []BYTE m2 IS "Goodbye World ...":
 * 
 *   SEQ
 *     out ! NOTHING.IN.PARTICULAR
 *     out ! STRING; (BYTE SIZE m1)::m1
 *     out ! INTEGER; 42
 *     out ! NOTHING.IN.PARTICULAR
 *     out ! COMPLEX; [3.1416, 0.7071]
 *     out ! STRING; (BYTE SIZE m2)::m2
 *     out ! BOO.TO.A.GOOSE
 * 
 * :
 * 
* and where: *
 * PROC Consumer (CHAN OF SampleProtocol in, CHAN OF BYTE screen)
 * 
 *   INITIAL BOOL running IS TRUE:
 * 
 *   WHILE running
 *     in ? CASE
 *       NOTHING.IN.PARTICULAR
 *         out.string ("==> NothingInParticular happening ...*c*n", 0, screen)
 *       BYTE size:
 *       [255]BYTE s:
 *       STRING; size::s
 *         SEQ
 *           out.string ("==> *"", 0, screen)
 *           out.string ([s FOR INT size], 0, screen)
 *           out.string ("*"*c*n", 0, screen)
 *       INT i:
 *       INTEGER; i
 *         SEQ
 *           out.string ("==> ", 0, screen)
 *           out.number (i, 0, screen)
 *           out.string ("*c*n", 0, screen)
 *       Complex32 c:
 *       COMPLEX; c
 *         SEQ
 *           out.string ("==> [", 0, screen)
 *           out.real32 (c[real], 0, screen)
 *           out.string (", ", 0, screen)
 *           out.real32 (c[imag], 0, screen)
 *           out.string ("*c*n", 0, screen)
 *       BOO.TO.A.GOOSE
 *         SEQ
 *           out.string ("==> Waaaaaa!  You scared me!!  I'm off!!!", 0, screen)
 *           running := FALSE
 * 
 * :
 * 
*

* Here is the (JCSP) Java version. The network is defined * (and started) by: *

 * final One2OneChannel c = Channel.one2one ();
 * 
 * new Parallel (
 *   new CSProcess[] {
 *      new Producer (c),
 *      new Consumer (c)
 *    }
 * ).run ();
 * 
*
* where: *
 * import org.jcsp.lang.*;
 * 
 * public class Producer implements CSProcess {
 * 
 *   private final ChannelOutput out;
 * 
 *   public Producer (ChannelOutput out) {
 *     this.out = out;
 *   }
 * 
 *   public void run() {
 * 
 *     out.write (new SampleProtocol.NothingInParticular ());
 *     out.write (new SampleProtocol.String ("Hello World ..."));
 *     out.write (new SampleProtocol.Integer (42));
 *     out.write (new SampleProtocol.NothingInParticular ());
 *     out.write (new SampleProtocol.Complex (3.1416f, 0.7071f));
 *     out.write (new SampleProtocol.String ("Goodbye World ..."));
 *     out.write (new SampleProtocol.BooToAGoose ());
 * 
 *   }
 * 
 * }
 * 
*
* and where: *
 * import org.jcsp.lang.*;
 * 
 * public class Consumer implements CSProcess {
 * 
 *   private final ChannelInput in;
 * 
 *   public Consumer (ChannelInput in) {
 *     this.in = in;
 *   }
 * 
 *   public void run () {
 * 
 *     boolean running = true;
 * 
 *     while (running) {
 * 
 *       TaggedProtocol tp = (TaggedProtocol) in.read ();
 * 
 *       switch (tp.tag) {
 *          case SampleProtocol.NOTHING_IN_PARTICULAR:
 *            System.out.println ("==> NothingInParticular happening ...");
 *          break;
 *          case SampleProtocol.STRING:
 *            SampleProtocol.String sms = (SampleProtocol.String) tp;
 *            System.out.println ("==> \"" + sms.string + "\"");
 *          break;
 *          case SampleProtocol.INTEGER:
 *            SampleProtocol.Integer smi = (SampleProtocol.Integer) tp;
 *            System.out.println ("==> " + smi.value);
 *          break;
 *          case SampleProtocol.COMPLEX:
 *            SampleProtocol.Complex smc = (SampleProtocol.Complex) tp;
 *            System.out.println ("==> [" + smc.real + ", " + smc.imag + "]");
 *          break;
 *          case SampleProtocol.BOO_TO_A_GOOSE:
 *            System.out.println ("==> Waaaaaa!  You scared me!!  I'm off!!!");
 *            running = false;
 *          break;
 *       }
 * 
 *     }
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch */ public class TaggedProtocol { /** * This public tag is used by the receiving process to determine which variant * of a tagged protocol has been received. * See the above
Consumer example (and the definition of * its input channel's SampleProtocol). */ public final int tag; /** * This super-constructor is invoked by the extending sub-class constructor. * It should be passed a tag that is unique for the tagged protocol for which * that sub-class is one variant. * See the above SampleProtocol (and its use * in Producer and Consumer). */ public TaggedProtocol(final int tag) { this.tag = tag; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyIntImpl.java0000644000000000000000000000672011113671251017501 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class One2AnyIntImpl implements One2AnyChannelInt, ChannelInternalsInt { private ChannelInternalsInt channel; /** The mutex on which readers must synchronize */ private final Mutex readMutex = new Mutex(); One2AnyIntImpl(ChannelInternalsInt _channel) { channel = _channel; } public SharedChannelInputInt in() { return new SharedChannelInputIntImpl(this,0); } public ChannelOutputInt out() { return new ChannelOutputIntImpl(channel,0); } public void endRead() { channel.endRead(); readMutex.release(); } public int read() { readMutex.claim(); //A poison exception might be thrown, hence the try/finally: try { return channel.read(); } finally { readMutex.release(); } } //begin never used: public boolean readerDisable() { return false; } public boolean readerEnable(Alternative alt) { return false; } public boolean readerPending() { return false; } //end never used public void readerPoison(int strength) { readMutex.claim(); channel.readerPoison(strength); readMutex.release(); } public int startRead() { readMutex.claim(); try { return channel.startRead(); } catch (RuntimeException e) { channel.endRead(); readMutex.release(); throw e; } } //begin never used public void write(int n) { channel.write(n); } public void writerPoison(int strength) { channel.writerPoison(strength); } //end never used } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelDataRejectedException.java0000644000000000000000000000452311105701167022420 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Thrown by a read or a write method of a channel when a reject has been * called and the synchronization and data transfer will not complete. * * @author Quickstone Technologies Limited */ public class ChannelDataRejectedException extends RuntimeException { } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelAccept.java0000644000000000000000000000554211105701167020562 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This extends {@link Guard} and {@link ChannelAccept} * to enable a process to choose between many CALL channel (and other) events. *

Description

* AltingChannelAccept extends {@link Guard} and {@link ChannelAccept} * to enable a process * to choose between many CALL channel (and other) events. The methods inherited from * Guard are of no concern to users of this package. * *

Example

* See the explanations and examples documented in {@link One2OneCallChannel} and * {@link Any2OneCallChannel}. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.One2OneCallChannel * @see org.jcsp.lang.Any2OneCallChannel * * @author P.H. Welch */ public abstract class AltingChannelAccept extends Guard implements ChannelAccept { // nothing to add ... } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedOne2OneChannelIntImpl.java0000644000000000000000000002507111105701167022430 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ChannelDataStore; import org.jcsp.util.ints.*; /** * This implements a one-to-one integer channel with user-definable buffering. *

Description

* BufferedOne2OneChannelIntImpl implements a one-to-one integer channel with * user-definable buffering. Multiple readers or multiple writers are * not allowed -- these are catered for by {@link BufferedAny2OneChannel}, * {@link BufferedOne2AnyChannel} or {@link BufferedAny2AnyChannel}. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ints.ChannelDataStoreInt ChannelDataStoreInt} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.BufferedAny2OneChannelIntImpl * @see org.jcsp.lang.BufferedOne2AnyChannelIntImpl * @see org.jcsp.lang.BufferedAny2AnyChannelIntImpl * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin * @author P.H. Welch */ class BufferedOne2OneChannelIntImpl implements One2OneChannelInt, ChannelInternalsInt { /** The monitor synchronising reader and writer on this channel */ private Object rwMonitor = new Object(); /** The Alternative class that controls the selection */ private Alternative alt; /** The ChannelDataStoreInt used to store the data for the channel */ private final ChannelDataStoreInt data; /*************Methods from One2OneChannelInt******************************/ /** * Returns the AltingChannelInputInt object to use for this * channel. As One2OneChannelIntImpl implements * AltingChannelInputInt itself, this method simply returns * a reference to the object that it is called on. * * @return the AltingChannelInputInt object to use for this * channel. */ public AltingChannelInputInt in() { return new AltingChannelInputIntImpl(this,0); } /** * Returns the ChannelOutputInt object to use for this * channel. As One2OneChannelIntImpl implements * ChannelOutputInt itself, this method simply returns * a reference to the object that it is called on. * * @return the ChannelOutputInt object to use for this * channel. */ public ChannelOutputInt out() { return new ChannelOutputIntImpl(this,0); } /** * Constructs a new BufferedOne2OneChannelIntImpl with the specified ChannelDataStoreInt. * * @param data the ChannelDataStoreInt used to store the data for the channel */ public BufferedOne2OneChannelIntImpl(ChannelDataStoreInt data) { if (data == null) throw new IllegalArgumentException ("Null ChannelDataStoreInt given to channel constructor ...\n"); this.data = (ChannelDataStoreInt) data.clone(); } /** * Reads an int from the channel. * * @return the integer read from the channel. */ public int read () { synchronized (rwMonitor) { if (data.getState () == ChannelDataStoreInt.EMPTY) { try { rwMonitor.wait (); while (data.getState () == ChannelDataStoreInt.EMPTY) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelIntXRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannelInt.read (int)\n" + e.toString () ); } } rwMonitor.notify (); return data.get (); } } public int startRead() { synchronized (rwMonitor) { if (data.getState () == ChannelDataStore.EMPTY) { try { rwMonitor.wait (); while (data.getState () == ChannelDataStore.EMPTY) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.read (int)\n" + e.toString () ); } } return data.startGet(); } } public void endRead() { synchronized(rwMonitor) { data.endGet(); rwMonitor.notify (); } } /** * Writes an int to the channel. * * @param value the integer to write to the channel. */ public void write (int value) { synchronized (rwMonitor) { data.put (value); if (alt != null) { alt.schedule (); } else { rwMonitor.notify (); } if (data.getState () == ChannelDataStoreInt.FULL) { try { rwMonitor.wait (); while (data.getState () == ChannelDataStoreInt.FULL) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelIntXWrite); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannelInt.write (int)\n" + e.toString () ); } } } } /** * turns on Alternative selection for the channel. Returns true if the * channel has data that can be read immediately. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class which will control the selection * @return true if the channel has data that can be read, else false */ public boolean readerEnable (Alternative alt) { synchronized (rwMonitor) { if (data.getState () == ChannelDataStoreInt.EMPTY) { this.alt = alt; return false; } else { return true; } } } /** * turns off Alternative selection for the channel. Returns true if the * channel contained data that can be read. *

* Note: this method should only be called by the Alternative class * * @return true if the channel has data that can be read, else false */ public boolean readerDisable () { synchronized (rwMonitor) { alt = null; return data.getState () != ChannelDataStoreInt.EMPTY; } } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. *

* This method is provided for convenience. Its functionality can be provided * by Pri Alting the channel against a SKIP guard, although * at greater run-time and syntactic cost. For example, the following code * fragment: *

     *   if (c.pending ()) {
     *     int x = c.read ();
     *     ...  do something with x
     *   } else (
     *     ...  do something else
     *   }
     * 
* is equivalent to: *
     *   if (c_pending.priSelect () == 0) {
     *     int x = c.read ();
     *     ...  do something with x
     *   } else (
     *     ...  do something else
     * }
     * 
* where earlier would have had to have been declared: *
     * final Alternative c_pending =
     *   new Alternative (new Guard[] {c, new Skip ()});
     * 
* * @return state of the channel. */ public boolean readerPending () { synchronized (rwMonitor) { return (data.getState () != ChannelDataStoreInt.EMPTY); } } // No poison in these channels: public void writerPoison(int strength) { } public void readerPoison(int strength) { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableBufferedOne2OneChannel.java0000644000000000000000000000711111105701167023107 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.*; /** *

This implements a one-to-one object channel with user-definable buffering, * for use by a single writer and single reader. Refer to {@link One2OneChannel} for a * description of this behaviour.

* *

Additionally, this channel supports a reject operation. The reader may call * the reject method to force any current writer to abort with a * ChannelDataRejectedException. Subsequent read and write attempts will immediately cause a * ChannelDataRejectedException.

* *

Note that the reject operation cannot be called concurrently to a read.

* * @author Quickstone Technologies Limited * * @deprecated This channel is superceded by the poison mechanisms, please see {@link PoisonException} */ public class RejectableBufferedOne2OneChannel implements RejectableChannel { BufferedOne2OneChannel innerChannel; /** * Constructs a new channel. * * @param buffer the buffer implementation to use. */ public RejectableBufferedOne2OneChannel(ChannelDataStore buffer) { innerChannel = (BufferedOne2OneChannel)Channel.one2one(buffer); } public RejectableAltingChannelInput inAlt() { return new RejectableAltingChannelInputImpl(innerChannel,0); } public RejectableChannelInput in() { return new RejectableChannelInputImpl(innerChannel,0); } public RejectableChannelOutput out() { return new RejectableChannelOutputImpl(innerChannel,0); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingBarrierCoordinate.java0000644000000000000000000001236211105701167021466 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; class AltingBarrierCoordinate { // package-only visible class /* * This records number of processes active in ALT enable/disable sequences * involving a barrier. *

* Only one process may be engaged in an enable sequence involving a barrier. *

* Disable sequences, triggered by a successful barrier enable, may happen * in parallel. Disable sequences, triggered by a successful barrier enable, * may not happen in parallel with an enable sequence involving a barrier. *

* Disable sequences involving a barrier, triggered by a successful non-barrier * enable, may happen in parallel with an enable sequence involving a barrier. * Should the enable sequence complete a barrier that is in a disable sequence * (which can't yet have been disabled, else it could not have been completed), * the completed barrier will be found (when it is disabled) and that disable * sequence becomes as though it had been triggered by that successful barrier * enable (rather than the non-barrier event). */ private static int active = 0; /** Lock object for coordinating enable/disable sequences. */ private static Object activeLock = new Object (); /* Invoked at start of an enable sequence involving a barrier. */ static void startEnable () { synchronized (activeLock) { if (active > 0) { try { activeLock.wait (); while (active > 0) { // This may be a spurious wakeup. More likely, this is a properly // notified wakeup that has been raced to the 'activelock' monitor // by another thread (quite possibly the notifying one) that has // (re-)acquired it and set 'active' greater than zero. We have // not instrumented the code to tell the difference. Either way: activeLock.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException (e.toString ()); } } if (active != 0) { throw new JCSP_InternalError ( "\n*** AltingBarrier enable sequence starting " + "with 'active' count not equal to zero: " + active ); } active = 1; } } /* Invoked at finish of an unsuccessful enable sequence involving a barrier. */ static void finishEnable () { synchronized (activeLock) { if (active != 1) { throw new JCSP_InternalError ( "\n*** AltingBarrier enable sequence finished " + "with 'active' count not equal to one: " + active ); } active = 0; activeLock.notify (); } } /* * Invoked by a successful barrier enable. * * @param n The number of processes being released to start their disable sequences. */ static void startDisable (int n) { if (n <= 0) { throw new JCSP_InternalError ( "\n*** attempt to start " + n + " disable sequences!" ); } synchronized (activeLock) { // not necessary ... ? if (active != 1) { throw new JCSP_InternalError ( "\n*** completed AltingBarrier found in ALT sequence " + "with 'active' count not equal to one: " + active ); } active = n; } } /* Invoked at finish of a disable sequence selecting a barrier. */ static void finishDisable () { synchronized (activeLock) { if (active < 1) { throw new JCSP_InternalError ( "\n*** AltingBarrier disable sequence finished " + "with 'active' count less than one: " + active ); } active--; if (active == 0) { activeLock.notify (); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableOne2AnyChannelImpl.java0000644000000000000000000000417611113671251022336 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class PoisonableOne2AnyChannelImpl extends One2AnyImpl { PoisonableOne2AnyChannelImpl(int _immunity) { super(new PoisonableOne2OneChannelImpl(_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BasicOne2OneChannelSymmetric.java0000644000000000000000000000423511105701167022326 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; class BasicOne2OneChannelSymmetric implements One2OneChannelSymmetric { private final AltingBarrier[] ab = AltingBarrier.create (2); private final One2OneChannel c = Channel.one2one(); public AltingChannelInput in () { return new AltingChannelInputSymmetricImpl (ab[0], c.in()); } public AltingChannelOutput out (){ return new AltingChannelOutputSymmetricImpl (ab[1], c.out()); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelOutputIntSymmetricImpl.java0000644000000000000000000000504711105701167024055 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; class AltingChannelOutputIntSymmetricImpl extends AltingChannelOutputInt implements MultiwaySynchronisation { private final AltingBarrier ab; private final ChannelOutputInt out; private boolean syncDone = false; public AltingChannelOutputIntSymmetricImpl ( AltingBarrier ab, ChannelOutputInt out) { this.ab = ab; this.out = out; } boolean enable (Alternative alt) { syncDone = ab.enable (alt); return syncDone; } boolean disable () { syncDone = ab.disable (); return syncDone; } public void write (int i) { if (!syncDone) ab.sync (); syncDone = false; out.write (i); } public boolean pending () { syncDone = ab.poll (10); return syncDone; } public void poison(int strength) { out.poison(strength); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneChannelInt.java0000644000000000000000000001331711113671251020150 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines an interface for an any-to-one integer channel, * safe for use by many writers and one reader. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Channels may be {@link Channel#any2oneInt() synchronising}, * {@link Channel#any2oneInt(org.jcsp.util.ints.ChannelDataStoreInt) buffered}, * {@link Channel#any2oneInt(int) poisonable} * or {@link Channel#any2oneInt(org.jcsp.util.ints.ChannelDataStoreInt,int) both} * (i.e. buffered and poisonable). *

*

Description

* Any2OneChannelInt is an interface for an integer channel which * is safe for use by many writing processes but only one reader. * Writing processes compete with each other to use the channel. * Only the reader and one writer will * actually be using the channel at any one time. This is managed by the * channel – user processes just read from or write to it. *

*

* Please note that this is a safely shared channel and not a message gatherer. * Currently, gathering has to be managed by writing an active process. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

*

* The default semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

*

* The static methods of {@link Channel} construct channels with * either the default semantics or with buffering to user-specified capacity * and a range of blocking/overwriting policies. * Various buffering plugins are given in the org.jcsp.util package, but * careful users may write their own. *

*

* The {@link Channel} methods also provide for the construction of * {@link Poisonable} channels and for arrays of channels. * *

Implementation Note and Caution

* Fair servicing of writers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * any-1 channels. * * @see org.jcsp.lang.Channel * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.One2OneChannelInt * @see org.jcsp.lang.One2AnyChannelInt * @see org.jcsp.lang.Any2AnyChannelInt * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin and P.H. Welch */ public interface Any2OneChannelInt { /** * Returns the input end of the channel. */ public AltingChannelInputInt in(); /** * Returns the output end of the channel. */ public SharedChannelOutputInt out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedChannelIntFactory.java0000644000000000000000000000700611105701167021746 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.*; /** * Defines an interface for a factory that can create integer carrying channels with * user-definable buffering semantics. * * @author Quickstone Technologies Limited * * @deprecated These channel factories are deprecated in favour of the new one2one() methods in the Channel class. */ public interface BufferedChannelIntFactory { /** * Creates a new One2One channel with the given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public One2OneChannelInt createOne2One(ChannelDataStoreInt buffer); /** * Creates a new Any2One channel with the given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public Any2OneChannelInt createAny2One(ChannelDataStoreInt buffer); /** * Creates a new One2Any channel with the given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public One2AnyChannelInt createOne2Any(ChannelDataStoreInt buffer); /** * Creates a new Any2Any channel with the given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public Any2AnyChannelInt createAny2Any(ChannelDataStoreInt buffer); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneConnection.java0000644000000000000000000000566611105701167020235 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

* Defines an interface for a connection that can be shared * by multiple concurrent clients but used by * a single server. The server end of the connection can be * used as a guard in an Alternative. *

* * @author Quickstone Technologies Limited */ public interface Any2OneConnection extends ConnectionWithSharedAltingClient { /** * Returns a client end of the connection. This may only be * safely used by a single process but further calls will * return new clients which may be used by other processes. * * @return a new SharedAltingConnectionClient object. */ public SharedAltingConnectionClient client(); /** * Returns the server end of the connection. * * @return the instance of the AltingConnectionServer. */ public AltingConnectionServer server(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelInputImpl.java0000644000000000000000000000474711113671251020152 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class ChannelInputImpl implements ChannelInput { private ChannelInternals channel; private int immunity; ChannelInputImpl(ChannelInternals _channel, int _immunity) { channel = _channel; immunity = _immunity; } public void endRead() { channel.endRead(); } public Object read() { return channel.read(); } public Object startRead() { return channel.startRead(); } public void poison(int strength) { if (strength > immunity) { channel.readerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyChannel.java0000644000000000000000000001355611113671251017510 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for an any-to-any Object channel, * safe for use by many writers and many readers. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Channels may be {@link Channel#any2any() synchronising}, * {@link Channel#any2any(org.jcsp.util.ChannelDataStore) buffered}, * {@link Channel#any2any(int) poisonable} * or {@link Channel#any2any(org.jcsp.util.ChannelDataStore,int) both} * (i.e. buffered and poisonable). *

*

Description

* Any2AnyChannel is an interface for a channel which * is safe for use by many reading and writing processes. Reading processes * compete with each other to use the channel. Writing processes compete * with each other to use the channel. Only one reader and one writer will * actually be using the channel at any one time. This is managed by the * channel – user processes just read from or write to it. *

*

* Please note that this is a safely shared channel and not * a broadcaster or message gatherer. Currently, broadcasting or gathering has to be managed by * writing active processes (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example of broadcasting). *

*

* All reading processes and writing processes commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

*

* The default semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. A reading process must wait * for a matching writer and vice-versa. *

*

* The static methods of {@link Channel} construct channels with * either the default semantics or with buffering to user-specified capacity * and a range of blocking/overwriting policies. * Various buffering plugins are given in the org.jcsp.util package, but * careful users may write their own. *

*

* The {@link Channel} methods also provide for the construction of * {@link Poisonable} channels and for arrays of channels. * *

Implementation Note and Caution

* Fair servicing of readers and writers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * any-any channels. * * @see org.jcsp.lang.Channel * @see org.jcsp.lang.One2OneChannel * @see org.jcsp.lang.Any2OneChannel * @see org.jcsp.lang.One2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin and P.H. Welch */ public interface Any2AnyChannel { /** * Returns the input end of the channel. */ public SharedChannelInput in(); /** * Returns the output end of the channel. */ public SharedChannelOutput out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionFactory.java0000644000000000000000000000622011105701167020354 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

* Defines an interface for a factory than can create connections. *

* * @author Quickstone Technologies Limited */ public interface ConnectionFactory { /** * Constructs and returns an implementation of * One2OneConnection. * * @return the constructed One2OneConnection object. */ public One2OneConnection createOne2One(); /** * Constructs and returns an implementation of * Any2OneConnection. * * @return the constructed Any2OneConnection object. */ public Any2OneConnection createAny2One(); /** * Constructs and returns an implementation of * One2AnyConnection. * * @return the constructed One2AnyConnection object. */ public One2AnyConnection createOne2Any(); /** * Constructs and returns an implementation of * Any2AnyConnection. * * @return the constructed Any2AnyConnection object. */ public Any2AnyConnection createAny2Any(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelInput.java0000644000000000000000000001704511113671251017323 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for reading from an Object channel. *

* A reading-end, conforming to this interface, * is obtained from a channel by invoking its in() method. *

Description

* ChannelInput defines the interface for reading from object channels. * The interface contains three methods: * {@link #read read}, {@link #startRead startRead} and * {@link #endRead endRead}. * The {@link #read read} and {@link #startRead startRead} * methods block until an Object has been written * to the channel by a process at the other end. If an Object has * already been written when this method is called, the method will return * without blocking. Either way, the methods return the Object * sent down the channel. *

* When a {@link #read read} completes, the matching * {@link ChannelOutput#write write} method (invoked by * the writing process) also completes. * When a {@link #startRead startRead} completes, the matching * {@link ChannelOutput#write write} method does not complete * until the reader process invokes an {@link #endRead endRead}. * Actions performed by the reader in between a {@link #startRead startRead} * and {@link #endRead endRead} make up an extended rendezvous. * *

* ChannelInput variables are used to hold channels * that are going to be used only for input by the declaring process. * This is a security matter -- by declaring a ChannelInput * interface, any attempt to output to the channel will generate * a compile-time error. For example, the following code fragment will * not compile: * *

 * void doWrite (ChannelInput c, Object o) {
 *   c.write (o);   // illegal
 * }
 * 
* * When configuring a CSProcess with input channels, they should * be declared as ChannelInput (or, if we wish to be able to make * choices between events, as AltingChannelInput) * variables. The actual channel passed, * of course, may belong to any channel class that implements * ChannelInput (or AltingChannelInput). *

* The Object returned can be cast into the actual * class the reader process expects. If the reader can handle more than one * class of Object (similar to tagged protocols * in occam), checks should be made before casting. *

Examples

*

Discard data

*
 * void doRead (ChannelInput c) {
 *   c.read ();                       // clear the channel
 * }
 * 
*

Cast data to expected type

*
 * void doRead (ChannelInput c) {
 *   Boolean b = (Boolean) c.read();  // will cause a ClassCastException
 *                                    // if read does not return a Boolean
 *   ...  etc.
 * }
 * 
*

Cast data after checking type

*
 * void doRead (ChannelInput c) {
 *   Object o = c.read ();
 *   if (o instanceof Boolean) {
 *     System.out.println ("Boolean: " + (Boolean) o);
 *   }
 *   else if (o instanceof Integer) {
 *     System.out.println ("Integer: " + (Integer) o);
 *   }
 *   else {
 *     System.out.println ("Unexpected Class: " + o);
 *   }
 * }
 * 
* * @see org.jcsp.lang.AltingChannelInput * @see org.jcsp.lang.SharedChannelInput * @see org.jcsp.lang.ChannelOutput * @author P.D. Austin and P.H. Welch and N.C.C.Brown */ public interface ChannelInput extends Poisonable { /** * Read an Object from the channel. * * @return the object read from the channel */ public Object read(); /** * Begin an extended rendezvous read from the channel. * An extended rendezvous is not completed until the reader * has completed its extended action. This method starts * an extended rendezvous. When a writer to this channel * writes, this method returns what was sent immediately. * The extended rendezvous continues with reader actions * until the reader invokes {@link #endRead endRead}. * Only then will the writer be released (from its * {@link ChannelOutput#write write} method). * The writer is unaware of the extended nature of the communication. *

*

* The reader process must call {@link #endRead endRead} * at some point after this function, otherwise the writer will not * be freed and deadlock will probably follow. *

*

* The reader process may perform any actions between calling * {@link #startRead startRead} and * {@link #endRead endRead}, including communications * on other channels. Further communications on this channel, of course, * should not be made. *

*

* An extended rendezvous may be started after the channel's Guard * has been selected by an {@link Alternative} (i.e. * {@link #startRead startRead} instead of * {@link #read read}). * * @return The object read from the channel */ public Object startRead(); /** * End an extended rendezvous. * It must be invoked once (and only once) following * a {@link #startRead startRead}. */ public void endRead(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelIntArrayFactory.java0000644000000000000000000000651611105701167021307 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a factory that can create arrays of channels carrying integers. * * @author Quickstone Technologies Limited * * @deprecated These channel factories are deprecated in favour of the new one2one() methods in the Channel class. */ public interface ChannelIntArrayFactory { /** * Creates a populated array of n One2One channels. * * @param n the size of the array. * @return the created array of channels. */ public One2OneChannelInt[] createOne2One(int n); /** * Creates a populated array of n Any2One channels. * * @param n the size of the array. * @return the created array of channels. */ public Any2OneChannelInt[] createAny2One(int n); /** * Creates a populated array of n One2Any channels. * * @param n the size of the array. * @return the created array of channels. */ public One2AnyChannelInt[] createOne2Any(int n); /** * Creates a populated array of n Any2Any channels. * * @param n the size of the array. * @return the created array of channels. */ public Any2AnyChannelInt[] createAny2Any(int n); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelInputInt.java0000644000000000000000000001524711113671251020000 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for reading from object channels. *

* A reading-end, conforming to this interface, * is obtained from a channel by invoking its in() method. *

Description

* ChannelInput defines the interface for reading from object channels. * The interface contains three methods: * {@link #read read}, {@link #startRead startRead} and * {@link #endRead endRead}. * The {@link #read read} and {@link #startRead startRead} * methods block until an Object has been written * to the channel by a process at the other end. If an Object has * already been written when this method is called, the method will return * without blocking. Either way, the methods return the Object * sent down the channel. *

* When a {@link #read read} completes, the matching * {@link ChannelOutputInt#write write} method (invoked by * the writing process) also completes. * When a {@link #startRead startRead} completes, the matching * {@link ChannelOutputInt#write write} method does not complete * until the reader process invokes an {@link #endRead endRead}. * Actions performed by the reader in between a {@link #startRead startRead} * and {@link #endRead endRead} make up an extended rendezvous. * *

* ChannelInputInt variables are used to hold integer channels * that are going to be used only for input by the declaring process. * This is a security matter -- by declaring a ChannelInputInt * interface, any attempt to output to the channel will generate * a compile-time error. For example, the following code fragment will * not compile: * *

 * void doWrite (ChannelInputInt c, int i) {
 *   c.write (i);   // illegal
 * }
 * 
* * When configuring a CSProcess with input integer channels, they should * be declared as ChannelInputInt (or, if we wish to be able to make * choices between events, as AltingChannelInputInt) * variables. The actual channel passed, * of course, may belong to any channel class that implements * ChannelInputInt (or AltingChannelInputInt). *

Example

*

Discard data

*
 * void doRead (ChannelInputInt c) {
 *   c.read ();                       // clear the channel
 * }
 * 
* * @see org.jcsp.lang.AltingChannelInputInt * @see org.jcsp.lang.SharedChannelInputInt * @see org.jcsp.lang.ChannelOutputInt * @author P.D. Austin and P.H. Welch and N.C.C.Brown */ public interface ChannelInputInt extends Poisonable { /** * Read an int from the channel. * * @return the integer read from the channel */ public int read(); /** * Begin an extended rendezvous read from the channel. * An extended rendezvous is not completed until the reader * has completed its extended action. This method starts * an extended rendezvous. When a writer to this channel * writes, this method returns what was sent immediately. * The extended rendezvous continues with reader actions * until the reader invokes {@link #endRead endRead}. * Only then will the writer be released (from its * {@link ChannelOutputInt#write write} method). * The writer is unaware of the extended nature of the communication. *

*

* The reader process must call {@link #endRead endRead} * at some point after this function, otherwise the writer will not * be freed and deadlock will probably follow. *

*

* The reader process may perform any actions between calling * {@link #startRead startRead} and * {@link #endRead endRead}, including communications * on other channels. Further communications on this channel, of course, * should not be made. *

*

* An extended rendezvous may be started after the channel's Guard * has been selected by an {@link Alternative} (i.e. * {@link #startRead startRead} instead of * {@link #read read}). * * @return The object read from the channel */ public int startRead(); /** * End an extended rendezvous. * It must be invoked once (and only once) following * a {@link #startRead startRead}. */ public void endRead(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneChannelSymmetricInt.java0000644000000000000000000000766511113671251022050 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for a symmetric one-to-one integer channel. * The symmetry relates to the use of its channel ends as {@link Guard guards} * in an {@link Alternative}: both ends may be so used. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Only fully {@link Channel#one2oneSymmetricInt() synchronising} channels are currently supported. *

Description

* One2OneChannelImpl is an interface for a symmetric one-to-one object channel. * Multiple readers or multiple writers are not allowed. *

* Both the reading and writing processes may {@link Alternative ALT} on this channel. *

*

* The semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

*

* These channels may be constructed by the {@link Channel#one2oneSymmetricInt()}. * Channel poisoning and buffering are not currently supported for these channels. *

* * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.One2OneChannel * * @author P.H. Welch * @author N.C.C. Brown */ public interface One2OneChannelSymmetricInt { /** * Returns the input channel end. */ public AltingChannelInputInt in (); /** * Returns the output channel end. */ public AltingChannelOutputInt out (); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyChannelIntImpl.java0000644000000000000000000001126311105701167020771 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements a one-to-any integer channel, * safe for use by one writer and many readers. *

Description

* One2AnyChannelIntImpl is an implementation of a channel which is safe * for use by many reading processes but only one writer. Reading processes * compete with each other to use the channel. Only one reader and the writer will * actually be using the channel at any one time. This is taken care of by * One2AnyChannelIntImpl -- user processes just read from or write to it. *

* Please note that this is a safely shared channel and not * a broadcaster. Currently, broadcasting has to be managed by * writing active processes (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example). *

* All reading processes and the writing process commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

* The default semantics of the channel is that of CSP -- i.e. it is * zero-buffered and fully synchronised. A reading process must wait * for the matching writer and vice-versa. *

* A factory pattern is used to create channel instances. The create methods of {@link Channel} * allow creation of channels, arrays of channels and channels with varying semantics such as * buffering with a user-defined capacity or overwriting with various policies. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * *

Implementation Note and Caution

* Fair servicing of readers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * 1-any channels. * * @see org.jcsp.lang.One2OneChannelIntImpl * @see org.jcsp.lang.Any2OneChannelIntImpl * @see org.jcsp.lang.Any2AnyChannelIntImpl * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin and P.H. Welch */ class One2AnyChannelIntImpl extends One2AnyIntImpl { One2AnyChannelIntImpl() { super(new One2OneChannelIntImpl()); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelInputIntImpl.java0000644000000000000000000000532511113671251021755 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class AltingChannelInputIntImpl extends AltingChannelInputInt { private ChannelInternalsInt channel; private int immunity; AltingChannelInputIntImpl(ChannelInternalsInt _channel, int _immunity) { channel = _channel; immunity = _immunity; } public boolean pending() { return channel.readerPending(); } boolean disable() { return channel.readerDisable(); } boolean enable(Alternative alt) { return channel.readerEnable(alt); } public void endRead() { channel.endRead(); } public int read() { return channel.read(); } public int startRead() { return channel.startRead(); } public void poison(int strength) { if (strength > immunity) { channel.readerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableBufferedAny2OneChannelInt.java0000644000000000000000000000435111113671251023625 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.ChannelDataStoreInt; class PoisonableBufferedAny2OneChannelInt extends Any2OneIntImpl { PoisonableBufferedAny2OneChannelInt(ChannelDataStoreInt _data, int _immunity) { super(new PoisonableBufferedOne2OneChannelInt(_data,_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneChannelInt.java0000644000000000000000000001121011113671251020130 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for a one-to-one integer channel. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Channels may be {@link Channel#one2oneInt() synchronising}, * {@link Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt) buffered}, * {@link Channel#one2oneInt(int) poisonable} * or {@link Channel#one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt,int) both} * (i.e. buffered and poisonable). *

*

Description

* One2OneChannelInt is an interface for a one-to-one integer channel. Multiple * readers or multiple writers are not allowed – these are catered for * by {@link Any2OneChannelInt}, * {@link One2AnyChannelInt} or * {@link Any2AnyChannelInt}. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

*

* The default semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

*

* The static methods of {@link Channel} construct channels with * either the default semantics or with buffering to user-specified capacity * and a range of blocking/overwriting policies. * Various buffering plugins are given in the org.jcsp.util package, but * careful users may write their own. *

*

* The {@link Channel} methods also provide for the construction of * {@link Poisonable} channels and for arrays of channels. * * @see org.jcsp.lang.Channel * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.Any2OneChannelInt * @see org.jcsp.lang.One2AnyChannelInt * @see org.jcsp.lang.Any2AnyChannelInt * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin * @author P.H. Welch */ public interface One2OneChannelInt { /** * Returns the input end of the channel. */ public AltingChannelInputInt in(); /** * Returns the output end of the channel. */ public ChannelOutputInt out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/0000755000000000000000000000000011410045045015722 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Any2OneCallChannel3.gif0000644000000000000000000001211710520670125022042 0ustar GIF89a¤Ô÷  $$$(((,,,000444888<<<@@@HHHLLLPPPUUUYYY]]]aaaeeeiiimmmqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,¤ÔÿcH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“"mñ¡ƒÓ§P£JJµêT.”jÝʵ§ ¬ŠKV*†*ºª]Ë–åƒ6?hhK·®]Žnžxp·¯ß¿ óÚÜ ¸°á¿‚k≯±ÚÄ4;žL¹(ä™’+kÞ¼ó²ÌÌœC‹Žé9&èÑGÀºµë×°cËž-»A ‰., Í»·oØ8L<‘à·ñã²À%YæiÔ[`Q…‰4À é‚ˆˆ0Üÿ¦™âÀö‘Í_>‡.Ѓp› PDL¶¦ GP¸ù–¹^¾ìäË=4Ý`>‚ú‡`€vÐ D*– C N(Rz¥0^ +¬àЇ­ÇÞ€6õG!uF”aІÄ!A" €Üæ€ ¥‰ ™Š5©h ‹‘]ØÐ‹EÆÒŒ€-œ€;öø#DB¢F$MF:Ta’.2£ƒ m€À@)ˆ˜e ظ@j^Ù‚)Ô(BC]ŽöåLa64&fJ2Ä$˜N~e ¬YP–qžPH B làãÌÉg¡þ)S  ú¨  h¢-Úè@/ÿ”%¥²:à£ùhc %¢z¢„g®ø DªŽÊjG‹‚Àr`É#žîx«@%¬àc³ô ¡A¢ÆDêB¦šæ+BÅz{,^Ùè2Ê£ˆà"¬0eàY²Ÿn[P·0}«P¸Î{P¹Ÿ»Ñ¢1´¯­Y`æ;~C ;2¸‚"Jܯ¿ü’À ¬žÁ!<²Â1œRŸ¢‰<ЭWBˆ”o"ç+Iúÿ4sAM+N/ÀØé稦 `Côg„„­V}cÐåú¶µæ ƒ b Ò¨¤ NKŒ¼˜¸öíÉ…9* eX¦‰¤ QÐËãòÐÇ¢‰L„ÝJ¨8¬ìU„Wù¡D‚H’!VF“*ád‹Š¦!Åd¨L‰*1éÉ&]’P´ Õ‘ý½l†£[þh¾Wú+–(™%.Y¬ s[È<‰2OÕÈf†D#°‰¶–É]®ª—,X5m9$`H§:×ÉÎvºóðtg•n¶RPá<Ù8yYÿ’øàŸ ¨@JЂt õÉe4M2Mqíó›¹<ÌBKÒPq2“œ-ÌDIRQ}^”ŸÌFGÒQ—ˆ1æ ©F½i,pvÒs÷T©]FÊ5búònÀˆ07IL™"E?7¡ODâc B ¸É€äSº„§RªT§:P äT§ U·ÊU‚Ž@9YT»JV®r ©Mõ 8϶®³p«\àzF„˜k[ ½Æ“=m[ý OžuMkYp¥X J!¥b}ÊXÇB6)’¬J+›”ÇFV³ eg‘âY̆ö´íQJ‹”Ì¢Vjª5 kâÚ×ÿú+¶E™­Qjk[á–(ºµLomûÛ¡—(¼.tŠ+”ã%¹Ê sƒâ\¡@7º¡™.Pª”ëbw3Úý wâÝïV&¼>ïOÊkÞÉ ·'êõ {ÛÛ˜÷ò$¾=™/}cßà—'úÝoaú«“ÿvƶ#(‹‚Ìà[E>)!pN ¬“ï¤R$Q(àà{øÃTi@Îc ã„Â9±°Nh5 X 0øJL|ãDÅ ±ÖxB”«XݦM ÑB) ƒˆ©¹)WvºÛÄÆ7Á±G浈ˆRºë[%5¢ä­0Y#N® ”m"åŽ4ÊÿC:’–·6¯!à-|ðN`¯À‚+Ÿu9sFÒL“5פÍ©Žô&,ÿøG<äbÕô‘2kEÐ!ôL MDoä‰)àÔ#yÔ,ï)‡¯²2­h橎XZ)˜¾ˆ¦eÂé™xZ# „—Ã:%=ëáHMXR!»G«RO¯Ò€¦K¬-2ë˜ÔZ&·Öˆí<À¹Þéð>*Aïj%/)bØÊÈ6̲+Òl˜<›4j‰!¸ rN½ØÕÉn˸)Rî—œ&Ñ&Éæâ1ƒ€Àt!yuRæ=‘z»äÞ/Éw_Ž‚KÄà-A¸K~†Åá8K$ÞŠÛÅâFÁ8D4¾޳Äãÿ±kC`@b‘€¼("ÉUbò• <#.èZ²€´<Ü…‰¹Cfž’š«äæÉ9ÀÒ…pðyÀãÍ¡7„è(1zJ>¥·ÆùiMÔNfª¯E˜,1T2@µ»Ýí ˆÀÛçîa¦ÓýîU¡Øn\Ãá_à58Àî^³«ít¯ÞO– l€ñ¯Šâ#Ïx½¿¦ï þ»k?xº^Ü(ð¶¼Î°Cdb—ºG^N«‹¾0^oºBž>ö©ƒþõ*ÍùÎÒs²Ãûö¸Ï=DX^ÖÅõÁǽñ…‚üä‹~ùAi¾ó÷ } Húí­þO®ýïjß'Üï~ÿt¿ß“ð‹¸äç‰ùÏoÛôïdýìGíò­Jõ‡>þøñ¥Ç=‡¬`Ì(ù§Y¬'ŒÃ){©¶8€ŠÅzî%d#°Dð‚fÄkR'ž‚4{r+(EÑ€ØT/ç#ÜÄ&ÀF¶—ÒFoV#Ø/º@ ä‚¥ÖCA‚%(S'<‘;ZÖ;Ž’%¯/DxD(/E¨ƒÁƒ=R4¥&$¥F„Xt„9â!+4R6M¨P…JïV|†·Õ:·RÊ¢…V†„ûz¢&% &i´nQ†fˆMƒÆ'28 ƒ9ë"<@ã1Î;Òÿ1;Â8¤£F÷÷Pø^8wJ)ðø!Ÿ¸cFvd@~x‰/'Z6'n/}c#WR²1<Â)C¨FWâe¿t•ˆŠlAI+€m}3'ÓBIÄ<Î’…±³öÂ8¸î§§è‹,¡&8Bm8‚9^Æb5"4{²#1¤,‚³€e|ÔØOtq2Œ s,Ö7©¶#ö²'¶#%pñD»hнxŽ\q%ó.ÐÒFïÈ)fb„/Ù²#jÒjåÈ‹üØ ÄBa;óm ã „†)Bé ÈјÓø¢’81’$É&y(™’š±’6Ñ’.I0Y29“wÿÃ%&Q“4q“8YJéäC¢äRù“u±¬!cñ¬1”b²†K¶FiHÙ$%­á”fŽ ‡Op_9–d9W Àe™–j¹–„ÕÀ–êÔK÷@vy—xI w9ÀÑp©N•f¶0PV5€˜ŒÙ˜Qà˜’9™”9U°• P—ù1öžù™ ùð™œâ=—™e„yiRÙdÕY— ¦Ô+­AAYégøÄ•$u'¡u\1›”Z¹›EYb¯IZ±ÉÂÉ%ûñ€¥†¼9¾iÀ¹щ<9 ˜%ÿ±ZÑGñ2žÍ¹ZÏ æièêiYÛòžEŸ01Ÿ°YŸWÅøùúéœüyÿéÊžjÚ*[í‰öI Ê š[::Ê€­‰fëé  Zª \**#š%j\')+€:hj¡! Bµœ%!ž$AžJ£@ÑÅ .¶y>:@šBúÝR:¥TŠÁa7j¢9:•,±¤"ѤHñ¤\:rYê¢[:¦XJŸ"¦hzueÚ\/ÊlÚ¦ á¥!¦G1§tšv xJ•ý¹§6ª¦²¨‚*koJ]qºzÿz¨ѧñ§EѨŽ:ê’J”Z©1p©‘©C±©•ꩪB!ªŽJªaªAª‡ªªÁª@᪂ «!«?A«{j««>¡«tÊ«á«=¬øwP¥ÊJ°š0À°¬Òú†4A 0­Ú €*ç‹Òazà¹áP1Á¤5‘ a2€—EZD;J÷q‚3ð4…36µš@Yc‹zr+{+C”´Th ks S[¹Jj6±GW±Ö¤œ»i»u‹QOùR e# R%‹±‹²üX° QR-a¬6²(ÿÁu>³¡t°&Kk6{8+S:ë2Ë4›ÄJA«RCÛE»G‹I;KRMËO«Q{S+U›Qu:¿#E‡' °osó ±1C:n›-“¨[kÕ…9C9Q¶ñµ5QZ¦<üR¶ŽæFÛ!@ø>¤s;¸’s[Õu#@s#Nxz[L/ë° ±€«ƒ›¶…k(èAp£¸‰‘1€†høm ‚Ѹüö¢¹(‹5#òb1Z£C¹%½ó‘Á· …¹d´Aº&i›:j‹>²BëHºGÁf:Y2ad¨? »kD1Yò0mDeì ´ÿ'ð’/SÂ. ¼ö$ Iœ»5ÇkIÂ’º²# ä¼vt'ë˜j6HiÕ«° A)”’)òH/ ƒ¶ƒ¼2+ظ'ÿO4)kè+G‹ ¨À\¤n>”¼†ËMöû>À–¿¨Àû30`±ÉZ*œÂ,<+üºÿ».ràÈ74†ÇK‹H¨ K|©–ƒÆëkH6BŸ[¡û>ì>º36ðrlýûd°ë‘8â.Ê(%LˆE”¢Œ`9vôŽÑÃÇôáe]FlîKÄ„¿Ê{¸¼C5³&c#%‹›®ëÂS,ÄYb‹Æx3Ì.«(âÓ(\b Md\:ÿæ!lâc>VEÛ‰á‰1@É–<@v<&ÊÈHR,¿>&"›¬c“¼c""ÉGÆ9Ö"œó») QG2ž»r@>ë²çxµ‘µQØÓ²löÊ-ÅÆË”±¶L¸¬ºŒSþûË—k±ƒ°#qÇó³&qÈ¡’ÈÉÄÁÔôÉÌ|ËØ,MÚìPÜ|hÀœR¼ÍÄÜÍÆüÍ Î•ÎäÜÌ[*Ð,Ò¬FÔ\Ö ÇœÉÜ:Öˤù|K¨ØÏñÏèÐ_:ÐèQÎ sÄïìËñ|ŽöT åùJFUÿjûá¨)™°{ñ`#ݘØ*®4!#°Òis4ñ*`¹–ð­9–àÒÕA?–à{œšÔJ½ÔLÝÔNýÔPÕR=ÕT;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Any2AnyCallChannel2.gif0000644000000000000000000001772310520670125022057 0ustar GIF89a¤<÷  $$$(((,,,000444888<<<@@@HHHLLLPPPYYY]]]aaaeeeiiimmmqqquuuyyy}}}………‘‘‘•••¡¡¡¥¥¥®®®²²²¶¶¶ººº¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,¤<ÿcH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ•(6(]Ê´©Ó§P£BUAÑÅ©X³ju †Î[Ê}Ê¡…ÇcÓŽí`ö¨Ä ÔÊÝŠ€ƒD,ÌÝ•‚¶5a(xÀ·pS DlÁ°ã »…ˆ‚M;Œ0Âf 7EH°©ÁFѤMOv¨ô¦ƒ °°yÂÁM n؈[÷jÖ\Æ(›¶m›½mîÖ˜¼æòß [Û|{vÍÚ·s+ç­Ý9t†ÒkRÿ'n&väÝi>ÇØ\ý÷èÁ§Xüúñšíg®¿˜_æþ÷…GÓxô•7Óyø¥§w¾ˆ€3èP}æÝGS1ýW†0iè` Ê$aCháL¾äáD)º´"€!Æ4"C%Ê„à… úÇàv#L3.TcL7¢˜c†;z×c€ñ‰7ß„Úx¢L-¶ôbDU²tåw?*”B ½æB)¬Q ¹P e” ­0¦CERy$™s®`&™{:´åCYº9§˜½ÑŸ¿uyP pÀ!ÄÀÁ 5p@g>Ib” eð(˜Æp€] ‘àh¤tNS …ðé`6ÿjB–ÎÚ¢ ʨ£JJiC£º$“]ºB Ф ADh&¤&BðA ®R *©ÔçCu®zçA'@A '\ƒ¬Í> ® j,²Ê2 ,·~K¢•;¡“Rð( Ø>¨ŽâËP´M{»`Öpp ÉB:©£… «1xꦙ²Öj–§Î"ìCð.”¥¿ü+Ê»:ð¶)¤|«¾ñKPµs Tí-X\ô/4@AÎ|ëÃ9lº]Ú¬ ðÕÊz4C¿²¥YzBº¸zBÎ!0íôÎÌ;Ð1;iÛ Lñ èÿ-°­ µ|”Ïsðµ½²†@$»-´šÒÈiBTÇðm°)þ(wÛ ®ªÁÀÁœ#nú@¥£~º@#<9ö¯– ñ¨sNñãï&™Ý?S ñ¤™ý)ªpóL¸@+@ª«+ Þ€âm‰ûCP$uAÉ~«ôãÁ_ú回§êP«Ç:ëåŸo~ù1€Œõp`:;oæÊ,ëŽPòËмï¡ò`³6Q) v œQŽ',ÎS˜r^Ñ(p‚íáïi‘ÒäR®4Üá +w­ y3ãø6$òL KÙ&/JÌ=2s±Õü¯-ÁiƒÎ$çBÙ¹lMÞŸóÃG~@D £‡éAQ:Gz¾B§2ÂG€µ"Ò±WýêÖ7ÂuHzg»Ø‘Ìg÷xÚߣôrÝýàOøÂþðˆO¼âÏøÆ;þñ¼ä/€½gí'μDX@¿S¹cwÖ¬óšOýC8?w¡>k=é5búŸ ^õ¸_nçÝÈ^$µ÷ÉísOü„°CW 40{j[:Ã/¾ô{üžDúØÇIõyrýì{&ÛßIÿ÷¿O~—„_'ã/¿úSrþœ¤ýð?úóçÌûøÛ_&íÇÉûïÏvÃvÿý€‘7€x€u'H jdÒˆ€(9¡8 €2ÍW†¶85ów#-PF'À9‘r‚)àf/°91°,e1n*8ƒÑ˜ƒ¼‚Á?‘9R4@à¶{+àjP4°5¦BF’*»§8¨ƒxr™sD)Ð$ÐfÊRidc/£Â.E¸‚[¸p…R8'W4î2-Fd;²#?”â@‚v@Hjö+dhfx†ørÉ&X“‡/¨…q¸.”2)pÂnø‚vÿáò¾®#ÉScoâ@£"h#Y1d³i &€d2\|Á±›,!Ä_"v”‚9°‚ˆ©h3Ã4’™Ã1I ºq)°¡'Õ9&ÌÒÁÉb(ó,ÿ30LÂÔû½á)ŽŠ‹“4]©8DÃgÚ’kfc*WÉ><À¬49aä(ed)`"B) 0gc5Ò–4Kc.Ý8Ę1J(ìjs,Æ’pÌ"+WD°6c-²(‹+*ø׿!°{9é¼>ë¬> ñ_'ÐCêâËoL*´£…‰T¬¹³#0©=cü“Ð<3Êâ,ßkâö“¡Œ‹²ã.¦²i#Y.~‡Ðó=ô,’´½¢“>ÝÎìc|?Z„^$2ó,k$í.÷l?ú ż¹ËÛAô£ 9Æ}94XÓTA±LÈ”R;ÍÇ"8*ž¢7Ò–Å915­<3ä*„XiR¤¬ É/\+sÔ»(+Pt-Cp0HícE×Hb=»?»Tt0Z9DfRR4EUä‹b¤G}Õí뤭¶=!³=õÓ@8Hr¤Gsýة̪ÇÙ !¾žtË0á¾dí$ -»¢ý¤íÒµ¾(å«ÝÏVÌ íJ©í±}™ž½Ð®=S°¿#±Û™'ÜQÛ¾tÛ-‘ÛwIÜaÜÝ„Ü,¡Ü®;Û+áÜëÝ+!ÝÌKÝ*aÝ%ÿa¡ÝÖËÝ)áÝ$ÞF{Ìaë×¢\—¯ÝâýŽí-æ=è=\À-õM`ý}ß"‘ß1ßðKÞ(à!!à«·ß!ÑßýU—‘Áž?Ëž›p¡¶àuqya`·|áîð·wËâ|ñR7œIQUëãV±µ][]1,Àckâ{!¹Eë»ðê³õ[äѽ,’´ÐµÈäñ´?å(åXâä¿aåˆåAå>Áåè倢å«!æHææÔ—äJ¾\ ^q—êæoþÎqNrs^ç¸}ç,—çzÝ|NsÚúç€~䙇æýÿ§æ¹bæ Kç„^Š/Œþ°Žþèé.3é[é–¾¥îsƒÞéØúh¡.êØöé]Wê¦~¦†~bˆÎ˜®lÎXªqq‚Œ(¶^~±ž³¾¦Fµ¬p,݃cÜ>Þ†–šèÈØ×ëñë:qrô&Ý)¦I‚W1½Xš›9&Õ.*Ï’4³íyon"&c"'¼8ì'æì”¤éûœàÖiŽ’3vYws袉G§^:yõÀ̱ó}¾Ý;oËßž>ž®vór»§g?<|{øqËljžþËõ÷ÙOׯ~ÿìë/?Åã¯@øþëO@ýDp»LOAý¼ÏA ©‹0Cñ(¼ÏBú0ä°¹ GÜÎCú@ŒOD+±EêPŒOEøX„q·olNFøhlÏFeË1HãxlÏGö€$²µ!—ÜÍHöLOI'Ck²JÙ LOJó¨ÄR³+¿lMKó¸ÏK1M{/ÍâÈÏLñÐdó°0çìÌMñàüNN;ÁëS8<¿ÓÓ;>ÿÜ«NC' ÿÔ»A·+4Ѻ…t°E·k»G'•KRMûª»K«Ë´Ó·8%U¯O« •ºQO…ÉTWéJ•ºU£k5Ö–`ÅU¾¼2¬º[qÕu×·fî׿‚uXbc2:d•SÖUf›½«W £=nÚS«µ¶¥g›ÓÖ8nIõöÛp•·¸r;=×Út[W¸v5}·Ùx›w·z'½—Ø|‹Û·~!ýw×€…¸¶‚=F "ÒjbŠ+¶øbŠ%p¯²ÂøcC–ˆ€úꀑSVY«ãpV–9e‚kq„6ÆŽ øb@„íZPÀ-Çð »"àÐTØ.Xjñ¼ƒÿ!€½Z à» 6ØË‚¾€Czö޵ÑÞnl½F¬ë½(AlLíñ®Žm»Ü> n½ä¦;C»Ó;Ããã;Ò5«Ü.Á½[ÁÂKüÁË››<±Æ©{¼®È×®[ì2/Ðôã6ß´óè>§+tìTï¯ò¾PïÏöâd‡ËïÁ\Ÿ ö½Gÿ÷ûˆßM÷RY‡Îw¹€§yúhçËøø¨¯ ú˜xŒù¸œW\ø³mÎ[üàÛV¾9îáò:ì$½:ëÛ‹?¶ö_Ò>°ôßZ_sð·›?½ÿµ¦~.¹__ò'“ý)g€zu8ê¥àh@(“à‚qY` $ÿ Vs ÁV—Æ$1‘ -H— n.™&HÁ¬àwÜËÅAD€€ [ò˜¼`/”T9À žð-$š]R“Âä1B$¢c€D%ê…†òbL&øDÊåС^|8<òÉå1‰AWЀ 4@‡h@ï=.ñPç›âZB¤€ˆ@^HPÁÆP`‚e„É_’ŗ̱%vÄc ùèDzvãwlØ€–dÀÈcؠ؀F›ã(! f c‰ÀcðXÇp@’- bÂHÊAî%ƒ)8A(ÿ˜ ’Xã&XK+ÿz-ps³ËctÉK_f˜Â<1`LAŽ’/¡` JhÈ êR• " ¨[ÆåásÌ,'¨´ÇH& - æcªˆLó)ÓŸAQéÐT²‚|±¤K0é’ÇÜ (G ʃòe,p™KJRžT¥)ei®J*«uºäþl€[ÖHPqB4˜ÓË'‚€HÇ#&ò‹BAA‰*Ædê%ƒ0™(Dc@M§ê¥¢-¹hP:T·„´¨ =*BAÇÍ€¬bu YÁ5V´–5­v9%LvºÕM¢ò­¶„ÑO3IT ÆàÕ*RªTC¾¤©Ô€hAG Î2 h 0@G( @J<ýi<ÉoÁ@}ê“Xà¥vQPýj‡Œš>-Ьm­èì[»æu¯}ýk`[ØÃ&v±}ld'[ÙËfv³-š€;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Any2OneCallChannel2.gif0000644000000000000000000001131210520670125022035 0ustar GIF89a¤Ë÷ $$$(((,,,000444888<<<@@@HHHLLLPPPYYY]]]aaaiiimmmqqquuuyyy}}}………‘‘‘•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,¤Ëÿ_H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ•,J(]Ê´©Ó§P£BuQñ„Ô«X³:E±s…Ö¯`¡2hÓª]˶­Û·n |¨B¸xóêe‹À œÎîL¸­dk<¡€*Í?¬ÀÁæ… 7E<°iBâÏ5h¸é DD*l–pp“Â\›@Ë–(š´iˆ¨U³¶éúfìÙÀÖ¶Yútêš«[¿®ù;¸s„ÃkÇ}œfrÞËi6Î}`tšÓæÿF¾»foØÝÓ ü>3¼ÃñÖËÓ<Ï\}zö2Ý7„?óºùì3mg_pøÅ¤CüÉäß|Ê$à€³Ó %Ó‚3ѧ„ÏIø… Y†2i ‡Îyèˆ ‰ø‰1™è ŠŽÑ ˆ ÔBŽ D,"äbB+ø8Ð -,” Á“Œ á8P ?.däCÒ˜˜ŠÐ °P4ämâU×a æ `–Ð`Žé“/A™q€Xs&„f¡ e©åX\”f +DpÀ e.tyÐm€/Jv"Tf’ñé’Ÿ•^¥ÿù¡–b ‘¢‹Õè@®Þ¶#™P框`–Ú¦qZ­•°Âpì ’ŠY&˜©Ú«Áyä„:-œ—"[ç­¹‚¶«@ž2Iæ§+X[¯-4@Á —¢ê³9K¬Ž6°‚¤ ìÁ“Â)ïBÞ²î³fR¬ÔZ¿ ð‹¿‰¶ûÙ»óÊ[é¬ €HJj¦l¾ç¦¥…¢ºî ð[g™ œœª| }À£C=ÑG-ÒMLš¡ mÂnPæ¨ë²+ò–66”všÂÉ„ªÜ±”Y?0A$©ÔXc†3¿ àˆ¤Ï{ (ÿýÓû øà"äô@ßFšSo ¬Ý?¦í®[E2¶+é&Ù[‚¾/¯i\ªr¶ ±7ç çpRZñÏÊA¦ã+£,Pxf,fèXVNÖåd¢9ê \KÁ¨#:| ŠN]·’6@,¶ ¦ÐÀ‹KOüµ°cÑ Â6`çñ1¼øå7ß»ïGoÒÚµRÄ+®åì÷ä~Ið $?JôS‰ýR‚¿üíd$éß þw’¦d€() s‚À‘(&q J x Nð&Égv!½Å¨A1ñàkÂŒP7±CÏ -×5ðÄl?$‘ Ÿ„B˜¨p†2i!Hÿ^HžÖˆ?âGˆ#n‰>Q¢G˜ØŸö©‡/ù!]"ÅŽPQAV\]¢Å-²¤‹ùb x"3°†í¹!‚rø¢0~kŒ-)£S‚ƨQ‡lœÑs¢A“¸ÀÓ‚H W\à&MT`€Aê„&7ÉÉNzò“ %* ‘à¡L¥*WÙÉ €+69¤XIËZ~Ò!°¤NH`ËOZ`½ü¤ (²³“ €À19é¿ä$ËÜä ÍMÒQ—Ÿ¡db8¨¥Bb“FÚ$ 7iäÍor(œc'ŠÊiΡó(êä;Û©žw%žš'=»cÿÏ¢às@úÜçsúI”Ú'  A‡bPõ 4¡³Y¨Pšž‡B4 E»cÑ‹*&£@Ù(w:êQ²€ô'"}IKz”“ú$¥ÎY)K‹âÒžÀ482éPjÊ“›'§: OwâÓÙ5¨?ªNŠ*›£"µ'JÍ SAãTž  …ɪV·J˜ $ò$Q +WUŠ˜o$% €ÂÂÖ¶º,@$JÂÈ –u"’É"QÔÇ…ÐÕ{H”©¬6-4o%hAß6Ð<Ãöì6;k¬²4‚AÅDr®•çX·¶ÒªA­q8 –¬¾œŽT⢖G*›˜Ë‚5³éܬÈVŠ&Äÿ ´“ʼT1YÕék pU•8ÂZ²¸Ö$ýWšIÉÉv¤šÛ æ-Z­«XÜGŠ;–ã–$¹ Z®%²bí–V®ê؈—04%ÉZ/Sƶ{Íçx—$àÍlÛµR ÈIVž"TBû¥Q¡)LˆœÂôUâÖ×9÷I~K´ß\ÉtI<’’æ&%”)‘Hº÷:ÂÝ£DX$>¡xS"Ý@« ø’žVûààœ8$)æáŠQ¢X¶U˜1QtcäøŠ;æP‰RäYŒI†Ð’‹Òd<ùŽQД‰RåŽ\Yb^Ô]å¨<Œ¾D–äwa Ï0wsÿ¼Y œ ¢€œÙÁiÆì6ÝLÎ9Od5@e â)Ø9$[J—9òåúñy~î–h2+D”6ô/’h¡tÙ\e êR›z-èË©WÍêV«Ep5é@«z0 ¨5PW ÆÀé² Þú”ûØÈnб“Íìf;Û)Ëv6Pë„a™NBðì{6‹~ªhF>ä”>4š9nq{Ò¤„4-’N¥Ýî· â lz#ö ¾óMp[6/¸Â1ðŸ$|áŸHÃ}òðˆ[\fy¾¸ÆñÌn5oüã™xO*ò’/ðà ÿ!¹É?.rž¨|åoùN^s‹wz°BÖ Íkñ-ëìKˆR Z²sž+|Ë„JÒv7ÝLëWWBSŽ:,+A}¸)ºÑ >åzM¶^[š6œqëÀjJ‚GU&4­7#Zߺ»§Œ³ÉöØëž2ÍhÍä´ ‹€š„›w:½"q—ûS§üµR)ŽP`ãܬÌdÚÒZËX’lÅ^|‘Ä+>¨HŸ“«4¿À[móŒ3Sj‘-ÄHîÿ¼ɇ’-/}ìjBæ}ú۪ɿPûñN§{I¹Î÷ñ¼ìíCû“$šRg%b=`l;ýxl˜)ÕnÓ3¯¾@ûù1ÿì—¿(J1v =ÓSy»Tm â¬úki‹È\ç±'¿}U¦cÁéÿt’&€‚€²´")Âb` à_Óp(÷ʧ>‘&ku;˜2tÁ"Â2+ÇB(Àõ}¦¡]!(<‘ n€‰šØ…œØ‰…8‰™Va™fŠëf‚ƒhvºv‹¸˜‹º¸‹¼Ø‹¾ø‹ÀŒÂ8ŒÄXŒÆxŒÈ˜ŒXg'x&@&O‘æ+pЊa‹ °†lè…øÅf÷ù4Q×¹ô!hÜè¨H‹z¦YYÖèøˆMóŽ#q9ÑŒñŒDŽeޱ›(¯µgõ¨üˆþX¹AyP™ Iø¨ySõw…iIi!©#y%Y'9)Y+™-i/ÿI1)3I5I7Y99;ù=9?9AIC)Ey”"‘”G±”3Ñ”1ñ”âèOéPIV XéÕ•cñ•/–ô8–4b–.–±õéÁ–Dב•!!•FA•2ÁÃÄ!oÈ••µ•E–GáЈCðoV&˜ E˜e˜G±Œ˜™™¼ˆæ˜b Dz©Šÿ™%™#E™¢Y—¤©Q¦©R¨™ša— —Eš°É“«R­S¯y›!›A›Da›· œ!œCAœ°iœœB¡œ©ÉœáœA¢)A@aªˆ¡?Áÿèž>!žHžaž=ž„¨žÁž<ស!Ÿ;AŸzhŸŸ:¡ŸuÈŸោԛ„8lÈÀlÉölŠ9IlÓ–l}©‡ ¥Ö°j@tÁ·jp¦fpŠ1qj p§F¢Žùy”äL3AI,š—a”q%À;Ê"` ·I®¸)ÚôY¢ØF_ØWñGuTW>T‡TŠVêôI z´r[z]Ú_º›¦&7¦Q¦,q¦¾¡¥p”KÚ,MÊp*CS:§R§s§‘§G´§¶1:EXƒê„lZnÿº‚úD„ª¤†ÚDˆ ©ŠÊ§â§l¨ñ¨Rz©…ú<‡ª\z ªÙ&Ê3]‚B•RZѨ‘-„B,xó2yÕ$FúaV&i‚>üÂ$®êª¡¦%<8à_û’3~œ§6š?X[€&ÇǪz7Y¸Š¥ á),3oìˆ*Ï:9rz#oGƒŸ2«Û]03©5/€''P&1|ÔÃ;ÝCª/·£^1¦=äS®!‡Æº2õªirPS)˰ú4‚ò9 ã) *¶ª­ á© á)3o€3)óYŒsx©ZÆ2]",.û° ±.&a2&’ÿ·.·º±sf_…=û³á³A ´!´M³«4›.8c[²A¬ w°Ê"]•Ò´¯­þ3­¯/¨—±¥g." /cK&e»g›¶¶k[¶/ÀAþz$Ìjµ0«PûqRKTk&V+2{[[ë²¶ƒ³ 1¹ZžHË${k;u›w»qÆ*9¿ê²­Z‰ÿ‚µ'.ê㪄ûµÜj*«z$«Z¹Øb¹'kªÒ¹ri›Bç*©¢J©üj©;¸¨ñ·t¸ë‰¦ñ¸‡»W ¯`ºy»«K¼kT©Ÿz»˜ú!¬Ë©ñºYj°Ï»"Ñ CÌ+H(kCÊ HÛ¯ »Öªm¢½µÛ¼((¼~›½£^¥ê¼ä‹qí«_q:¾²[¾óKaõÛ½qô½W¾ÕË¿tê¿^Ê»ñ黼'¨   ¡@%ñ—7áH6zÈPMÜI˜A\ÂpK5áP&\ ¥;èðÂì¶¡`ÃÕÄ ,à<\Mê›F|ÄHœÄJ¼ÄLÜÄNüÄPÅR,;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Barrier2.gif0000644000000000000000000001212210520670125020063 0ustar GIF89aú)÷ $$$(((,,,000888<<<@@@HHHLLLPPPUUUYYY]]]aaaeeeiiiqqquuuyyy}}}………•••¡¡¡®®®²²²¶¶¶¾¾¾ÂÂÂÆÆÆÎÎÎÒÒÒÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,ú)ÿ]H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´)Ê2HJµªÕ«X³jÝʵ«×ª'(ŠøJ¶¬Ù³h«†p*ñCÚ·pã¢%QSÁ¹xóê¥Z`mD ö Œ¶A¶#< ̸ñVf~x€ø# [XQÙ#ª šã -dJ-½1Eˆ®Yod B¶A lg,BuÝcC¼"íâq#¯ÈÛ÷ò‰ÄFþð8råÔ#6¹:ûÃé Á{ÿWh½8öñ ·ÃìŽ~¡x…ïÛ,ü¼ü„ê_²¿0>Bÿüѧ›}ü”ŸKûH€1(Ÿ€¶¨à@¶”à„.8¸àkÎWÛu¹uHP…,]8¡†¡8„²Iˆ!‰+™¨ Šr(¢@,²æâ„0ª$c4Ò˜]Ž¥í¨`)ýÈ_6ÞHdhFˆ$JJÞÇä=ÙY”üMyR•ò]‰¥ ZVÆå}^šf{bbY&bgÊ—fIk¢×¦“š"–s’TçxwŠø&[q¶×çHzh‡ƒ:U(z‡Š”hv‹bØhSŽiH“RWé„—2•©w›‚ÔésŸ*êR£fWêG§.ÿ—j«*Õ*u¯z+r³˜g}{Þ˜kG»×ë}µ&uësÃrT,pÇ>øë€ÁŠØìFÏêm{É"µìr×j”­mÛ¢×íQß"nFãÊVîŠÓFXm‡ëbÔ.kïzw®QéWïE÷––ïñ¶8q÷ÛF,hð¡‘¹ ‚,(Ä¡à@l,1 ¼»ÀÅ.4Œ‚BO±Éµ±P²GûÕ¯A$ trÅ*³ü2D‹à± ô¯E»`À. +?`ÀB , Ñ/`€V£0µG"+¤µ@€1P+¤Á×MÀ´ %±cT3Q74¶Òf›ÿœvBkKä¶ Zo­‚× ]QÒUûÝ·”Á]Â@%°Pyã*LîBæ ÁmyÅÉM- Œ^›Ü`7Ù#Oí4”Mð5 %tnyæ{.P +§\»æd×&;OyGw•7A¿ûìµ „Âô(ä^ùæÑ7M=At›ÎÂÒJÿ¼‘â%ø,ð€ `\¸“oÝ~Õq3í×l,ÿÌX;ê°ZG–@0À¦9L[Û˜ (7° q^ÛÓ&¸µÜO ê$Æ6Ž$O(ˣܸ@¥ÅŽ‚YÛÚÖvA«ÝOk1l Ǧ–@Z-€FKØzÿ¶Óµo €šì@“>úkd»€ §Ã,@Šÿ‹Lî8BÀ„ÈM}£‹<@º)@Aà g€¨YmtÕ; è\ČЀÀ›MÝŠt°‹|ñalA¶6hk”ÚÊhFÂYpŽ@dßnØHo"Is!ÔF'5 Š[)ã4ÈiÍkâC]áVBt!UkŸ&«÷5<掃Tä¤v²V6ÎŽ/ƒÍöÈø¥ 8&ó”9dÄ™8cæDRhE­a rP³JðK\² ”ékã/«)¨¯qq ¢s:R8²ÁÎt Ci€$êOŠ™ _APGÿF°oc= êÂ3PŒ\ài+%Ïè‚~Þ’nàûåä¶(þq/bNË£Fº•½‚œ s)A>z’Ĥ¡¦@š6…šŒ¡ýì&D™ÆÈ|޳¢ähÀÐŽ\R"™<èÛD‰1>à‘aã,*»Zm„AÙä'Šº² ðÁjJ!XÕw*íŠ |èKQ€¶ H ­ì©>Y)ÒsK}Üê×&9®-22kS¡xÓ—’M}m¬¤O…¨"n¤zš誧¢9LgCãÊNV²Ç䃛»ÀzwÅÔÁF«ÉÙæ,Û0ѶLbklC!šÓ„} µ¬ˆ¼·ÿš)®¡-?TÚ’],9©e![Ø6M³œ•¢% ‹ à %°a¨@?k”ÌŒ XûÈ ƒ¢Ò”X÷ Òì:‰âñ¹Êîp@˼ *8^m—Ó]”¸× èMs-ä\ ½8ÛJ}+óÓˆd²2ÿÕM€2`Ä"FL‚m³`Ÿ4˜-~H„Ù2aÙT¸'vJ†²a§t˜5æIˆ›2↔¸)'.MŠw²b¦´˜!/fJŒC3cÔx)7^HŽ—²ãÎô8'?VJ2d¥¹2GÆI’“²ä„49)OFL”o2e¤T!WFJ–Ù²e›tù(_>H˜2f§”¹ÿ&g6Jš ²f£´¹)o¦Iœ‹2ç‚Ô¹(wfJžg²g¢ô™ &J —2h™z(‡H¢‡²h¥4:&J¤2i¡T:)—†I¦ƒ²it:(ŸFJ¨_2j ”úÔ@IõQVí’VÿäÕý={´kiÑ·]Úo‰r=£^ohLd²-œ€&aLjØ@2vФ ¯_#×c’µQhÝ[ûÛXÒvQ¸Ío÷Ü77QȽsóÝ"R÷PØ­wïÞ’·Pè{ëßþ¥vÍo”ø;'×5uÇTð“' /öÂݤlB1[NÎV‰0mÙ   r.ƒìÏÈDÿy‡Z` H„ÀÒÎâ`i?Éð´žûüç@ºÐ‡Nô¢ýèHÿ¹,ØD éPºÔ§NõŸ7@£À)AªÎõ®{êÈ8·*ŽlDC»ì¥™@Ð.“†3Öl_‰Úã·/îtGÉÜóÞ»+ï|/ÉÞ¯¿'ð„ÉàÃ#ñŒÿÈâ#OÇò”çÈä3ËóœÏÈæC?LÒ›úì¦ÊèSïVÓƒžõY=ì/âù¢¼~öm[;îMHv¶ß~÷ ‘=ð_Þ{´ÿ~ø >ò«Sü²ùQ>ôR{¢<ú‘>öRý¡\ûÔ=ÿø#Ò}¡|ûÚ¿‡\zõÃ$ýîÇQó‘}~ìÃ?þåJý§÷ç(û}ý§~ÿ÷¸|8~èˆ| ~ Ø 8|¸}È|ˆ}¸¸{8}¨ˆ{!}#˜%8{'¸|)ˆ+{-ˆ|/x1Èz38|5h7˜z9|;X=hz?¸{AHCHzEˆ{G8IzK8{M8^ñgQ{S¨0UˆWÈzY8D[x]˜z_XXah…âw†Q†Í¥†41†¦Ç†üå†3‡¤'‡ÃF‡2a‡¡‡‡Ï¦‡1Á‡œç‡>Ò~€H‚˜y„˜$†xˆŠÿ—†Ž¸ˆTÒˆŽ‰Hy’ø%”X‰q‰‘—‰j²‰œ¨yè†)Ð9Ö¡r·aqzqŠ£8*0{wœá†* Q0àrŒ—`Uc €±(š¡P€hJ×V|÷@sÉ(t6§‡¹èsÀy àsȸ!¡>'‡HO#ÖxØØsÚˆŽ!Ñ=÷€Ž0Ž”WŽpŽöêìèˆÔ¡7õ8 úxˆ¹è™wŒMçI© - ù‘ÙŠ,ñÈxÐù‘õ’ ‰u-¡À4Y“4Éq)ÿi™“±“*¡ `“6©ZÈ“FlTx”Jé*b7‰Kù”L™”P9•²qTy•Ö”šˆ•\VÙ•`)gZŠaY–@6–%_·–lÙ–nù–p—r9—tY—vy—F& }e–~)0%q“Ñ—™˜=˜ƒ 3G˜Š9™8Á˜vd<Ùå@UnsTpT€ °2æ´Âš !™”¹š3a™Så41õ´D¢t' x4:$s@”›©I[¬9œ4ášk…:%ÀÄMŸTKÛ´@%ÀM`Ub#œÄy/aœ#$7 d›Û”Wp³MRÿ1$C ¡šØ™ž&¡  h#3AÌYUΙœð_ `ž°dêÙŸë)˜vT8¤At#U•T˜ð$C‚Å PŽñ ¡:¡Z¡z¡Ê 0A ¡ ¢":¢$Z¢&z¢R1½†þÙ¢&ñ•.£»–~"Š2z££8º£¡£<ú£ á£@:¤B£ˆb£-ê“DJ!F*)HêŸ`˜CZj0tòu£¹x¥2Ê@7·¸¤7áŽR ¦d:ü¨¥eš¦2áŽOÃ’jú¦-Á¥ §têlšuš§(1w°‘z:¨ RÖ¡JJ¨Š:_‹ÿÚ¨"ŠŽj”©99©”Š‘–z©™©šŠŽœÚ©Éø© :Š¢:ª•Xª¦zˆ¨šªz¸ª¬ê†®úªg«²º…´Z«ø7¸Ú¨·º« ¨«¾J¨½¬¬Äš§Ãz¬.h¬Ê §ÉÚ¬@ȬК¦Ï:­R(­Ö ¦Õš­dˆ­Ü:¤Ûú­}è­âÊ£áZ®˜H®èz£çº®‰×®îxð¯y7¯ôwöz¯h—¯úJpêÚ¯ê‡FB9°[°{°; €° Û°[“à¦[v€.y±›±»±ûû± ² ù p]‹l!Ðcòq'‹vð^7-ë²0+"2ÿ;³Èö²Èv³8‹%:;&<Û³"ò³X´B‹!D³G{#Ik³K;´5Û!Fû´üÑ´RKµHµ2µXÛV»µ]« _;!\¶Þ1¶ R¶fKh[ j»¶ËѶüñ¶p[r{t[·ºq·ò‘·z+|Û~û·¥¸è1¸„Û†;ˆ›¸ˆ±¸ÞѸŽë›’;¹LQ¹Ôq¹˜«šûœÛ¹Hñ¹Ëº¢k¤‹¦{ºD‘ºÅ±º¬+® °»@1»ºQ»¶ë¸kº»»<»éS5UƒßõÆ#,€>)¿ ¼:!¼ZÅ{¼±7Z3¦-ñ¼Ð‹½ëHÍÿT@V‘‘ŸE31%sHÙ;'“'í[U p2ƒ¾õ[Á½Ýkß»7ú´5 ´KP“Dýc5Zó}ãC2U“ÀºÔ?g$À#J  µ¿ùKûË6¨ÃHcƒG?¢DAc@³$¬™JÃ4ì3[]­t|Á2‘ÁÀ¤O¼M2”> J0:D½é3C@¬>ǹ6»„5è)1,Ã0AÃd“T‘qÃó‰Fàë@d@ÂXl2 Ó@b„9QÌŸ±ÄLìNÜ¿Q<5»‰?ü5ìc5RƒC *ÇòE"¤5,ÆAÆeÌßK;”3ÂÈp#™£9„Ü4šÿ ÅÈOœÈ‡,=+z¿}œ¹ìPU|\É)ñ½+aY&±Éœ|ž\¢<Ê%QÊ¡qʨ<ªÜ¬ÜÊ!ñÊ•˲ü´Œ¶|Ë‘Ël±Ë¼¼¾ìÀÌ1ÌMQÌÆ|ÈÌʼÌÑÌKñÌÐ<Ò¬Ô\ÍqÍI‘ÍÚüÜŒÞüÍ ÎG1Î伿lèœÎ ±ÎEÑÎî|ðLò<ÏQÏCqÏø<ú,üÜÏ.ðÏAÐýLÐ@aÐøŒÐ?¡ÐóÌÐ>áÐî Ñ=!ÑéLÑ‹ï¤GpÁ½ŒjÂÏ-Ìð¬/¤ïHüÖ8q×qvoÜ©t€[69ÐÁH< 2¯ÀÀÌ4×l3 $póÎ40AYð,´ÌBïLÊ/Ë:L7íôÓ @ÔT7]‚N)T­µŠZSôוñׇ-ÔØdlvPh§mïÚ@µí¶»pÿ$÷Üÿw7ÞwÿÌÚÞ|s¬wà„Ã;xá|×íàˆCë÷jŒ7žíã¢E.ù›Š÷dùåJfÎÓæœßèùN ‡.âè:•nº„¨ç¤úê¶ŽÓë°Ç'»†µ—Myh´çîÝíÜú®öî õ.ütÀ³»•Œ xpúñ€ ¤ IH7±‰È¢ , )Љ#‚/®‘"‰” EÁGFR'"€%-ã(^2#™ü€DNOöÄ@¦ M(EyÊŽt ù$}2KZ²Æ@A¬¥’€LÑôÒ—ÂÑ1‘ b3™ræ3-³LfB3>"8‹€ŒÒ/`€ Î@ŒÇ# TÀo!"ˆg<B ðAÁ:'2ÿÀ\P¡ùž^Ðøª{ ÙÀŒL59DX¨â€P`ÚA3¢F‹øó7ua.êLiT ¨žCRŒ R¢À‡6")þ³6!å ¨`*P€y*@” ht¤“u¨Gr¢ä¾óE`˜)š*:SPUP%ˆ,ZQç)´¢þq@¢ä<±’U]@«†š‘Ú&§UPrÍ•¡Oˆý¦D9@/½ËâÙ¶Ft¡$+¤T XÐ(ª1€ó.pøˆ²AýfQ¤ÊÕ$ÁDm Ò¢O¡ñ¬cWD# 0m¢ õO¡tØ×Îÿ"tSz¬^ O{ÚÕ±ök¨ý˜¨‚ઠ¯¸@”6`\™6W¡ ì/¶Þ”5pß(«Üê"J´&RîŠ"0Ñ‘Rv©Œ]¢ ^ãöô·¼…/c«+¨fà¶$øéVIp_Hñ¿¼ç‡T‹·âÔ´×»A/@¶v¶ºö{jã)*½Ò·ÅõQûl £uŽ4¨îx«Q‘ êu¬W”×¹¶øAŠë\­[ÚüYöžȯ@r,ë1oGpš[_úþT ò@ó5ôfÑÄyÏêshþ h>ãÙÏz.ôy B+=Œ¾Œ£íH[fÒ”¦Ž¥+ƒéL+gÓé´§jƈzÔ¶)õbNjÖ¨0¬nµh^ý—XË4´ö‹­o}çóZÓ‡t¢=ë`7zØÄƵ±%ìd÷ú­ÍvöO* €B¾±Ë~‰8imGâRÚ6é@®Ø('PeHLÀuƒ›& pwHÎi“œ{$ Ë»i’’äº$s!É®÷=’~äß$ øHNð\$‰ÂEÂð†äá!‰¸H&’Š[¼#‰ÆCÂqxüãÿ ùGF’’ää(ψÊ=Âò¸Ü#0ùEfÞ‘š{äæɹÎ+ÂsŽø¼#@çˆÐ‡>‘¢oäèIúF–Îôˆ8]#P߈Ô5Bõª?äêhšQ_ñ©¬kdëÉÀŒ@]ˆtÝë {‹¡‡˜=#h§+j'‡¼î ‘{Píª)â–=Û,É{gp‡ú=Ú€—9©r!Ê:Þ!wLjâ/€¾RJfÈß#Á_hF=BçA"¨¤õýë]¯Ùמö¶WÈæ÷~¿ó5dô¤7ˆéí SÈGºe1˼·|B5_ùÉ~óuO—†pþ>R}A€|‚ _ #FhÿC2‘ÝßG¥ï~Á'¯ÕÉzãGüJv(ñ‹òêo:ûÒ[Ã/„ü¡xö!OÚgÜ—‚GZ5¡xq€ê—€€Á€á€Ýd&*AaÁ‡!Áᤂ!‚A‚a‚‘‡‚¡‚9T}‡ùguûGs˜,.x02=èv6xƒ_—ƒ=·ƒ(Q„ñƒp„vÇ„rAƒw„HwJhtThN˜~Yr[øt]pVhrX† !…˜W† w†/—†jˆ@_!‘@n0aŒ4Ps¸"pÐ5†xˆ ðr8¬‚ˆŽ.H5ШuP4–x‰ ŸdR‰ž¸3à“8ФXЦxЍ˜Šªx;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Bucket1.gif0000644000000000000000000001171610520670125017721 0ustar GIF89aú<÷  $$$(((,,,000888<<<@@@HHHPPPYYY]]]aaaeeeiiiqqquuuyyy}}}………•••™™™¡¡¡¥¥¥®®®²²²¶¶¶ººº¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,ú<ÿaH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´iÊ¢JJµªÕ«X³jÝʵëÔ-(¦ðJ¶¬Ù³h§n`áT"‰´pãÊ=ÛáEM æêÝËWª)$^Pз°á³ „hû„Ã#gµ` °Ì !" v5sL¡@ôBΦ9v°03jê+D4ñàõF¶ºÎ}‘vk ¼/Æž];¸EÜÆîN.Ñ·ÌåÌ!‡è’˜ó#çPZ=ó M”èûyÑo®ô”0ýžF3†Îî-V¤=iiú׮بTjÔ9Uõ©¿Äi µzI³†qª™µêNßúJ¹¾ñ£Aìü¹$žn ¬÷Zkb‡zÊ¿S±›óÇæ>‰Îƒ¾™=7@?úJ†®ôƒ½é¦I:ÔOÂô©°çVo‹Ô³>’ªgýé\oÊÖï[ìdWÊØÓÞ³Oíl?ÊÚã®·Cît'ÊÜó~»7ï|ÊÞO¿+ð„÷ÉàÃñŒßÉâ#ïÇò”ÇÉä3¿Ëóœ¯ÉæCÏûô¤—ÉèS_Óïõ¬Éêc/×ãö´gÉìio{šã>÷*Ù}ì{óß%Âg=ñlüã›$ù©_~Åšï|’@ŸôÒgõ«/’ë‡>ûÅÚ>ÿ÷Aâ}΃?Xâ¿GÊŸùóß*ýêçû)ï~VÁ?þ™äëOp¬ã_÷7÷µ÷r_ç˜úÇxü$÷w€‘€‰·€Ò€8HxèXq—ù±øÈw H"8‚ Q‚yw‚ï‘‚*¸,Hw.¨0ƒ 1ƒqWƒåqƒ8x:Èv<>øƒ„i7„ÛQ„F8HHvJhLØ„0ð„a…Ñ1…Mh…\‡…Ì¡…FÈ…Yç…Ɇ?(†VG†Æa†8ˆ†S§†ÁÁ†1è†P‡¼!‡*H‡Mg‡¹‡#¨‡JLJ¶á‡ˆ;·¡1txt-€:Oÿ‡ˆT˜X…7g܇@° €oM÷à À‘˜(@šXà‰ 8~°¤p0pAÇ '«˜µ˜p·¤p³Š—pªØ‹1Œ WŒ´Œ¸Htº˜p¼¨Œñ‹ÁˆÌèŒÆÈ5Éh±KÙ˜uÓXàxäÕAÜu¢øéhîx+/Àr4!ì¨t€ŽóhúxçIcøÈuù‘1qÿk ‘ubnÒly‘Aqm¹‘ïB‘%e‘’ ó#M%‰Ç&’Ù_Õ-Y¼µ/ ©’4,é§ÿÃ=:ŸS:àóXÈI ÀoèT“FÙ‘¡?hó;à9¹Ó8ŽóA7ÔP!D@Ã8VEy”Z™,‰>.°9³¤EðÔF`R¤8$–Þ/3¹•nI7™M7Ô”jÙKÚôIž´Ck)“oÙ—ö#k –t¹RïDf™ôäP÷´—Ó–~ù˜Á’í$T#Ð8X6êC?t9FÕUc3P‘Ó˜9šQF’g$[Ý%3ŸE)Ó1µ…X4ÃY±Å–¤Y›€æ‘œâ˜¶¹›«äm¼ù›¡‘!I‡œ!œ™ p$€œ‘‰›Ñô’QÖyØy¤p¡Ù(àžâÿ ž ñ㙞깞pÑ ÷!ì9ŸôYŸYáÐy"°pÜ•ŸþY= wðŸ*(`'ððœÚ @¡  ê º:¡š-ðDy¡êº¡¢)ñ¡"Z¢-±°ˆ&º¢È–¢,ú¢-ª¢0:£04š£áx£:Ú£¬È£>¤AÀBz¤ A¤FФLZJÚ¤Pš°7QZ¥1¥Vš¥¥Zj¥)Ù¥«ø¥`J…b:¦FHˆfJšh𦹦lÚ—ú¦Bú€£rz§xš§zº§|Ú§~ú§€Ê¨"*ŠøI¨ª‹òˆ¨ÿ*Š\s¨ŒÚ Ó‹©ê¨Ôh©:©Þ¨© Š©0ê©:Alt"À¤ê †¸ªÖت®Ú‹°«‘8«´º…2z«Èi«ºÚ†¹Ú«¼É«Àú‡¿:¬µ)¬Æê€Èš¬¸¬ÌŠÎú¬ê­ÒÊ}ÔZ­Îw­Ø |Úº­´×­ÞÊzத7®äÊyæz®”—®êÊxìÚ®„÷®ðÊwò:¯tW¯öÊvøš¯d·¯üÊuþú¯V° u[°Jw°û)Pžð°±;±[±[±Ð»±Û± ‹±°N¡o`&{²(›²*»²,Û²-[.³2;³,KÿÐ\"««Q1í–³£¢›In>ËZ@“2´)V´U"´H{aJ›GÛ´Wö´a´RûdTûQ{µ¾gV˵u–µmòµ` ‘KF¶eËmC–¶D#¶¦±µl‹,n›'h·Ócuk·*Q¦ ·zk!s«~û·"¸†’·„‹]†Ûƒ›¸$Á·/ƒ¸Ž«#‹+)’;¹!¹à…¹gV¹MѸœûš[Y—º1º^dº‹·ª¶¬Ûºf m°»ß6»Ìöº¶Ûžë)¥›»¹‰»¾K9$aCbãN8Ë4Ýù ¼Ñ´»bc?ø´y¤¼½Ë¼½â¼t9Q„µ1#S3kÿ¡E(ÀY±y4²¥[!±¼Ø›½$ñ¼Кß4;³4NÞô¼âEWi„6eC껾ݢ½ŽÓVÌ7My6Œu7lñ?ôVÚC¥#ñ¿L›#ñ¼È4;òÛ”*ð5Ð+–e¿/4½|½Ì—¼½3•–Œšh4¾&4—¡å2t•¾$\£½ 2°$6M9P†äÁ—ó5"$Â"!Á6l5»Ë“#µ4Ý>Ýs3á35ƒ:äƒl5|ÄYy¶Xü¸»»F¼ÅÿÕÅ©rÅ`abœ_\Ƽj¼&g\+d¬Æ¨›Jm,ºo|i,Çwü+q\ÆsU} Æ,‰¼ÅƒŒyìÇ{³¬,…ŒÅ‡,|Äl‰,È‹L•lÈ—\-‘lÓ\™ìÈ›,¡,É£ü-\ŸL¥ìɧ ­¬Ê¯œ.©<Á«<±l˳ì¹ À·,½¼¾¿ÁŒ½Ã,µì˻ΚÉ:üu¼ÏaŽhL%`p@¿µ‡LÛç &ÎÆ•0‚E!˜ý’î³Iõr›÷Ôߟø«‘ùø¡šú̱_Ÿû¥ÁŸœüòÑï™ýÆáßžþšá_pü§^F€¾i‘ À&â-$EœÊð€w5¤w°àB@P4@keéäbÀÇ p7%"Ü™1¤3SÁÊð¨€P!—ŠH`¬.ÔHÿ¼–.æ„¶)‘¼Æ¨ € KlÖ\( *À Þ:`‚Q=r-t! ‚)B«Œ[£R” X …Р㻜ÅRÑ1Š ü¢@®Ø#‰³áP ²¬)ª€ƒ,Hãˆ7Æ dTX– iGÇX]£UàCl²“c,È" R’ˆ4d*pÈ­-k]¥ºá‹ ‡ @†C¦$H×D,+LA¼¤E¹4² ƒ¿âï,0ª ˆ`…4YÐÌÁéÒ0"˜ H°aòrfß\d˜:\žˆ–r`yŒG©†˜à†ÏDÁÖ¨éÅf>j”Y£@d(ÿOè0˜Ì€žd ˆ  "È€åÍ ø²œÈCé9Qi2Ó"Ø€5IˆÎ ©>ì•Cð(dÅ…ËÊf³GÒG†Æ‡œZY&]¼³ <$Ü rŠ,\Êa°€B³,7î‘*ýRQJf²À‡*˜˜‡: ¢î'¤ª‚ÝA`4À t˜‰,ÚµÞ™¬GYÀhœRf"™ÅU\+”Ùaј%×W²À†b¥æ£åËQu¯z¦<¹Zªœö‘ª)²ª° +­"D{Ñ`EPGÊD²-ñc]l¹žG³Uá,j<+ÐE´¥!íwL+ÔzFµÜamP\«ؼ^G¶@¡íelKÜþD·ámt|ëà.F¸Ì!nOŒ{ä&G¹ í@Öª„í‘ݦô­ÚnÛB¸(Û#º'©‹c¹Û²k’»3Ê[½. ­½$á›"¿#ùK¢¾ÕJë µ¾,’Àœ°Á"¼«Â!1¬¡ÃCܡĴR ’ÅbܱÆ'rüªÇ ¡È'“̢ɬ¢ì‘Ê ²üÑ ' T íLÑ %Dç²0‹TBÐ%ᬓÌ©|ÂÑGçŒ4ÒFóìsM6{Ä#t@}MQ rý ½cÑ•pÀÛt@ ”Ø/1Í‘Ê[ÿà7%p´à#‰-öAPRÖm]w ‡?yDd#tÀã,é½Í1p@ )x>7æŽ7~½ªä9ÔR·¸âm_6ù@¾ãy؆ƒív 0ðÀå¼-÷åo£=|Ü-,ÿp[ÐBådOð6µð@Ú©·4| ]‚ç0ÁïÓ—ÝAôÍ¿½ýòr[·Üt7O÷å)<Àìª]$ÛÎ08ø dyÒs›ü ½õ½Mz'ð[àÀ€r¼ãõ°½ìv&ÁÝFèf½ôÎu‚«@€ ¬ ~øÛ:`½/t_Ý:PHþÿ.—³ÌùOIìH÷Ç€ Ò͆»{]úZ0é ¯žA jxà çnX¬›çFÀ tàêô³’­Ámpƒsa ‡GƯÎ…W¬bûìgÃÏyqè`!Ç€X@p‡”ÛíÐVŸJµ‘+àà _W9Ó…ƒ^#Û×ÈÖúµà—“õÊvÉË­‘J1žç„ˆ7;®r)ÞÛ. ¹MÆÍèZý<éÊÓqªÛd_'Å׎nR„¥,Ë9)ä„b£¤íT"ÂÖM†»ÃäRX6KÂPz¼Ô^ˆ9U࣠I׿àd¡3)EùAî%°'/wÿ4ž`—äåù²™·#Ž)‰ @ˆÉµs n‚aL&3ñiÏ ®`ëF19ÉNsqŒ$#U÷¸­ñp[^7³ øMàœòüBWRÀÉe«\)°_¢Ò%ú³€&©èÒÝ …ÐcfâDçɘÎÔ‹[,Û.÷5!æ² î<‰BQ8¸&ŠÎz<œ¡D!·Ô²}¯†¡„á £)¸3¦q‘ØaÚ"ØÓN2 “'ØÀöèJEä<ÀåSäèvÁ ̵| è©^[°Ø¾~’!M‰æ4¹ –ƒE,ŸüÀfáe`{Á{À iX˶  ºVÚÒ6¯§åëé)³t­íÿ $‚832ÒÙĶ·Œ­ðF˳Á6ñ·å{@ÎDûÚæâ–¦Ei\ÍU'ƒ¢ ¡&áßT&›‘Êò§š~â.F¼»íJE¼!¯|À;(ëÊ »íÍ*uÙK'ôZD½í±oEð‹ú>ʽw‚o}(¿É¿jÒ/Eø;O„ÁÞAp™,g‡Â±pu$ & CDÃÐñðC@¼oIÄ!qqPÜÇÄÊ"p¡ œ`7ŠÆ Š¬ˆFJÝsÙ8R8îð=äaé8F<¦.‹ââÜ,y!Mž Œ£ôd…D¹5UNÈ•M3e&e![¶Ê—Wd+u\C¾U™©œæ`­9ÿ[GR’Í5fƒ„¹*u.È©rf!å™ {Þn›‘õæ#õy]ƒfV¡ýœèk-ºG‡ÆÑŸ-ûhI7Ú[•žQ¤ëuiqeÚE“H ¥²iPw:]ŸþשەêÅùIsŽ×ªçÕê…šŠµ¾Ø«½ë}Íú^¹®Ð­G•R«Z¾tþu¿‚½²]·©×C¶¬¥ -c“hØÌ^¶{LkÛZÙ˶¶Ím=9›OÐ~µ£ Ìr{[Cä.w¼¹ýnaƒ{aâм{\oí[É÷®X¾¿{îDµlÝên7½Ï ”[ ·¦€låð ü>{2Tðð 8<)!h€hzLÛ$åÿxx ð†d€ ˆ¹ÌgNóšÛüæ8ϹÎmnìüç@ºÐcŽp\)€ùЗÎô¥ éPzÎ53r£°`J—ºÖµþô­{ê€CX0‚²›ýìhO»Ú×Îö¶»]íðÀÛçN÷ºÛ½ì‹iŠ îÎ÷¾÷k~¼àÙŽ§¤`ðˆOü6Ïx¿_f6(¼Ê—€É3¥ò–gHä3ŸÌsþ(žÿüA6/ú¢„¾ôB9=êBúÕEõ®ï ìQßúØûdö¶Ï îE_ûÜïd÷¾¯ ð9ßûàãdøÆ ò-_üä ßù¿~ó¡/“åS%ÖWùô¯ÿ’ìsÿ$Þ/÷ÿö¿Ï’ð“$æïñøÏŸ’ô³ÿ#î7×úßo’øÓ#ö‡Öüï~þw_ú’çØ'€-‘Ų蘀±€»‚€ ˆØ~8àgè{ˆá€¨ø*ø‚$h&x*#x‚‘‚,(.¸)+ø‚ |OC5Hsƒ4ˆ6x4:¡ƒ€;¨ÀçFG8ËS„(¸H¸õ4™4ESh&wãOAt.wX†-pzztEžÄU!†Tè‡V$U¤SCtè+ãW; ÿp ô9£õQLxz±$A´$ˆ‹¸…–¸L™øRŠDˆ"H†)àƒtÈ@‘”@”X„§ÇAù„ˆ:Æ|؇áŠúô8 H;m8†=˜XI„£†«¸ƒ­XV™èL¢ÈеhŒõsF—ã[ɨ‚DXuÅM‚(Œ DŒZĈÀµ‰…¸ÃIõÓ[tÓSÑ(*µwÓRÀ4ØÈ‡G8‰»ŽVHaúG„õ³M*ÕBÔS^¤‰œ¸RH y ±4KuøÁcí³5]ãL 9‹fXKK850dø¨‘ƒ–Òˆ_£FÜrHÙHƒ*y‚3é'ã7ZÿX8]'‰’ È‘>5ùCI'3è“E‰I©&G‰’K9O &M©‘QÉ€Ui%S9‹WI€[É$Y)AY‚@–Ñ•þg–Bò•nH–B9–l¹hyq‰#j™‘oÉs9#uÙ“w ‚nÙ—‘—ì'˜)²—•˜xù—ˆI„I~ù!†©Œ‹™©!‘©“ÉƒŠ™™•y} !—)“™©™H†£I‹§YŸ¹ ¡ù‚«é|¯ ­É‚±i|µy³I“©©š›9™·é{¿Ù¹I‚Ái{Å9ÃI”»É˜½¹˜ÇézÏ™ÉÉщzÕ Ó©”Ë9×¹ÙiÝùyáÿ ßI€‡š-`šÎÙœoùPÀbwšã™åI€ à7üç9š÷ yꉘÀŸ~SŸöÉžw¹Ÿ~ãŸË ­‘ŸX ~cr» ¡¦!¡ú Puª wY z¡ º+{×x(Zw )Ú¢n7 Ô…¡V¡¡’t_w£Kçs8º£?Gu“'£UA£ã¶º-%÷£%Ê*§r·vyIz*ÄMJyO**QúSª@JB WêYÚyUº)_ÚaŠ[:]ÊeÊg zcj)mºoji*kzsªujzqª({š}Jwy*Šƒ:…ÿ ‡Ú‰z‹šzê'‘j“úz•š'—Z™ úŠJŸú¡ê£:¥:§z{›J'­*¯*{±ú&³µÊ©Ú«ê¹ »}¥©rÁúê½Ê¿šÇêɪ{·ª&ÏÚÑz|ÓZ&Õª!˺ÍZÛݺ ߪá ãº4åj çšéºëÊí ïŠñZó*4HZ¬·¯7q­7q¯G‘¯À°ÚQ¯üA°Fa°¹°5!°6Á°Eá°³±4!±Ïç¯å†±ß¡°÷A±Da±­QYp#<<9éHÑKXeEÊ*";$û¯ÿñŸ¸æos7¦d+«‹–ÃNíD*€º+3+5kxpž&û8ö”Z(Û<µìxZU>¤S¡•3„Z«U9z5ZÊ%CéSE;Û’´Añ--РO›³-!NI$YTå3>ÌTT#0J4T6Û$? •S-´>¹ô6·±¶üyt¾’|!`žÑ¹žûÔŸùæAoCE6uQ®#KN¶Q#ð…Ó³?<“N¥$´’ÅÀ¶ýù¹À¼a‘‘k{& ¼È›¼P·Ús¥K:V…“˜„E_c=Ó»;{7]ƒ¶·›S¤´Nyÿ“ `  Ê{¾ŸKÛY ðQ[:‘´º­tˆ„”gÄCfu+Z)`BÃóEÞ«N«›“ܳ³ë;™,î»&k[s9å3½Ëc½ÈS°$Aiè…üK‡ð>tJ!À 1ÙÀ‹éï«gWæ…©˜ò ðq*œšyçÂEÞš*ê{Ã@LlW㦠Äè±éQÄFçMÃl²Ûÿ8¹ã­g;脾9Ìvñˆe÷aRí:ºË->Å’>éÝl&t.'ÀC)[6°ÿ[¸%Y¸§ƒê…$’ÐèÁC²F°.²]£¿€,êâl°=tפ3>CA‰=bKÛc‰sE¦µEÈ!í[6€ÓIÔ(F²6 HŠêÂ~_Á&Ts‘¤³:TÔJXTD…ô8#@:³ŽEîÞ+ÐAóx8`íÞé£\îòlôHJx]< 4#@Cñþ[ÈA#üNxMCWÿ:Ê®N±4>õî|lðlÝô8WÕ9†D¼>ðÿ—ì~@›òwñÓSv‡Nïu<ÚNðò›kÊFXT‹Xt4¸Ø5ßY'ÀJÖK;UÔY^#íuSëX$Tô¸>^#î…LîDŸa¤®ï:³®óƒA¨3TSŠ¥H<³Õl¿ö µé¿µPi<ö%[炦÷{ßæ~/+oƒÏÞ܇ÿ+b_øPÆ÷çոޝe‰Ü‹Ï+“/ø•/¥’¿ùvÖùXúù ÿà€_ú—1¨ÿ™o&¤¿ú­¿(¯ú±o,³_úµo—ïÛ¹-«ï½_]¿ßÁÏ-·úÅqÇ¿ùÉïcÃÏÍ¿û»ýË?ùÔÿüKqýدp=¹&ý¸­ýÛO[çýµ þá_*§þ“þê_2ìßþ<Ñp*·ðO˜».šÿú¿ÿsŒhQÐàA„ .dØÐáCˆ%N¤XÑâEŒ5näØÑãG! š ÐÀäI”)U®dÙÒåK˜1eΤù2A‘9uîäÙÓçO A…%ZÔèQ¤I•.eÚÔéS¨Q¥N¥ZÕêU¬YµnåÚÕëW°aÅŽ%[ÖìY´iÕ®eÛÖí[¸qåÎ¥[׮Ѐ;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Any2OneCallChannel1.gif0000644000000000000000000000531010520670125022035 0ustar GIF89a)n÷  $$$(((000444888<<<@@@HHHLLLPPPUUUYYY]]]aaaeeeiiimmmqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,)nÿaH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜI±…‰Ÿ@ƒ Jtè‹E“*%º‚§Ó– 8˜JµªÕ«X¯Ó„Ô¬`Ã^=0áèÓ³%S$0 ²E7œYáÚ»";l éÀ„MH‚¨€·°Gøú­¹â€`†#gD¬ØfãÇ’3[¤<²¯eÇ#k-‘³HÏŒA‹MºuCÓ!QÓ¼²ëÛaƒ”=“öjÛ¸ƒÔý‘·Lß!Y _NÜ£ñ˜ÈA*_¼yÇç0£œNý¶uŽØ_jÿ÷Ƚ{ëïûß±¼ùÑè V@"¢ú–ì†@¼¡û÷™ÅW4`ßb³©ÖPFô€‘ 8Ph€ ÝÇR~±€€ØõЃ&¡@4à"Ø›‚ u€ 8b%Jv¢‡ÀÀ`‹ ½Ð\y@$ F”d‘G.‰d“GÄá€ÀÐ..DbŽhh!PŸCê­À”J¢Édšl®iД™˜à˜Ð–\>u" àgi¸œÍç' óݘ§fš@ß@ bØ * ‹9*"Cx.ºÓ‰Qš’¥uêiN V$*J¤Vdê©7¥ÿJѪ'µJÑ«°Ö$ëD´šdëD¸æ:Ó®õZÒ¯+lLÄøfËv™XgYBãvvF‹ê´§U›Ýµäe«m¬ÜÆæ­xà¶'–»Û¹ë¥Ë‘²ì®Ô,©A[¯N÷ /~ònDï¾(õK濬ÑÀ›dð¤ªpF 7L’ t@S6m<ÒÇÄÀˆ•lòɈY Ê,—ÌÀ8}@Ë-oPÍ,W !çTÎ(+Ð'Ï•S D›LÁI— [=gVWybužS/jõÕ9f]uÆ\—è5—[‡ àØ9–m¶yh—¨öÚÔµ áÛp '7€t×ÛÝïåÿ­·k|›ç÷ߤÞÝà„kf8uˆ'.ÙâË5î¸a 'ùäxUÜ嘣¥9nœwþÔç·….:O¤»f:Ü%D ÖëauÀóG©·¶ºÙ80ÂR¼+µÁ³wT;i·síÔéE;Õdƒ}: È:¸nEÃVüÕÑCTqBÕkv}Mt°é‹úrÔ}fßÏÄà|ÓW:1FÛ#t¾déǤ‚˜0ü”omËkí¼a( p’=Eyd~‘©Lx T)AåÛ £@˜T ¨Ðþ~³\`€Y3Á'ˆàV[AJ @RäßF"€Ú0 mX®€‰Aÿ¸CÏ< Ø!‰âÿFÌer‡ x©£‘DŽˆX`Ï ªòy*ù'‘Øð“¬R$k4ÑKÍ©A©„¨N2I€+*DÀh"¢Å-v >.pé#)ÒœŽÙ"W*ÚbΉ4õ©ã€R¡NލÌ|¨Q-†Ô;)u©k*B„ÑR:„5Z¦ŒjTÇs| QAŠÙ@°Z„FRzßE¨zº¤¨!rüRÈ ™ A@¢‚,¦=j 1àHõ l휇ú*  ¨E#à‚®jà!°Qc SDà$øl}@]õ²ê@}>@êþ¶§Áe)$‘;ÀÁUª Ð*Ìоù@è+Á.ØOvëv5`ÊæR˜¹ÔÕl‚!#X  2b­@ )ß÷õPUÚï@kÄN.EŸ¥gºÅÎ*T³%ˆ|mLÜRnQØu‚? !kன€ x Éø2³ÈåYs£üßHx‹`ì}9˜ß…xv [4Á틨º• Ö•kx«$Ø*#×­/Söï)ÇäWû¹c‚rr«<åðöh¿3tÄ\(„`µ+Vk©žêÓ;g*â±@<´˜c>0³5‚Ì~ÃR¦hÀ*Nm" ƒ¾ÖhLÍ­Ñ7ØÏÀ(òÓû䣡–Ç I>³.cä± ,EÔ<bç:% `aHZð€øú" :b‰PÀoZ[‰ØË³-2àm{ûÛà·¸ÇMîr›ûÜèN·ºó;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/One2AnyCallChannel1.gif0000644000000000000000000000753410520670125022047 0ustar GIF89a¥÷  $$$(((000444888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,¥ÿSH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§4=T˜JµªÕ«X³jÝʵ«×¯U-€J¶¬Ù³ 4˶­Û·p«R(°­Ý»x“~`×"‰} \s*a‰+^Ì8¤áÆ CžL¹2ÃÇ– JÎ̹scÌžSlMº´]ОG›^Íš)êΪ[Ëž-ô5çØ´sëÆi;3îÝÀƒ»ìmù·ðãÈI¯l<¹óç—Sn½ºuˆÒ'S¿Î½»Áì·{ÿÏ|cñäÓ?7Ͻú÷ÂÙ/v¿~nùŠéÛßÏÿaýüš„(à–8˜6øY¦1èà„„)(˜„+a`v¸’…a˜’@P¢‡(šb_"ž4¤ðÁ)Ö(ÒŠyµhR„`ãŽAXšŽ%•`€)LàLF'$iD– 0A“XZ„#^Q–4B#d)æD[ÞÕå˜hÚT¦]g¦éfLkn¤!Nm¾i'KqjdŒ7ÕY 4VôÁXwf™'F`À’6ù  M‰À„úã¡-°”ШKJ À©”V4å©\š©¦rÿZÑ‹yeMŽ*T*«¼¦JѪ¼¶Š)¬Êú«X h£ 4ëì³ÐF+í´Ï.`€ÁÀÜvëí·à@¶¼ `ÀÔ¦«îºì¶›îèº+ï¼ôFkm½øæ«ï¾ü6 o¿Íª±)êi•1ÒÀŒ 7ìðÃGü0˜Jnd¬ñÆw|A䞊€HlòÉ(§¬òÉ—®ìòË0C¼1×lóÍ8ç”áÎ9d„ƒÿMäÉI’âL1Îæ@aŽèq¾”çבî“èǩΑéJ¡në<±.íNR>&î:ÙïÁž}%X`å i`uñÇ?äµñÍ7¤Á†`ŸÀ‡2“ïÀi¯eà·=¤ÁŒ_7B%?Á_þç#´@²Æ‡Éü¬/…À~öÈ ÷v㽊)èéÀÿö¦0…`j%“@Œ'Œ@1@SðÀ„ÀGû3È—òöÁ8{)€€ÔØ×A”P Õ NÁDÐ~`R¨›Rä€GAÏÿ&d}À˜ÿÜ·€äì"AŒˆD%¦`äK"(@ÀLÁüô7þäðSÖÕǾ#&‘ˆ#–ÄD': €+ñ!Mx˜=JˆFA’¬ ¤Š °^ •‚ôÅhE´€!CxÇ ¦TŠZ”Õ/~mÓ»Õ™‚ØޤüÔŨÈ%- o0ñ£LøHYb|¾q$ňF9rQ¦@Ш]. —|%0I”B¦ ’2bf5ô5ŠÑGXLÁ&à©k&3fÔ(—éJšØ&´œÍ9È¢ ÇD8Û§Â[™R›a<"ÿÏpB ›tâ@XAªp”ç0ÙçÏ2ZO”ò§ÿº¨ ØóKŒŒÉ:IÕ·Ãáñ#í$ z°¨(k¥‘:0>Q•Èx4"©I5˜Ò} NÜ%  °ï„!ðby:>0ý”e -PS‹V°+miuȶŽFÃeqR¼ äN¼¤õ>`<B©é*öÀ* (¦)83Û7Z”ˆ—t€dV·–²|3b«X?€Ãa–U›°Œ%VWgÕÌ-öuZeNåvØØÑ=v#!Šì²vÙ¤S6šîÄZ–|¶5¥Xd§3Ùªrvk«ÕNkrZÖÿ¤6!™ÊfýFÙמ$·AÙ­G{ËÛ߯6<³å›oá6Ú,Ý6%µ]Ís\ ÷ªÄ®q›‹¥éž$º¦ñnAªû“ë:6»ØÝî’[¸Ê¶®³!¯OÌkYôžW½PbïåÜ{;øbÄàn“Ä[ð–†ÀùKb3“è÷qüý1r„ìÂΰ†7Ìá{øT xÕxL@|øÄn€& øÅ@\›Æ8™Š‰Pàg3ñÀê€41A¤–âc ËDÈDæñYL0€›\@¹òMe¢PÙÊX–²] ,’ ÄOµ7AðHÈ3‹yÿÌv‰›o™æ ß„Í ™ó›Í‚çè™ÇU‰šEÒgüyÏP)tG-Z› :$Šæ£Ý”HodÒhv´mbi`šÒJétF>ùäÑ 5FH jÚÆ¹%¬þN S‚ê¨ú"±nõ~o’k‚˜z µöÈ­-Òk]eØ)¶@~-`wÙQ¶±Ëë3ãvÖ(q6G =iO»v¯f‰´™mo„Ûñö·{Û'1·FÐu¯{{íVÉ»ël_™ØûÞœÎwJö­é~ÇäßߣÀQBðšÈ;#ô†Â>Ë…Ÿ¤áæÜtM"þ‰S7 ÆgòpŒpÜ!ÿÿ8G«r—ü"'oHÊUnÚ—däTu5Ëiá?ÄåW¸Ïy:›“ç úLbΙ%L_Òkp˜8ýé&‰ºB¦þ’—ûÅè#¹:ÖI¢õ„pÝ%^ÿØËlí±|è zÕ_"v·Czímn;uám’´S¤ì©»Ým÷<ë]Öüv­M?øgÞχ/ßKâ÷‰þ Œoü¹oèÈûzò$©¼D.oÌkâœ_´ç"wÅ×Äô§‡9ع9?´ÊÈ‹aöê— z,zjª›œ€ý("úGÍÞSɲßpOìÝÇê`7˜µø÷¹O·óÄ£sYkI˜”ÿµhìâCÄÀÒ_Võ¯Ÿýz;ÿùYþÿ:Ð# 0êHÉÞ>èyôIþ •G]öæ÷è7õwÕ¤}ð÷v¡(ÆÓMQ}xå~-·Ög<ÈBÊB~ 1€~GF\$ù·€}Þ·(SçÒ|HÝç)'Ò>VbØ (ƒ°‚-X‚&¸tò÷U'‚\Ômúƒð5ô#Có~á8$™RSX…A…Wh……[¨…)À…_(b „q5„=èƒ?8LÈb$ð!`=º÷‚Ámµ0ô7P(€JWqуІŠ‡rh„iè‡ Š¢ˆ%0¼ÿ’€Hgu¨ˆ‹E¼²‡؇j}”ȈŽÈ*(qNxˆÂvtŠ0tŠqˆ†€Vªh?ªˆ‰™8w ‹©xŠ…¨€¤ø¤Wg×7ȽH°·‹Â˜z’v„çz4QŒÆ¨+ÈxiÊèpšrp÷ŒÐw Ñz:·x£ˆ&ž6G‹°öàøuÚ˜iÔhŽâ†Žéøwâ8jäHrÕÈ‹ó¸j𣗸V9§\ÞÈÙ8’ØŽÌ8ÎH1Œñ‹,Œ á± I‘)‘yt+g Ivþè‚YŽ éoûø‘8’¬w 7 눒ۦ’s8’öèŽîÿv’2 “ÙŠËØ¯§“;‰©‘‚Æ‘-Q”B9”¡”tˆ@ÙŒKÉ”á”6í“T©Ž=É’‰• 9•[™Vùs-)/™e9–óF“†x•I‡“ú&–[¹–^ù“”l9“Z¹w_™—R¹—›×—ˆ‡—YÙ•‚©v„)yy˜z™˜á¸˜Ÿ×˜»†˜Ù’ÉzgiI”n©‹—©˜–ÉŽ$ –&š\ù˜fI™=7š¨™’™É{¬)@Ÿ‰¯‰™®Yj› yvy›X›¢ø”¥ ˜a œa€6`p I¡œÌYΉœáÐ3Þ¹\FA–ÞÙ3 LÖå™3à)‹Úy&`3Ÿux7óÙ/?¶ñ™ŸýRŸï : Z z š  º »;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Any2AnyCallChannel3.gif0000644000000000000000000002013510520670125022047 0ustar GIF89a¤<÷  $$$(((,,,000444888<<<@@@HHHLLLPPPYYY]]]aaaeeeiiimmmqqquuuyyy}}}………‘‘‘•••¡¡¡¥¥¥®®®²²²¶¶¶ººº¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,¤<ÿcH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ•(6(]Ê´©Ó§P£BUAÑÅ©X³ju †Î[Ê}Ê¡…ÇcÓŽí`ö¨Ä ÔÊÝŠ€ƒD,ÌÝ•‚¶5a(xÀ·pS DlÁ°ã »…ˆ‚M;Œ0Âf 7EH°©ÁFѤMOv¨ô¦ƒ °°yÂÁM n؈[÷jÖ\Æ(›¶m›½mîÖ˜¼æòß [Û|{vÍÚ·s+ç­Ý9t†ÒkRÿ'n&väÝi>ÇØ\ý÷èÁ§Xüúñšíg®¿˜_æþ÷…GÓxô•7Óyø¥§w¾ˆ€3èP}æÝGS1ýW†0iè` Ê$aCháL¾äáD)º´"€!Æ4"C%Ê„à… úÇàv#L3.TcL7¢˜c†;z×c€ñ‰7ß„Úx¢L-¶ôbDU²tåw?ôB )xfHA*4äA_´Â ÙP‘Té˜j²IP /P´åCYD§@i6„gD{þÖå@ÀDˆTfBg”è˜ 4Q ¸¹œ1õiPŒ.Êf¦`×D…6Ôg ,ÿz@FÚª„.É$C‰†Â|Ђ§MŠP¥]*ª›>*L¢¦JA '4ßáÊj’ ÐÀ -Dp@ :¤íC­Nv¨@ʾ j¹1ˆ;k­ ¨êm¤0šCÆ„,AÊÆ€*¬Þ†yŒ: i½)@lBϾ-AÞ¶f¼Ž6Üè¹¹2''A'0\šðækm ¤2JB ª6¼oC麵î£dÀA¬$”‹p Œ›è'ü|©'4L+Cýô/¢²€¦ LK¦Þ¶A§Bsú0B»4ñ@¤.Á©P7À3«J³BYŒh¤úÚ€£¿@ÝkêÐÚFÍÿœh¦ ¬\.£Ä /¼~pCI´4»ø «Ùr°3®ZëµC]nŽúè‰^:éðä× ç[6Ë«r ßµÝi²‘2 éæÙ:}4̺ä÷ío³Ü˜xn+ÂÈÛ¹Pã=N3¦”g€<ì×bm+ï u>P¨Ç`zêá/~ø1°¾Â+ǯÀT¿,;ºÜ"´Ú‘ºB¹ÌæË)lE3Âè< ÏSåÊ òE.[Á‹Á"Õï½H/`¨ÊT "@5»dn{ÄëÞ”Bõ±n©*_ŽB•¸H@ümËc ‰@Í\W+”¡TÓòVP¥ªÌ!´#ÊÌÿ>ð-‚|ÀQéËÔÊŽ(&²+Si{Þ“H%„ÑN˜Ö 88¶x} +ø–Ãè¼OZ%LȽ5­ôµ‘ƒˆÀ_˜QÝlq1p"ð²-ÎMr|TòÄ ef+© @¤—ï­„u%1dA II‘*Qd ‰Gª„’#±ä@@)Qþ“)Ñ$'OâÉ”2$¦L_µT@6i@S¤QaÒJ”¼$±üåGbÙT¢D•»|I/O"Ls–+!&OŒyd'; ª#4U"ÍPÓ$Ö´6y¤Ílï›% g…Æ©¤r’󜷌P.…”L—,Ó$ÍìÈ3Í©ÿ+t’D&b§{`øÎ~ÆSDó4S=[rÏ’ä“#û,è’ü9€JI  "h;á)œê\=ü´ÈC7ÒMPTR ¥ÔBYÒP’ŒT#ݨ®R €Ë À+‘€bjrÒŒ‰4¡éF~j¡Ö20€–ÊÔ¦:õ©Mm JÕª.•Û$ˆ 0U«z•© hÀWǪ¸'@ÀX¿*Õµ~•)HZÝJ׺:®G NÀ×¾úõ¯€õ«àØÂög¥ ËX¿> ìÖh¢‚È6¶ °lcqÊ‘Êjö³ õ+góš`5/ýPKIËZŽ˜µYm-ÈÎ(ÛÚÿŠäµ“I­ƒVkÛÞF·nÑ-€xëÛâ2¸Gî{ˆkÜæ¹FQîw˜ëÜêêõ´¹­m©k]çB·(Ò…w»kÜï%¼¿/y}kÞ¡ w5ê]¯mÛ+”÷N&¾ò•-}ƒb_·à7¿¬Ý/Pú{”ÿ8¯þ bà×2Á>YpQìààA¸'& …+¼¤ ó$ÃCÙ0‡?äá€X("þŠìÊâ»ø«˜lHJ¬“%Å äHF „öÇ@rcA`ªœ„Æ9±1Pp‘v„(h-4€$ãDÉ?Áï g–Ì‘'xè80G/‡ÌyW™£¨‘UBÿm4‰•1ºÞø&®^ðK3è•7 2\Ù m…Gޏù7p®2vƒ«ÝÚÆ·^hÎ3ì8E«t ÏÆƒÝýB²2¶y¥Jô‘ÜFË6¾k|š¤[v;­1‹‡v™ÛÔ>rèÕˆZÎ¤Ž®©[_¬ÌÒ“£Ú8e`…ñy²®,}€9v¤Ö“¹uIæ ÒÇ÷jõÒÔß Í)o`ZõbÔؤ-Fif#Ðv‹´IBí9¿+Àð¤µ?ejXmË€úlP;hÝ#i7ŽÞM[pOÒ!bä@’î£ü¶¹ï®YËd@q€Mt6È80Á~·öá3Žøy'NڊפáFÿ9Hn$‚ËåEQùGX'—·æD‘¹GhNB›D£] :CœEçá9}"? " PÑCbt¡ ݵ"w/ÉóÚ`"+Jã 逢¤NuèêQºÄ¶~Ôÿz]Q"‹H à²{¤êAAzÈèÎ÷¾ûýàOøÂþðˆO¼âÏøÆ;þñ‡€Ù߃ö[^",h!Ý£ ‘½+*8wFð”Ê_þôÉ<Üwú`ô¢ÿôÇãŒúÚ—¶…´!ìEBúŸ˜ÞöÀW 0t…À@±÷8küæû¤÷>a¾ó§Ÿè÷DúÔÏ>M¬Ïìkÿû/áþÿN¼þò«Dü:!¿ù×_ôçDýì?Ã'ÿøËÿþè¦ÿ›sÿþŸ_ÿˆÆþ7€í€\ÃAài !c$aø€P’–ÆGæÖïèRq2-8ÔR8´4)@f1à.¸B.e!A3G$h‚‘8ƒÑc€q?lÆ)Y$2ƒ{ëóg>;AS£mOƒ{1(€4¸„sÄf)Ð$ð.ã’gx/ª‚*ëS‚UÈ,!ƒL¸0çC/ã>-FQC…Ë5‘"C€–†ÂAgf+^x`†ˆsâ&À2‡1àCг†7Èö(hø‡v/uhwˆ‡Ðÿ¡€±Sí:&8wlN3-iŠh„È&nãV-ÙVCg‡J舶ˆáC|+qu—èQñ+Îo`´r1×2&Ø2,c²‹8¨Š´Q8Ãqfhæe9C+‰ƒ(Ãq׌ٳ2/ c[b–39#û#f°¡‚G£‚É·I6¨n©hŒðõgâ²?5ƒgõh‘ÓBÍF„¨’/ú8ˆôH+ŒÒ+?WCÝÖ!³†+l,A¸3Ç’Ž·ŽìèâÒDy’ðH0zö„Zè0°/¤2ˆzö‡£2ÿ“D”–f9ôEªÒ3fûChlfA™r9‘FÿQ‡¤5—¦7¬f #‡bÃA‡;ä"®ø7\Ä;‚…8nˆ€9{8é ó/Ð;¤)ÀÆ,?™gGù‘ÔòE^If „œ²DI<>„Gªbi°!„’'0Œî‡ÅX•/±>âÖ-”)=9’„CŠÞB3õn>kMH÷â+!$CÃ+áÆ>(È(vY“1w“zIò&x‹ƒoyŒj‚‘àh'úö+ž&ù&&~BH¬é' x—7‘—› ~´i¶y›Ú—›5±›¼I}¾IÀœÎ7œ3QœÆÃW|€™TD•ËY\ª§™£ômÒ©PÔYµ¥zŠÂz ÿ!pGÛé/ç™wš)dìÙžîùžðŸò9Ÿ–%ÀwÐú¹Ÿü©Ÿ°ŸWCwàcóIéYz7Y/ÖT ú ºTZ¡z¡^%]UW }'¢":¢  ¢Ðw°¡è+Êy]°|éövŠ‹tgl7•ˇ¡v^Ó£½…rov áz<Ê{ê{@ZZYW_Dj[8çtñK:È)1BÚXæUtâɤÝ9mQÊ_SZ[[Šo ]ú¥,¦G§&§.1§k:`múrMzrz}OŠtúHzsƒ:zÿÚ|:£¶×¨Zº¨ãW¨q¨Ÿ”¨¬%©hú£Š©µÇ©e—¦ìÖ§ ¦©¤%ªóGªgª†ªy¥ª´F©ég©©®«G%«wG«ïg««¾¤«µÄ«ÊGZš]4ê«áǬµ ¬!¬ÌD¬d¬eRFe£ª¨g­CÕcô®ðIdF†kÜzzÞº%°bÚ®c)!­øD­Á“®›)¯E¯ºb¯z‰¯.¥¯K¯Ué¯#a§F!°8I°"a°E°©°!Á°Dá°ì± !±CA±Æh±±B¡±ªÈ±á±A²Ž(²A²@a²xˆ²¡²?Á²aè²õsy2ÿË„4«QÝê¬ÞÙ9ëN¡Ê³=»?ËÛ#7»„EËGû!IKƒK+RMë O |*`0†Á†¡`gú.І1`œœieÐ… *@`¶…!ƒ…†` ÀoziT4X¡S61eAAçØP¼ÙS aQDRp6µ¶t¹%#8ê8BË9œ[ž "¡ËŽ˜ûšËK§K©ÛºøG»ñºÊ»31»«kŒ¶Ë¸kOº+¼ ºEåÅ{›¿»ÁËPÃË»™Í«ÏËRÑ Ó«—Õ›×»&ÿw©®ªÝk~å{ß«á{«ã›ç ~ï[éÛHÙûÛ[•3›Õ4º5(&¦©FžÆ€±¾ÁÚ§Ès= (¿Úw(°"+eøOüK“w–yuxpAÀѺ¦œBw¶’ð²À½«Š‡Â(°,ŒR´9’s2‘Á!„<&#ÀÃ’ œ}]bi•X‘)Ã>(#n+c2ìÓ0%™2 Pí²8C¼/ÙV˜œ"/•&nûB0âb&³ÂÔR¿.a…y-SCòå)%ùk SÆ ÑÃÔ×%ƒCvƒ7wœ!à.À)€‚VÂáÄMS…°/Y/|ÿu0:h7ãrÈñ’;f,wE3/³b¬7›Ã?IœÆ Y5uÓB ÇÓ'Çà<þBw+Çs;…9ƒ<Á‹d ½’[‰ˆá&iÔjB.½\n–C…¹çIàs:ÊL>Ë|>Íl>ÂçªcÜÉ’Ì.„¸†›£Á>RÂŽØ%!“6wEs’Es?€†›3Ë‚|„<&‰²>}ü>¯ËÔ)’ï#–°Ã<`âiŽô9åÐÏŒ> ±É±9ò¬7iL‡ô,l¥ÌÍxx(2D7‚¦•<„ѱüSË£mël„l34ÄÈòˆ6Àòœ8xfÒ‘‚0q„6ôÿT5ŒyÒ¬7÷CSXÍ5ô‰ƒøÊ3|¦ì|ërG”Ž\Ä&~ÔESCÑcSDB˜G†+Ò¶ŒŽF8QÃ&7#Gƒ”ES³/at3Ç#H^'SC*‰EqÓ¿åªS-¯ŒÆŽ’EMä(Nd×[ÀÆ+-¼°ÐÕÒqm Æ-¯Sí’~ͼHW}—C\Õ‡­Éí{HìÅÛü×NØõ÷‹“EýóÛIˆÍ¡=‘£Í/‘]ºorÚ+‘Ú¬ûØ™ÔÚÉÛ²í»´J¶-N }Ù'±ÚÀ'ÜHÓÛëôÛ7Aܵ§ÜdÜ…Ü6Áܧ'ݵìÙ›kÙɽÛ4HÝììÜŸÿ­¼ÀmÜ=bã]¥ÍJ°­¹mÂÚ½¿Ö »ØÝí½åMçmn ë툕q™œá ñ˜1¹,༠n+ŽQw‘†QzË~aàžaƒ»·ÎðtÆ™…‘µŽQ®a_¶…ÑCÁp¶¾–;´ì{®6ëÚ2n©Ë"S U»9.0û|6~ãñãX²ãïÑãhää=¡äÈä|‚äßå(åáäIƒ>‘Î~“Nn—¾~™>J•.¦NäŸ.›.¨+áe\8/šª^~¥.KËÚa$À‹h?eý—NS‰›AÙÓë§¾}˜ocr5´’šH…Ì‚‹ýÌnì,³/Y‰DÌ~-_¢Àô6&ñv‹ì`ÀêwZ“S˜Nã‘Ô)|ùés/ä6™,³(Y„”7ãÆ2ŒÒ3#˜Êùø4øCï­~`ß>ëÁ0t¢,˜Ó)â‚•Þr?+hûfC%x;©6+ 1/šÂAðÊpÎmñµð~~a³8îÁ?À27-òÊb''P/+ÿÏA‘¢-¤b4ðÃ=3i¨'òA{QˆÏX#ËvÑ•„fq…Ø“9Â)s„0y-fq.÷²†›–G`–ôž_>¿³±Å;2ßR/BDø—)–ŸbFO+RLûr.WÓFt0Ö’)ûòá}eà~°˜¹euÉ.·?uyq1ÐŒªNŽìˆ_8yò‡\Ž"ØøA.mñê[6GŒo{]®£~ãŸ_ã{žØ}Og–×éæ7ú©ú2Îú#¦ªˆõSçã§_m?¿¹ªá¥K~ûî6ò¹«(Úês¾ßåÀ?p½t[-°£ÿ)P¡ ê®Mµ€ýLÿUjÅý`bþäï °ýP¥¡åU 0*J¢ðo¢#ª¢ °þQUöUàœÎ'$XРA.d(0Æ%&”Xq!5näx°ƒ…;Ž,(â”('t`ÙÒåËR¢TÐäMnî<‘"ÆO A…%ZÔèQ¤I‚  ÔéS¨P °ˆZÕªÕ®n…Ê‚BJPS¤tp‚ëYήeÛÖíÒ¦oåJ¥:×.Ò¬wÝzðªÌ²z¦\Øð\¦‡OU\8oã­^[<µ`rQ—5o.š˜³\ÆŸÝ>]ºpfÓ© {VÍ5t뫤aÏæŠšöÿí³¬q?}½[©lßÁÚ^®ñ¤½‘¾¼8qçÎuGªœzŒæ×qC×.|ºvëÔ³wŸÍüîï×ÃG^µy÷´ÓS_ï¼}üÒðñ·ž½þòûöãL?MëϹÿ °ÀËdð³—KиTÌA 5‹¹ ‹«0ÃÓÔ‘¿¸ÎëP¸G¼ CÛиƒK±E¹X¤Q°‹‹Ñ·olËFíÊQ¸wë1H´DDRÃÉ+·#—¼ H)Û2¸'o‹²Ê¨¨ä2·&»Ë’¶-¿LI3 »Ò·1g+3M¤¼„³ª5wk¶7çÄ M= ¼ºÈ˳O¡ä$T©:q»ÿ³µAýÉPGsoQÕuÒH;ûS½@»³ôPL3*ÑÛ(MíSBC5(Ri3Õ4TûTuÕŸZíÕÒbÕsVZm… WÑt“×U}m ØÏ„…“XQU YΔM“ÙLM Úͤ5“ÚH­5 [Í´ý’Û5`&tÓUw]vÛIªJá$wëµ÷^”èÀªÀ÷_€Ñ} SòF@ `„ÿEÀ2Gx ^Ø8 *D˜­|KÉ`û ‚ø\ @…ÙR0†(6ˆªnÛ`ƒ¨,øà6âabÚÐçÙrîŠOÕfŽŠpŽÏÛ·€ÆÏéÖ„~ŠÜµŒ†ÿ i¥ÝcÚ-¨Ýë:5©Ï”™æ«“¦-ìî¶nëkòØ. í¤¨>Ëê§°>{éMMs[»½?ƒ;N¢S£Û)»ƒÆû¶¾©K|³¿’›«Á•*¶Æ£S›­ÅËü²Ê÷ûh³ ×:ïÒ6GÎôÆ:'êñ­"Ojò¨ï™á§i}èÏËÎú¼Ë×B½¸ßS}(Ö¯r)ØUÞ¸ÞÏ >¸ç [>¨â­:þ¨äÁ–}¶èw þðh „R8 óÑ?ÿªé"ƒõcˆäùå§d·®7*ù"Ÿ„«¤/8@ Ò¾àôÇø#àœr€°l¥{¸ù9࿼€/ ú ÿ±ª 0ïûàOăÜì„'ÌÙê: €ï!hlç ¾ ÈÀ ¸½¡ÔÐ;ŸS8pC¨LqHLJB¬` XA;Ⱦ..(2ÑØ )Дp#| f™"¢¿¢Àî6 |H‚2Æ`Š4l¿ˆÆ¦LqŒ8ÀÍ(Ѐ¸|1!zH'¾œ ðßO~L˜”ßÍÆØNâ”>4Šgg•ð5àM±â¯h’P|ª4`cpB2¦@•DÌ€ùš’!ŽDÝ.õˆ¾œ˜cO0¾"ÖÀ:¿ÿœ€ŒxY 3p3¡47ý™eBÀCª’lL(pNAð–ãß VI‚UÅ”ÜsãQÀǨҙ$(qw™d N´% SPòÐ’%Ý]H8Þrˆþ{&0Ñ×€^Ò~óü ¯(O¦àé4 QÈ‚@ÁÔ}1¥éLmú¨š>…œ Edà7ËXpˆ'4)uƒœ~--Ê>aó=¦R²•…e‘ÂEÖR«$U'wÁT“ŽHæPä8Ö‚҂̼âHYXTŸ@0¬èY8¡Û+PúZ+¾Ö¯‚Õé#×øÏŸ–ð«#%)\‘ƒIF@ÿL%ŠS[UôÉÄš®ä,£K-ÖQ± ݪD+)O1)e ì&¹ÆP3çë ÚÊÒ’rà¤aÉçIêR …¨i>›ÉX¢ò–/ àXH`OÊŲª© ø(Y¾ó¥O€U=¨Q~ú“ú…÷~òŸWQ‹Bd@)¬ JòÆxBR`2þ»®GZ¿¯ Pžøùð‹×à¥~»)åÉØúÉóœýÕ((£+”é¦&Âlmcà×1²^Tr )` ÷ó:^K…_ü­Vïã°öF·Ä‘ø,&6 úžÂ^ dÏ4â¼Mó¸"ãÏy+4† Ž-ÙâƒXo"ÿV“?ÜÝ"¯yH~›’KçdÍa™sV¥‘HeÑðX> ²–OgæÔqy6^Öq•_|ÊŸ¡Y1Dn ›Áì7+‹FÈ›Ù3w§ZÑØywäñ±å,œ>‡PÍQÝ ÓFfÎ$2’þ!”ë,eìÝ™3bžM¡¯BiÅ€Ú)t.¦÷§é'óÒ|>4ôZ-½E_ºÑw{3?cüjÁZp¦Ž#ª5ÃiØxÚ*¢6ŒÍh³¨ˆ e³ÁÀ¾þ¢Ú¸`ñ)_h“±™ <áö@ªÍë8J Ûãþ€0ì˜}`ÜÝŽ´ãc€#®›'`ÀƒP@ä[ßûæw¿ýýo€ûû¾ B >p„'\áþ¶Áœ¢ ,\âÿ7Á‹Ó P\ãçÄhõq‡\ä#'yÉM~r”§\å+gyË]þr˜Ç\æz ;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Barrier1.gif0000644000000000000000000000771210520670125020073 0ustar GIF89aú¯÷ $$$(((000888<<<@@@HHHLLLPPPYYY]]]aaaeeemmmqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶ººº¾¾¾ÂÂÂÆÆÆÎÎÎÒÒÒÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,ú¯ÿ_H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´iJ#¢JJµªÕ«X³jÝʵëTKxK¶¬Ù³SRD˶­[³%lf(À ®Ý»xóêÝË·¯ß¿€ßM @…Ä^̸±ãÇw „Pû]Ș3kn¬ÀX™* ° ìQƒ‰ â’æÚÅj…. ~­±D‚™.ÐÞ:bïÝŒnpâeËÄ€ùÅß¡;§(|º@ãÖ+*É<ûDé Á{ÿwXÝ:öñ·ÃìŽ>ºßïÛ?,?ý¼ü†ê_²¿¿P|ÿøü-DŸsö˜P~.ígàAþ)Ôà‚ ˆ\„`K V8Ѓq¸ „ÄQ¨¡@²”ሔb€ 'âˆ%®t¢†+Tã}-îö¢†1ª4c…7 d{9Ò¶c…=¦ô#„C‰^‘¯ a’(-¹`“Ž8”«I¹ •'Yi –ZÄ%i^¦IbHf™[gÞqp’8ÛzÍÕùfgR–f€k–Ô&{ÂÙ§Zò(IƒÞWh™‡:•è}‹ŽÔ¨|jiS“ÊW©H—¶—鈛2Õi{Ÿ†*z£jXêR§¢ÿ—*H«Ž×j…¯*ëx³~T«w·B˜kR»z׫G¿fì‡rÖGgÇv”¬uË8,RÅf-GÓNW-‹Íø,œÛnÔ­sßòwíQÙZW®Fç"—.ŽáN8n™ïf/qóÊ·®QíN—/Fû×/‘õ†x¯–_Tðn?™°‹ Ãx§~yÂñxÿ°s [ôpA”¼À)¼p@­pÀ /XpÀ`-0±F7ô€É €ðÂldÁi/¸ VA‡Ô1Q#TòÌ(ÿœtF tð‚D-Ë!…\ÑÈ•œA3«Ì5FÝ,°@ÌS{”3C ¬œAÝ+¸Ýò)ÿ°ŸpsFKÕôAb“ý¶ÞupÀÕt ÷w}q‚wTv̯ün£œAÒm·zÏ/¤°€ ¤,Pä??>)¤@;Hs/T·@ ®w ¸ ‚ßé>ð pýë ´Áã&ðà­ôàQVœÑæ2¿ ÷颓¾@ È+Ïü@œv€/¬ Ö̓ä5E`4³ ŽwžA HBÿ¶³ÚÉf— `Ñ[Ý@¢—2½Eï}ñ“[–Â3ÁÔÍ~£Þ‚g‚Ýõs*óŸçJfÏx/hä{ @Èv½ìÎ ÷ËŸ÷Æ×¿ÿI €' áÿXFBÂ/‡¬YÜÿ:2¿‰Ôïu0ÙûXÖ‚(î„.ë€ÌLÐÁ ψ©ç¹äN!{šßöÜíqX áì:` ¼m}$;› ÛW¹\‹&$Èò8=ÄdAY‘’,‰÷›á šøÄ“Eqm|#ûb;°ü¯nÔs£å–“9ŽlÎ~pÙÚö¶ç±pgc+àWX¹-ÖìlùbBvG½Õ-i´G`@ ¤Òlq\ õ^@¹NÄà£@ÙGe¾€™Ët&4%bȰ‘q n%)_`ÊÇõò—]ÈW€Aê±n“ÜéäF>ùºdü#cÉNó<¬à Xe+÷ÿ<¤˜^¬à@BKlJ2vZ,YêØv5ö…S‹“,ã0Y’ ¥šö»¦iöÎx¾îƒºl(@í7Ö¥àŸŒûH%rD• Ñsu;§'§emŸ|<Àglj5—¹N‚ðÉÎ b=›þ³—‘Y"³kš@§I›1’›Äz1 ^õ®È¹¥ÂÒ{,KÁÓäôCù]Cê\ÉP²¼ÀL ’ ‰,3B¶·6D¬N³ZE±×%í¥d­i›[Ýú2tâé%OÀWRLƒ<@¯ êK ½ˆ<¶8õˆEƒ‚ш$v± )lAp)’•F¤¥1ÁO²ÚŠd®¡âDZ»H»ÿÚ‘¯hòëIT+‘´À ´%âYM”V ÔAÇÅný¤Û/ WFÅeRr;4]f¹°¹jz®¢{¥êªÈ»àºnìÄÉñÂ8›JgIcZˆ Ö)çÝMz²^Ê´÷!ïmJ|i3_ŸÔW-÷uH~™²ß×ô·'ÿuJ€2à¥x5æI‚›²`†4X)&M„w2a¦Tx!NJ†)³atx)VHˆ‘2bµ”8''VJŠ²â£´Ø)/ÆIŒ“2c„ÔØ(7nJŽo²c¤ôø ?.J™2d›ù(G6H’‰²ä¥4¹&O6J” 2å¡TY)W¦I–‹²e‚tY(_NJ˜g2f¢”yÿ gJš‘²f™´y(oHœ2ç£Ô9&wJž_°çŸôÙ(†I ƒ2èBûäÐEIôK ”FswLàµQ¦é%ÞñZÚ¼›R¨ÖihiWI—vӨıå" »€:u•RM¨UZb¥&—¬ÃDkGÙz¼/´K(ý“Oëé×ãvKˆíck Ù|rµ¤`­¨]³©×˜‚¶¡¤Í)jSÊڂ¶¨´ )n›ÊÛž7IJ €ñ† ‰mG$ïì¬À®Ó½ó“(€9¸ÀNð‚üà¸ÀÁÎð†¼0÷ 4`…;üâ'8&ñŽ{ %Nàñ’_|ÿ0¹Ê~x &%X¹Ì n€ÌüæÌÑÀh¾“œßÜm>¿9 Úƒ‚ Ï<0úÊ3 îV›¥â~zS$À©ËDÙ«q´ÕSBõ­Ãë¤Ñº×MÒõ±·ì”»ÙGRöµ«íjQ»ÛAÒö¹ŸîN‘»Ý;R÷½“ïMÑ»ß5Ò÷ÁOÕð‚7üE ¯xÍJ؉o)©o=BX/ûù<~¼±¯}Ah¯{†¼)¹ï}T«.|Óß¾NÁ>ï‹ß%ù½_>ó â|£@_÷ÒŸ>Aª_”ë×>ûÚÐÿñáä}Ùƒ?üÜ'Jù[~í§(ëW}û§ÿ~¡Ä¿ôóg~ýƒrÑç¿øûý×yÿ'|ø¨yØ{è Xy ¨{ Ø(yX{ÈØx({¸¨xØz¨!hx#¨z%˜'8x)Xz+ˆ-èw/(z1x3¸w5Øy7h9hw;¨y=X?8wAXyCHEèvG(yI8K¸vMØxOX^á§S¨xU˜NWˆ…Ä×… ±…‡†7‘…†'†C†eø…j˜hˆ9mXf8xoˆVqHsèwuH\w8y¸w{]}(hw¸]ƒ…8v# ÿ€ #`vwO0ÌQó–ˆ#àmt‰ü‡ ª¸Š°w°Š«XžøW°¨ŠˆP‹·±w+ °(8‹"=°X§x‡©ÈŠƒ÷б(Œ´¸Š·è‰¹¨Š»èw½¨ŠÀèŒ(AŒ`ŒÂ˜Œ­hxÌ(‹ÚˆÓÑ8‹¹Xƒ×‹ÙXŽ»Õǘˆ ŽŠWä'ñéX!ÓX‹ªˆnáL¼Œú(0'¾ VxiuÎ6‘ijy‘i1¹‘™]ù‘"‰*M*Q7’(i_%©*'™’.‰b+I+-ù’4©e1ù¬ÿ£t:¹“<Ù“>ù“@”B9”Dépp“±P”LÙ”Nù”P•R9•A$@ q-°?‘R5ù•«W JñTù^ –jÙb6&DNŸQ;µÓö&$[‹t— ‘–kù—HÑ–öó4osI U7Y“ˆ¤Bˆù6Š©Pt“Y€9™D!˜¯s³³&Ð<îS7-°•d—€ó<Ÿ ?Š9¿™”¹šEa™µ2À33¾CFõ@Ó4‰YGªÉš¼ ®ùA.³M³ÓA´Y9Ô=e´•º©;’Ù›Îy¿Ù?xƒJCœ¬$N€#V ïDQ}ٜϞ2¯ášð–E36+ð–?N$[ù[N”•Ärᙟú¹ŸüÙŸþùŸ : Z z š  º  Ú ú ûy!)žúY¡Úš¡ŠÚ¡ :¢$ê#Z¢(šH)-3™¢.z +Ê--ú¢4JÆdž5J£,`p£Ñ£g;J£È”£Eš¤Jº¤LÚ¤Nú¤P¥R:¥TJ“;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Bucket2.gif0000644000000000000000000002020110520670125017707 0ustar GIF89a÷ $$$(((,,,000444888<<<@@@HHHLLLPPPUUUYYY]]]aaaeeeiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,ÿ]H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§ UlÐ@µªÕ«X³jÝʵ«×¯`«vXA±E‡°hÓª]˶ê†P!ªàж®Ý»j9¨PÊ@¼€ ¦j‰$X̸±Ú .Äm"²ã˘·^ Àé -&sTA@â‚¢98‘:!½­1¶ @Ö(‰±5€ @îŒ<ü&˜¢Àð‹ H½}Üâ›S .½¸tŠÉ—ã¾.ñyoî©7ÿ·bvÛÛË;ôþ0ºú†â“Ïð|Qæô²wè>ÂøÃÍçBö…߀í×Pào6HPC(!A 2Äà….<˜[„R(”…ºáB^èal ^(bP$rx¢B)J¸bk-Jø"P1^8cB56xcj96¸ãO=Jø#BA"8¤hE"x¤OI6¸äAMøädQ8eOU"x¥AYú·e\]ú÷%Oa8fAeæw&Tiæ·æNmú÷&AqÒ7çSuÒw§Nyæ·ç@}¾÷§S¾7hN…Òw¨@‰ª·hSª÷(N‘¾7© •–w)S™–·éMª÷i¨àºT©àÿjSªå­Z"A®*+w²ÖD+x¶Þ*P®Iíz]¯4ýÊ]°Â‹”±Ò!;“²×1{«³GAÛœ´2Q+µ%bk”¶Çq“·ÍË¡¸E‘;œ¹0¡{œº* 7žqºïKòG¯öʇ¯°ûºÔïoÿ p€ßZpKç–°“ CØp‰³qlkYñ‡‡¨z¡`‚ ™À‚C*K¤ÂÊ. 0Êu 'Ã& 27ÄóD=«[ϱK”»1Ÿœ2Ì µÑË3D4Ñe¼ÒÆ.0€@làPØ ¡A€]Sõ5óÖGlÝõÙY3àz+ÿDÍA 6m»€ÛEÌbÈi͵×`‹ÝÙ~öÈ0ÛÀ}øFV«„5Û'SÜ&è¼å±]Pš®B˜ÐAßÙ QÝØ€ÛJ7Ä·Bu[Ž‚*|`€ï&¯:pŠãȸD¤›`:êÏ'ÄúAÅ» *˜®¹ °[¯¹ó…žÒèã»`€Þd@ÁÝÎöÙï¾öÝ&ØM_û j§‚åuDwé^‡bw6ðí}{Á@×\Ƕ Öo‚äà0€;ò!Ï}’ۈц‚4× ~b“ý\`?àsnÛŸ ݧÁÍ}m ˜Ÿ@†×?”mÏ"êC ûÿ6§¹ø1@¨ÝüH@‚÷¹ïˆ´û@ ÀÚíÏrû_ß~ˆ:Du[›ÞØF`@T@Á´5ño8™:D¸mq.¨â†Ç‘ ¥„ís‘¨D7:‚Qœb€‚:$‹+ËÜõÖü¥od÷IOFLhÉø‰­‡|åÈ6E­™€“.¨ä ˜µêFnü¡[í"Éáñ1l’Ì£æB©·P@kP`䢂&vÀp„^E<€I‚0ñ Ï4H4 2Mg6“"€Ü A˜ÊÚñ’›Ü,eí„©J]N²›(ãà%µÃ²`†žDç7!BÂ1Ñ›í‹Ù,³ÆÿJpnÄ‹ Q á,yË`ŽO‚–Ìì>PÀ`îs˜(Ü ™¸Š„àš©æ@4šQŒº€£õhD²é‚wâ/…ŸôfßDùµzºqœEÁCs9ÐÊŒ¢U)’4‰¶“m2‹gÓHÓÁ¯s¦»¢éÌçÊ,ŠoA=fî`¹ Yb`P#A·¸B@‚»<#í:9ÐÀÓrè‚4bÀ‘ À›£G¤éEħ84@PQŠN¢Õ}He$é–êV¦e‘–ãsk(åŠR‰§ù%ß(Ð3Ó²1c€ÌpˆC½}Õp#ß>2Æ• _e!ߠо©B‡#·ãD0,·ÿµ~ÇAZÔ_~Mܺ ÕÜŽ–|“¨çZ»BD²9¬ìe¹¶Í2 ³,Äh?:ÚÒ²Q³k)ùäš9Ðì° âI°‘Û‰ €xŒˆò2Ÿ½–%k›'RÀìÏ#~ ÒÚË€÷Ê"óeÈ×I2ür¼1¯AàXŠÔ#„ëÚr%rUƒ Àt…’sA"C7Îrù0ƒ3™/QUC-0Põš„½¢¹p«BÌ¥«©Âl‚¬^Œ¢óM>¶ñ$d%™FFnn‹m\OFÇÜ‘ñOhÜ*“ÄÊqÁòu´ì.§ÆË#3TÄ,2÷ÄÿÌ¢A³HÔü67ÇÍ<ódä:;ÅÎÇÁóNô>ƒÄÏMôp­BCÅÐA4SýFçÄÑO´G$½JçÆÒ8Á´S4ÝN+ÅÓ±õMDÝRsÄÔIAukTmV3ÅÕ5RdZ×ÄÖKÁµFt}^‹Æ×4¶R„bÅØ“AöL”fcÄÙEv\¤-j#ÅÚÁ6Q´ nÇÄÛG·EÄ=r?ÅÜ0A·QÔ]v ÅÝN÷Kä]zSÄÞAÁwSôí~Åß8P΂·ÄàCA8bšl¥')Ê÷šò’ Eq1YœI˜ÆÙ™/†/Åá,ÿ¸P$…ÿÄäJAùJT–CÄå>yRd®šÅæÁyOtŽž§Äç?ºC„΢Åè(AºO”Þ¦ïÄéFúI¤Þª3¤ŸºN  æV+(@ör“Ôܪ8¡9ŠЀºÛýîxÏ»Þ÷Îw¾ }¼à¯÷Å 1Áß ÏøÆï]p¼ä'O€#OfXÀä7Oø €ó <F°&šþô¨O½êWÏúÖ;­½ìg¯z·SĴϽîWìþ÷À;xJüâÓ~0¾òcßâ‰h)ˆoó‡C•é?ÝòÖHô³œês(Ï_Êÿö¿Ÿï“(áWÊøÏŸó³¿'éOÊúß÷Ó_'ñGÊüïïûóÿ&ù'wÒ÷KáHhûw€Ia€  X ø€Fá€èHxCa¸8ø@á$ˆ!(#x‚=a‚,X)+ø‚:á‚4(13xƒ7aƒ<ø9ø;øƒ4áƒDØGØ—}Cx„1a„L¨L ¸„OèN8…„>!…V¸U¸…Η„Ö§…^ˆ]8†Ï†Ó'†fXe¸†ð†Í§†n(m8‡~‡-&‡vøu¸‡…=¡‡~È}8ˆ¸‚‡ù"ˆ†˜…¸ˆÿ‚ˆÂ¢ˆŽh¸ˆ€È’8‰Q‰†x‰;‘‰š(œ8ˆž¨ Š1Š~XŠ9qЍ誸‡¬ˆ®øŠ ‹v8‹7Q‹¶¨¸8‡ºh¼Ø‹ñ‹nŒ51ŒÄhƸ†ÈHʸŒÑŒføŒ3Ò(Ô8†Ö(ؘÛè…Ýß(ḅã希çh…éøëHŒí8…ïèñØ‹óø„õØ÷h‹ùÈ„ûÈýøŠÿx„¹‰ŠI„© Š ùƒ ™©‰Ƀ‰9‰yƒyéˆIƒi!¹ˆ#ù‚%Y'iˆ)É‚+I-9ˆ/y‚193ÿé‡5I‚7)9¹‡;ù=?i‡AÉC E9‡GyIùKé†M©&ÀX3ñ”•k8•qDr5•¡•f8•^·V÷ˆ(–cH–)×`Éjé…l镉·2—[X—Þ#UÑ~‰LóQÁ´2$°F„¹ƒÉg—¡—VÈ—ÚtWÉTê4u£YIÔ5³cJ7÷–,ᘙS(™“¤©#4ƒ3š43<¨¹34S@&–K^óN_SNUš ˆ—%BšOhšüÔ5zUI’$Äy6|c6?@U7@^šSI<ôP» €¾É!ÀÉ„ÂÉ6,`RƹKgÿCÀ¤72E[ðB!IÔIIÖɘ¼©¢™Ûy„ݹRæ5K’´=Z3C´W‚ÔAî9KÕ‰x јÙy!÷I„Ý9>.TI:t`dž`F0@Ê‘šN„™šS@Çt`º)ŸØ™–˜ÑÑi:@]c8¿CAzCQ|#A_Ã6xDSïŸf9Ÿ)QŸÑ ?(œ€ù@[. Ð$ 9HÚUäsLRRFÁ¤~™KäCJ:¢?Z¢Qx¢(ʈpš–9ŠIMI„  ¡ &Z¦|x¦6¡i±E5äS\A¤(¸ B¤<(œ#§'!¤¡…+`ÿ!§ÅH§5Q– J¨&a¨¡… °5[ãJŽ:‚ # °|¢ºz¯7ª¦zª¨*ª½—{´£©0}–ª²:«´ŠªÈW«ÊªÙz¼Êwp½¬Â:¬¼ztGxàª[SaÄú¬Ð­ÄZ ­ çkÇ~–ºLdz' ®ºÊŒ:®±­¡… ©Эe:•ˆ®!†' °ШæêðÊ€ò*Šø¯Eѯ(°!‰+K€ ë™!`® û Û™Ø@z:±üW± Š«±rʱ÷ç± qŠ-à{ŽJ²ôg² áŠ+Ðnê庯.ÿ›µ³3«5k®7‹¼¨³(ʲï÷³1Œ)ÐÇ‘=;®Fkʘ´K‹’MÛ©O[Ñ(µìXµŽzµÎʬɵrêµña‹d[¦f«}îši;¶ûzˆqšf |¹¶(Ú¶.#x+’z›|{¸.9¸ÒX¸oË ©¸ËȸÙ¸c)¹ÄH¹•Ë´s{®~Ú É’Aµ;,Ÿ‹ I´ê¡ºç§¹*ÁºÜ»ßçº*q«“˜Û‹´[º¢˜»¶¸»¼›Š¾ûŠÀ¼°8¼¨X¼Æ{‹ÈŠÊ»¼¾Ø¼šø¼Ðû¨¼K½ÕK®×{º¨7(»<ÿѬaØ›½Ó(½!±³%¦¸ŽÁóhÚ–œB©0Ƚþ±ŽëI³ñk—Wi¿ùQŽý㣤[§ò‹*ôKå{YrKÀü+ \¼5êË”è r[Ïõ¶Ít§ÃrL¼§ìK€ß¸À[c•©×ÄGÁÂáÂjº2gõQmú™#ü`«¬Œ»û«EHJ[,°¦O*QºÃä2¼ÊÑDsä¡«tFª¹Ã§cYuÔš¬(L“ü¢5ë "žy£cÄitL5*Æ´s`ˆ%jE9`:©7ÌѸcÁ¯gŠÇb›¸=<™ODÆ–<Ãy6ý£Õ¡oÿ<r,ÅÐtÀ#Á”ØÅJÉñÅú)È®ôŸz“™ÄžNÌÈ’3Ço É8è¿ô±ŽàKúòÓ?êYDg£[bÔP°L>´¥Èæ$ÊQ\ÁÎdÊ!!ɱÊïñ ÄTïã:Ê3A–”9À•?pÆ¡Áó3©´29ÓšÍ3ÍéÜËÖü•جÚ¬¿œ™‰§·ãÈÒÌ !Ì›ØÍ4ø©iV˜ÔdÐ"|Íu %0µçkÏ*üÀ8Ïå¡…%@[ã}œļºS ’ü® ¹ ÑÑåAÐHR™Á ð-Ó2½ÿaÊ*ˆ{N¸3ýÓ@Ý|Ô_Ql-0DÝ/½ÔN Ô5Ó;­½áÓOÕZ½C½ÕW±Uݺ RHÒšÇ Ñs+ÌŠ·5 p·'ýÑ,ˆÒ!G–[)@‡Ë¼jm³cÍŠ8À× Ü¹ µoK×±+×Îø×ב‰+¨Ø×!Ù×âØÒŠ`ÍØ$HÙábÙÍqŠèÙÝÇÙÜÚÇáŠHÚÔgÚâˆÚÃQ‹þÇÚ¿AÛ ³Ðñ ¶»í1¸Û ÓÛíçÚèÛ¿¡Œñ!Ü¢¡Ü~bܹ ±Ì]ÄíŽÎѲzÜ×>{Ý­ÿ!;ÝP!Þ¢âÝ©ñ-°PÝHÞ;öÛ‘v`‹+àÐÒ¨aÍ~-­‡g¾>Ðöà~~T¡µ¾àX} îˆ#pv "K€ûMÞ— °Ñ{Xw¼[­ðíæ·†x£Û¹pâ‘K$Îà.þ}ög ß/^ãâ{mã:.,8¾ã@Ž îäD^o¾\äHžäJ¾äLÞä×x×NåR>åT^åV~åX>ˆ µˆ`Þ/È^~~]n‹^º žåÍ÷¾h¾ælÞænþæg åp>çt^çv~çxžçzî)Pà{þçaæ€>è„^è†~èˆÿžè»(çŠÞèQ^æ{æŽ~Þ‚N‚`>阾¼}žéœî°•Þé ê¢>ê¤^ê žêª¾ê¬Þê®^ä›þê“>æ²^ë[hâ¼›â¶þsþ¼ˆ’¾ë<Áœj® áHì ìʾìÌÞìÎþìfëо紎Š!p»ËGÝb%0ì/>äcöéNê/îm&îMAîsì‰îÐÇèÐkîwæîâïË+ïFïêgïÆ‹ï‹¦ïòÇïÁëï•ðú'ð!í+^º‡-jž·Ûâ.NðŸfðäŸj/-PëÇážñ³¶ñB±°½ç v.@&þ¤Øÿ.§ðò¥jÛ.!! Ã*~à³áª 1®*®šJvü—®*üm¾ëª©úÚ©àª3ÿ~;¯©=¿à?ÿª4NŒC¿5FÿHJ¯ãMõŽõ0õôWõfõ0ös;ô_O€ ÷dßöçg=7a»x¿—þŠn0¾,f ‰Ÿ¢ì^º’ZÊh.ò÷÷øSÜëßÞøKùù˜?·çÎú 3€CΤ¿t–?ñ¿¯çáÂÂS™!ñU7ôN’Vg“9üœQ«Ïà’O¯/û û¡Ë¹ôÀ¤ONJ6¤LM¿¿àÁÿ~¯Ÿ?”d@’$C7:Fgÿ³Ì»¡ì5d“KzY>ýìWýLôÊü;P„<«…< jž@›DÃ¥Ü$SkäDÏ.º Ñ`àA„ .dØÐáCˆ%N¤XÑâÅŠ4`äØÑãG!EŽl@B '˜`ÂÅ. l8È .>À°BL)Â<8S IS²tù°àH¨Q¥N¥ZÕ…F«YµnåZµ¤J•L] •‰Á “ `@bçqe Ht Q(NBp!Ö©Á®&ÌkaĉSýêÂæ†: À)"©‹Ÿ(PÒ1(`3i‡¡1ïÒ Ma}[B|ºØöÿmÜ7ææÝÛ·ÀÆ„30;–Ÿ) Œ-œ "Pæ4Ný¥jPëD¹Ý¯ÃÚ¿Å/|˜üyôYg…Ù´!‹î†O_ß~Hó÷õﯸÞ*LäS@¢?\(?lпûtpBÅZÈ <ˆA ;¬Bû$ôpD®¸é¦íâD{±> aFk´ñFsÔqG{ôñG ƒrH"ŒìDˆhÅùŠtòI(£”rJ*‰”Á0ÔrK.»ôòK0ÃsL2Ë4óL4ÓTó̼iˆ˜\È„5ë´óN<óÔsÏ5P¡E@ýè7Xr7AUÿtQFÑãàÄ&8´QJ+µôÒ®JÐH RlHNLCuTR¢@C‡@-uUV[¥ôÔTuuVZkÔ>•ÕV^{õõ¾ ÈuÁ]5öXdm vØ„TMöYh£…ª… ¼ªXi³ÕvÛ‹Vh @g¹wÜq½0\rÓU÷YHá tוw^[³|W xéÕw_RíÅ[~˜Ô€3ßV¸E:W@xaˆ#nN –øbŒ$Á€ 2öøc%8 K6¹> $€€ä“[v97@àešk.o#¬³ygž§:,瞃$ó6èxh¤“ÞPÖ‡•vºf›~zj“9ìÿ”j¬‘^‘f³öj€Yþzl—¥&ûlˆÍF{mÕfûmz݆{îtå¦ûîmíÆ{ohõæûocý|p['üðV G|ñQgüqK‡|òE%§ür@-Ç|s5çüó=}ôýD'ýôôLG}uñTgýu˜-†}öÎe§ýöÐmÇ}÷Òuçý÷Ô}~øÖ…'þøØ‘W>øå›Ïu磧zé«WÑxë³÷{í»‰zï½?|íÇ'ßzóÏ—>}õg¿ýå߇yùç'¾~ûÇ?Þ÷çwÿýv ìX@Ö¨SàI×@‚‚äÜ)ˆ9 ^rÔ ä8ØÿAÆ}„ˆá WB…)äÛ Yˆ7¾n1”!ÜhXC¶Ý‡hÓáÉÖC~ ˆAÌÚ‰H5#ñiIT¢Ò˜ØD­qŠ÷“âõWE+ö‹Yà¹8@/~Ñ€acÉXFžTã%ØF7VŽqÄàé¸A;ÞуyÔcùØGþ'ä UXHC¶‘‰„á"9CG>Ò†‘”d)YI^“?Ôä&…ØIO”¡Dâ(I¹DSžÒ‰©Te[™ÆWºŒSpS-myK\æR—»äe/y9 À)–£ZÀ„9+‡9`˜¢:Á|E€?-óR"rUî%ÍJÿQ³UÖĦ¥´É*nv“Rß\U8ÅÉ(r–ÊœçTT:IµNv Ê£‚g<5OQÕÓž,Âg¨ô¹ÏõSÿh‡z)‚tBµTBÚ †VÊ¡MPD)5QŠòÇ¢ÂhFõ³QFuÔ£! ¯D:Òô€tQ'EéyTª(–¶t¶´ïCma[Û>Øîµ¶ëÃm\{;=঵¸ÑCîW›û<èVµºÉÃîR»{<ðö´¼ÅCïKÛû7ø®³¾}Ão(û»7O±fÀyCp<7¯ÂqÃpÛ:ü6o¬ÄmCq¾Z|1O«ÆõúdfwÅã‰á8YUP±Ñª8fÈ# Œ J3§¹“Fs—¦pŸ|þó:9À)ÏyÑ~t¤']éKgza;jcsp-1.1-rc4.orig/src/org/jcsp/lang/doc-files/Crew1.gif0000644000000000000000000000540610520670125017403 0ustar GIF89aõ÷ $$$(((000888<<<@@@HHHLLLPPPYYYaaaiiimmmqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,õÿSH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›=TØÉ³§ÏŸ@ƒ J´¨Ñ£H“Í€§I ”JJµªÕ«@(átä]”pA,ÈfÓjÌð@íD Ѻ;‘-݇ Ä­p·¯C»-ÿ9ÎÀš³E€ù'?#zW¦bâ''MéJS:ltr-š9þÉ7¶•¢+"ißdOÓ‚n <“¡S£º®œî Z èW3,Öþ µ«F½ØLÛš×Ñ5©€aoŠØ16¡}e·‰Ùq6™ ]io‰Ú±¶”°=m3‰Ûñ6‘Àq÷ˆÜÁl P X(¸Ò¤æMïzÛûÞøÎ·¾µÐÚV"xŸNð‚üàO¸Âçä°ûá¸Ä'NñŠ[üâ÷ ;jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyChannel.java0000644000000000000000000001334711113671251017500 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for a one-to-any Object channel, * safe for use by one writer and many readers. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Channels may be {@link Channel#one2any() synchronising}, * {@link Channel#one2any(org.jcsp.util.ChannelDataStore) buffered}, * {@link Channel#one2any(int) poisonable} * or {@link Channel#one2any(org.jcsp.util.ChannelDataStore,int) both} * (i.e. buffered and poisonable). *

*

Description

* One2AnyChannel is an interface for a channel which is safe * for use by many reading processes but only one writer. Reading processes * compete with each other to use the channel. Only one reader and the writer will * actually be using the channel at any one time. This is managed by the * channel – user processes just read from or write to it. *

*

* Please note that this is a safely shared channel and not * a broadcaster. Currently, broadcasting has to be managed by * writing an active process (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example). *

*

* All reading processes and the writing process commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

* The default semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. A reading process must wait * for the matching writer and vice-versa. *

*

* The static methods of {@link Channel} construct channels with * either the default semantics or with buffering to user-specified capacity * and a range of blocking/overwriting policies. * Various buffering plugins are given in the org.jcsp.util package, but * careful users may write their own. *

*

* The {@link Channel} methods also provide for the construction of * {@link Poisonable} channels and for arrays of channels. * *

Implementation Note and Caution

* Fair servicing of readers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * 1-any channels. * * @see org.jcsp.lang.Channel * @see org.jcsp.lang.One2OneChannel * @see org.jcsp.lang.Any2OneChannel * @see org.jcsp.lang.Any2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin and P.H. Welch */ public interface One2AnyChannel { /** * Returns the input end of the channel. */ public SharedChannelInput in(); /** * Returns the output end of the channel. */ public ChannelOutput out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableAny2AnyChannelIntImpl.java0000644000000000000000000000421211113671251023006 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class PoisonableAny2AnyChannelIntImpl extends Any2AnyIntImpl { PoisonableAny2AnyChannelIntImpl(int _immunity) { super(new PoisonableOne2OneChannelIntImpl(_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedChannelInput.java0000644000000000000000000000472511113671251020453 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is the same as {@link ChannelInput} except that it is guaranteed * safe to pass on to more than one internal process for parallel reading. *

* A reading-end, obtained from a one-any or any-any * channel by invoking its in() method, will implement this interface. * * @author Quickstone Technologies Limited */ public interface SharedChannelInput extends ChannelInput { } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedChannelInputIntImpl.java0000644000000000000000000000500211113671251021735 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class SharedChannelInputIntImpl implements SharedChannelInputInt { private ChannelInternalsInt channel; private int immunity; SharedChannelInputIntImpl(ChannelInternalsInt _channel, int _immunity) { channel = _channel; immunity = _immunity; } public void endRead() { channel.endRead(); } public int read() { return channel.read(); } public int startRead() { return channel.startRead(); } public void poison(int strength) { if (strength > immunity) { channel.readerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Crew.java0000644000000000000000000005645211105701167015641 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This provides a Concurrent Read Exclusive Write (CREW) lock for synchronising * fair and secure access to a shared resource. *

* Shortcut to the Constructor and Method Summaries. * *

Description

*

Concurrent Read Exclusive Write

* Parallel processes must ensure controlled access to shared resources whose state can * change as a side-effect of that access. Otherwise, there will be race hazards * resulting from arbitrary interleaving of that access between competing processes. * For example, a reader of a resource may observe partially updated (and, hence, * invalid) state because of the activities of a concurrent writer. * Or two writers may interfere with each other's updating to leave a resource * in an invalid state (as well as confusing themselves). * *

* Where possible, each resource should be kept wrapped up in a process and accessed via * a channel interface - this will always be safe. However, this also serialises * access to the resource so that it can be used by only one process at a time, * regardless of whether that usage is read-only or read-write. This is an example of * Exclusive Read Exclusive Write (EREW). *

* [Note: the above assumes the resource process has only a serial implementation. * A parallel implementation, of course, will allow parallel access along parallel channels. * However, if that parallel implementation needs to share state, that shared state is * itself a resource and we have only deferred the problem of secure parallel access.] *

* Parallel reader operations on a resource do not lead to race hazards, so long as * no writer is present, and many applications need to be able to exploit this. * Parallel writer operations are always dangerous and must be suppressed. * This principle is known as Concurrent Read Exclusive Write (CREW). * *

Design Pattern

* Suppose many processes hold a reference to a shared object. Associate that shared object * with a shared Crew lock, reference to which must also be given to each of those * processes. *

* For example, suppose Resource is a class whose methods may be * classified as either readers (i.e. cause no state change) or writers * (i.e. cause state change). Whenever we construct a Resource, construct * an associated Crew lock: *

 *   Resource resource = new Resource (...);
 *   Crew resourceCrew = new Crew ();
 * 
*
* Each process holding a reference to resource must also be given a reference * to resourceCrew. Invocations of reader methods must be sandwiched * between a claim and release of the reader lock within resourceCrew: *
 *   resourceCrew.startRead(); // this will block until no writer is present
 *   ...                       // invoke reader methods of resource
 *   resourceCrew.endRead();   // releases this reader's lock on resource
 * 
* Invocations of writer methods must be sandwiched * between a claim and release of the writer lock within resourceCrew: *
 *   resourceCrew.startWrite(); // this will block until no reader
 *                              // or writer is present
 *   ...                        // invoke writer (or reader) methods
 *                              // of resource
 *   resourceCrew.endWrite();   // releases this writer's lock on resource
 * 
* This pattern enables fair and secure access to a shared resource according to CREW rules. * Concurrent readers will be allowed, so long as no writer is present. A single writer * will be allowed, so long as no readers nor other writers are present. So long as each * read or write operation is finite, readers will not be blocked indefinitely by writers * and vice-versa (
but see the Cautionary Note). * *

Access Sequences for the Worried

* Java is a language that allows the throwing and catching of exceptions (and a return * from a method invocation anywhere). * This means that the normal sequential flow of control is not necessarilly what happens: * what-you-see-is-NOT-what-you-get, a worrying property. * If an uncaught exception is thrown (or a return executed) from * the resource-using part of either of the above access sequences, * the corresponding Crew lock would not be released. * To protect ourselves from this, embed the access sequence within * a try-finally clause - for example: *
 *   try {
 *     resourceCrew.startRead(); // this will block until no writer is present
 *     ...                       // invoke reader methods of resource
 *   } finally {
 *     resourceCrew.endRead();   // releases this reader's lock on resource
 *   }
 * 
* and: *
 *   try {
 *     resourceCrew.startWrite(); // this will block until no reader
 *                                // or writer is present
 *     ...                        // invoke writer (or reader)
 *                                // methods of resource
 *   } finally {
 *     resourceCrew.endWrite ();  // releases this writer's lock on resource
 *   }
 * 
* Now, the lock will always be released whether the reader/writer section exits normally * or exceptionally. This asymmetric pattern is not very pretty, but is a classic * application of the try-finally facility. * *

Binding the Shared Resource to its CREW Lock

* In JCSP, shared references may be passed to processes through constructors, through * mutator (set...) methods (but only, of course, before and in between runs) * or through channels (when running). *

* If a resource and its lock are held in separate objects (as above), passing them * both to the processes that share them is a little tedious and error prone. * It is better to combine them into a single object. *

* One way is to define the Resource class to extend Crew. * Then, we only need to distribute the Resource object and its access is * protected by inherited methods - for example: *

 *   resource.startRead ();        // this will block until no writer is present
 *   ...                           // invoke reader methods of resource
 *   resource.endRead ();          // releases this reader's lock on resource
 * 
* However, this may not be possible (since our design may require Resource * to extend something else). *

* Alternatively, we could declare (or extend) Resource to contain * an additional Crew attribute. Again, we need only distribute * the Resource object. The sharing processes recover the associated lock: *

 *   Crew resourceCrew = resource.getCrew ();
 * 
* and can use the
original access sequences. *

* However, this Crew class offers the option of doing this the other way around, * so that no modifications are needed on the application Resource. Pass the * Resource object to the Crew {@link #Crew(java.lang.Object) constructor} * and a reference will be saved as an attribute of the Crew object. For example: *

 *   Crew resourceCrew = new Crew (new Resource (...));
 * 
* Processes to which this resourceCrew object are distributed can recover * the original resource by invoking {@link #getShared getShared} - for example: *
 *   Resource resource = (Resource) resourceCrew.getShared ();
 * 
* and can again use the original access sequences. * *

CREW-synchronised Methods

* The safest way to ensure adherence to the design pattern * is to burn the correct access sequence into each reader and writer method. * For example, extend Resource to contain a private * Crew field and override each method to sandwich its invocation * between the appropriate synchronisations: *
 * class ResourceCrew extends Resource {
 * 
 *   private final Crew crew = new Crew ();
 * 
 *   public Thing readerMethod (...) {
 *     crew.startRead ();      // this will block until no writer is present
 *     Thing result = super.readerMethod (...);
 *     crew.endRead ();        // releases this reader's lock on resource
 *     return result;
 *   }
 * 
 *   public void writerMethod (...) {
 *     crew.startWrite ();     // this will block until no reader
 *                             // or writer is present
 *     super.writerMethod (...);
 *     crew.endWrite ();       // releases this writer's lock on resource
 *   }
 * 
 *   ...  etc. for all other methods.
 * 
 * }
 * 
* Now, parallel processes can safely share references to an instance of * ResourceCrew. Invocations of its reader and writer * methods will be automatically CREW-synchronised. *

* Notes: *

    *
  • * this is similar to declaring all class methods to be synchronized * (which guarantees EREW-synchronisation for parallel access to its instances); *
  • * it may have been better to have designed Resource like this * in the first place (rather than extending it as in the above); *
  • * the above access sequences may need to be of the defensive * variety; *
  • * a disadvantage of this approach is that we do not have the capability of grouping * a sequence of reader or reader/writer methods within a single * CREW-synchronisation envelope. *
* *

Alternatives to CREW for Shared Objects

* The proliferation of references in object-oriented design is a common source of error, * even for single-threaded systems. For concurrent object-oriented design, we must be * especially careful if we are to avoid the perils of race hazard. *

* Protocols other than CREW may be applied to ensure * the safe parallel use of these references. For instance, if the shared reference is to * an immutable object (like {@link java.lang.String String}), no special * action is needed - this is Concurrent Read (CR). *

* On the other hand, if a reference to a mutable object (A) is passed * between processes over channels, the sender may agree not to refer to A * (nor to any objects referred to within A) in the future - unless, of course, * the original reference to A is passed back. In this way, the reference acts * as a unique token, possesion of which must be held before access is allowed. * See also {@link org.jcsp.plugNplay.Paraplex} for a double buffering adaptation of this. *

* Such patterns give us safe, secure and dynamic forms of Exclusive Read Exclusive * Write (EREW) sharing which, along with the dynamic CREW provided by this class, * complement the static control automatically conferred by the CSP * process model. We just have to know when each is appropriate and apply them * with due care. * *

Implementation Note

* Channels, which are a specialisation of the multiway CSP event, are a fundamental * primitive for synchronising the actions of concurrent processes. Common patterns of * use have given rise to higher-level synchronisation paradigms that (when applicable) * are easier and, therefore, safer to use than the raw primitives. This CREW * lock is an example of this. [Another is the * {@link One2OneCallChannel CALL channel}.] *

* The implementation is given here because it is short and simple - an example of the power * of expression (and provability) that follows from the CSP/occam model. Correct * implementation of a CREW lock has been notoriously difficult. See, for example, * Hoare's short but rather tricky solution from his paper, `Monitors: an Operating * System Structuring Concept' [C.A.R.Hoare, CACM, 17(10) pp. 549-557, October 1974] - * a paper often quoted as one of the sources for the Java monitor model. In contrast, * this CSP version is easy and that easiness is important. *

* Each Crew object spawns off a private and anonymous CrewServer process * with which it interacts only via channels: *

* All accessing processes * (i.e. the {@link #startRead startRead}/{@link #startWrite startWrite} * methods) communicate down the any-1 request channel, identifying * themselves as either a READER or WRITER: *
 *   public void startRead () {
 *     request.write (CrewServer.READER);
 *   }
 * 
 *   public void startWrite () {
 *     request.write (CrewServer.WRITER);
 *     writerControl.write (0);
 *     // wait for all current readers to finish
 *   }
 * 
* For startRead, this is all that happens - CrewServer will refuse * the communication if there is a writer present. When accepted, there will be no writer * present and the reader has permission to read the shared resource. *

* The startWrite communication will also be refused if another writer is present. * If there are readers present, it is accepted. This has to be the case since, as far as * the CrewServer is aware, it might have been from a startRead. * So, acceptance of this communication does not yet give the writer permission to start * writing - but it does let CrewServer know that a writer wants to write. * To get that permission, the writer performs a second communication on * writerControl - see above. *

* After accepting a writer request, CrewServer refuses further * communications on request and writerControl until all readers have * finished - which they do by signalling on readerRelease: *

 *   public void endRead () {
 *     readerRelease.write (0);
 *   }
 * 
* Refusing the request channel parks newly arriving readers and writers safely. * When all existing readers have gone away, CrewServer accepts the outstanding * communication on writerControl, which gives the waiting writer permission * to write. CrewServer then waits for a second communication on * writerControl, which is the signal from the writer that it has finished writing: *
 *   public void endWrite () {
 *     writerControl.write (0);
 *   }
 * 
* before returning to its initial state (listening on request and * readerRelease). *

* The logic is easier to explain in JCSP: *

 * package org.jcsp.lang;
 * 
 * class CrewServer implements CSProcess {      // this is not a public class
 * 
 *   public static final int READER = 0;
 *   public static final int WRITER = 1;
 * 
 *   private final AltingChannelInputInt request;
 *   private final ChannelInputInt writerControl;
 *   private final AltingChannelInputInt readerRelease;
 * 
 *   public CrewServer (final AltingChannelInputInt request,
 *                      final ChannelInputInt writerControl,
 *                      final AltingChannelInputInt readerRelease) {
 *     this.request = request;
 *     this.writerControl = writerControl;
 *     this.readerRelease = readerRelease;
 *   }
 * 
 *   public void run () {
 *     int nReaders = 0;
 *     Guard[] c = {readerRelease, request};
 *     final int READER_RELEASE = 0;
 *     final int REQUEST = 1;
 *     Alternative alt = new Alternative (c);
 *     while (true) {
 *       // invariant : (nReaders is the number of current readers) and
 *       // invariant : (there are no writers)
 *       switch (alt.priSelect ()) {
 *         case READER_RELEASE:
 *           readerRelease.read ();         // always let a reader finish reading
 *           nReaders--;
 *         break;
 *         case REQUEST:
 *           switch (request.read ()) {
 *             case READER:
 *               nReaders++;                // let a reader start reading
 *             break;
 *             case WRITER:
 *               for (int i = 0; i < nReaders; i++) {
 *                 readerRelease.read ();   // wait for all readers to go away
 *               }
 *               nReaders = 0;
 *               writerControl.read ();     // let the writer start writing
 *               writerControl.read ();     // wait for writer to finish writing
 *             break;
 *           }
 *         break;
 *       }
 *     }
 *   }
 * 
 * }
 * 
* Note that a CrewServer cannot be misused by reader and writer processes. * It is private to each Crew lock and operated correctly by the * methods of that lock. Given this correct operation, it is trivial to establish * the declared loop invariant. All readers and writers start by communicating * on the request channel so, so long as that is * fairly serviced and that no read or write lasts forever, * processes cannot be indefinitely blocked (e.g. readers by writers or writers by readers). * *

Cautionary Note

* Fair servicing of readers and writers in the above depends on fair * servicing of the {@link Any2OneChannelInt any-1} request and * readerRelease channels. In turn, this depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for JCSP's * any-1 channels or Crew locks. * * @author P.H. Welch */ public class Crew { private final Any2OneChannelIntImpl request = new Any2OneChannelIntImpl(); private final One2OneChannelIntImpl writerControl = new One2OneChannelIntImpl(); private final Any2OneChannelIntImpl readerRelease = new Any2OneChannelIntImpl(); ///TODO make this poison the existing channels, once poison is added private final Any2OneChannelIntImpl poison = new Any2OneChannelIntImpl(); private final ProcessManager manager = new ProcessManager(new CrewServer(request.in(), writerControl.in(), readerRelease.in(), poison.in())); private final Object shared; /** * Construct a lock for CREW-guarded operations on a shared resource. */ public Crew() { manager.start(); shared = null; } /** * Construct a lock for CREW-guarded operations on a shared resource. * * @param shared the shared resource for which this lock is to be used (see * {@link #getShared getShared}). */ public Crew(Object shared) { manager.start(); this.shared = shared; } /** * Finalize method added to terminate the process that it spawned. The spawned process holds no references * to this object so this object will eventually fall out of scope and gets finalized. */ protected void finalize() throws Throwable { poison.write(0); } /** * This must be invoked before any read operations on the associated shared resource. */ public void startRead() { request.write(CrewServer.READER); } /** * This must be invoked after any read operations on the associated shared resource. */ public void endRead() { readerRelease.write(0); } /** * This must be invoked before any write operations on the associated shared resource. */ public void startWrite() { request.write(CrewServer.WRITER); writerControl.write(0); // wait for all current readers to finish } /** * This must be invoked after any write operations on the associated shared resource. */ public void endWrite() { writerControl.write(0); } /** * This returns the shared resource associated with this lock by its * {@link #Crew(java.lang.Object) constructor}. * Note: if the {@link #Crew parameterless constructor} was used, * this will return null. * * @return the shared resource associated with this lock. */ public Object getShared() { return shared; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/InlineAlternative.java0000644000000000000000000002566511113402355020354 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; // (NCCB) what is the reason for this class, over and above using a simple flat Alternative? /** * This class is experimental (i.e. not properly documented yet). * It is intended to allow {@link Alternative}s to be nested. * * @author Quickstone Technologies Limited * */ public class InlineAlternative extends Guard { /** Flags to control behaviour of this ALT if used as a guard. */ public static final int MODE_ARBITRARY = 0, MODE_FAIR = 1, MODE_PRI = 2; /** If used as a top level ALT, the work will be delegated to this */ private Alternative alt; /** Mode of the select */ private int selectMode; /** Index last selected */ private int selected; /** Index to favour (fair / pri) */ private int favourite; /** The preconditions set for the ALT when it is being used as a guard. */ private boolean[] preconditions; /** The guards */ private final Guard[] guard; /** The timer guards */ private final CSTimer[] timers; /** Nested ALTs */ private final InlineAlternative[] ialts; /** Timeout index */ private int timeoutIndex; /** Shortest alarm set by a timer */ private long minAlarm; /** Creates a new one */ public InlineAlternative(Guard[] guards) { this(guards, MODE_ARBITRARY); } /** Creates a new one */ public InlineAlternative(Guard[] guards, int mode) { super(); guard = guards; selectMode = mode; timers = new CSTimer[guards.length]; ialts = new InlineAlternative[guards.length]; for (int i = 0; i < guards.length; i++) if (guards[i] instanceof CSTimer) timers[i] = (CSTimer)guards[i]; else if (guards[i] instanceof InlineAlternative) ialts[i] = (InlineAlternative)guards[i]; } /** * Returns the index of the guard obtained by a call to select() or if this guard became ready within its parent ALT. */ public int getSelected() { if (selectMode == MODE_FAIR) { favourite = selected + 1; if (favourite == guard.length) favourite = 0; } return selected; } /** * Establishes a precondition array that will be used by default in calls to select(). This is useful when the ALT * is used as a guard within another ALT. */ public void setPreconditions(boolean[] precons) { preconditions = precons; } /** * Alters the precondition on a guard. */ public void setPreconditionByIndex(int index, boolean on) { if (preconditions == null) { preconditions = new boolean[guard.length]; for (int i = 0; i < preconditions.length; i++) preconditions[i] = true; } preconditions[index] = on; } /** * Returns the actual guard object corresponding to the selected guard. For example it can return the channel * or the ALT object. */ public Guard getSelectedGuard() { return guard[selected]; } /** * Returns the guard object at a given index. For example to obtain a channel or ALT object. */ public Guard getGuardByIndex(int index) { return guard[index]; } /** * Creates an Alternative (if needed) and delegates the call to it. */ public int select() { if (alt == null) alt = new Alternative(guard); if (preconditions != null) return alt.select(preconditions); else return alt.select(); } /** * Creates an Alternative (if needed) and delegates the call to it. */ public int priSelect() { if (alt == null) alt = new Alternative(guard); if (preconditions != null) return alt.priSelect(preconditions); else return alt.priSelect(); } /** * Creates an Alternative (if needed) and delegates the call to it. */ public int fairSelect() { if (alt == null) alt = new Alternative(guard); if (preconditions != null) return alt.fairSelect(preconditions); else return alt.fairSelect(); } /** * Enable this ALT as a guard within its parent ALT. This will enable all of its guards. */ boolean enable(Alternative alt) { timeoutIndex = -1; for (int i = favourite; i < guard.length; i++) { if ((preconditions == null) || (preconditions[i])) { if (guard[i].enable(alt)) { selected = i; return true; } if (timers[i] != null) { if (timeoutIndex < 0) { timeoutIndex = i; minAlarm = timers[i].getAlarm(); } else { long a = timers[i].getAlarm(); if (a < minAlarm) { timeoutIndex = i; minAlarm = a; } } } else if (ialts[i] != null) { if (timeoutIndex < 0) { timeoutIndex = i; minAlarm = ialts[i].minAlarm; } else { long a = ialts[i].minAlarm; if (a < minAlarm) { timeoutIndex = i; minAlarm = a; } } } } } for (int i = 0; i < favourite; i++) { if ((preconditions == null) || (preconditions[i])) { if (guard[i].enable(alt)) { selected = i; return true; } if (timers[i] != null) { if (timeoutIndex < 0) { timeoutIndex = i; minAlarm = timers[i].getAlarm(); } else { long a = timers[i].getAlarm(); if (a < minAlarm) { timeoutIndex = i; minAlarm = a; } } } else if (ialts[i] != null) { if (timeoutIndex < 0) { timeoutIndex = i; minAlarm = ialts[i].minAlarm; } else { long a = ialts[i].minAlarm; if (a < minAlarm) { timeoutIndex = i; minAlarm = a; } } } } } selected = -1; return false; } /** * Disable this ALT as a guard within its parent ALT. This will disable all of its guards. */ boolean disable() { boolean result = false; int startIndex; if (selected == -1) startIndex = favourite - 1; else startIndex = selected - 1; if (startIndex < favourite) { for (int i = startIndex; i >= 0; i--) { if (((preconditions == null) || (preconditions[i])) && guard[i].disable()) { result = true; selected = i; } } startIndex = guard.length - 1; } for (int i = startIndex; i >= favourite; i--) { if (((preconditions == null) || (preconditions[i])) && guard[i].disable()) { result = true; selected = i; } } if (selected == -1) { // We might be here because no guards were ready or because a timer // returned early. The workaround in the Alternative class will make // it OK to return FALSE. However it will probe down into the nested // ALTs so we must set 'selected' to refer to the timer, or point to // the nested ALT which contains the timer. selected = timeoutIndex; } return result; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ProcessManager.java0000644000000000000000000002750611105701167017650 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This enables a {@link CSProcess} to be spawned * concurrently with the process doing the spawning. *

* Shortcut to the Constructor and Method Summaries. * *

Description

* The ProcessManager class enables a {@link CSProcess} to be spawned * concurrently with the process doing the spawning. The class provides * methods to manage the spawned process: {@link #start start}, * {@link #join join} and {@link #stop stop}. The spawned process may, of course, * be a {@link Parallel} network of processes to any depth of nesting, in which * case the whole network comes under this management. *

* Spawning processes is not the normal way of creating a network in JCSP - the * normal method is to use the {@link Parallel} class. However, when we need * to add processes in response to some run-time event, this capability is very * useful. *

* For completeness, ProcessManager is itself a CSProcess * - {@link #run run}ning a ProcessManager simply runs the process * it is managing. *

* *

Spawning a CSProcess

* * This example demonstrates that the managed CSProcess is * executed concurrently with the spawning process and that it dies when * its manager terminates. The managed process is `infinite' and * just counts and chatters. The managed process is automatically terminated * if the main Java thread terminates (as in the case, eventually, below). *
 * import org.jcsp.lang.*;
 * 
 * public class ProcessManagerExample1 {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final ProcessManager manager = new ProcessManager (
 *       new CSProcess () {
 *         public void run () {
 *           final CSTimer tim = new CSTimer ();
 *           long timeout = tim.read ();
 *           int count = 0;
 *           while (true) {
 *             System.out.println (count + " :-) managed process running ...");
 *             count++;
 *             timeout += 100;
 *             tim.after (timeout);   // every 1/10th of a second ...
 *           }
 *         }
 *       }
 *     );
 * 
 *     final CSTimer tim = new CSTimer ();
 *     long timeout = tim.read ();
 * 
 *     System.out.println ("\n\n\t\t\t\t\t
 *                         *** start the managed process");
 *     manager.start ();
 * 
 *     for (int i = 0; i < 10; i++) {
 *       System.out.println ("\n\n\t\t\t\t\t
 *                           *** I'm still executing as well");
 *       timeout += 1000;
 *       tim.after (timeout);         // every second ...
 *     }
 * 
 *     System.out.println ("\n\n\t\t\t\t\t
 *                         *** I'm finishing now!");
 *   }
 * }
 * 
* *

Stopping, Interrupting, Race-Hazards and Poison

* * Stopping a Java thread releases any locks it (or any sub-process) may be * holding, so this reduces the danger of other threads deadlocking through * a failure to acquire a needed lock. * However, if the stopped process were in the middle of some synchronised * transaction, the data update may be incomplete (and, hence, corrupt) * depending on the precise moment of the stopping. This is a race-hazard. * Further, if some other thread later needed to interact with the stopped * thread, it would deadlock. *

* Instead of stopping a JCSP process, it is much safer to * {@link #interrupt() interrupt} it. * This gives the process the chance to notice the interrupt (through an * exception handler) and tidy up. * If no such handler is provided and the JCSP process attempts any * synchronisation afterwards, the process will bomb out with * a {@link ProcessInterruptedException}. *

* For historical reasons, a {@link #stop()} method is provided below – * but it is implemented as {@link #interrupt()} (and deprecated). *

* If the managed process has gone parallel, managing an interrupt to achieve * a clean exit is more tricky. * Stopping a network by setting a global volatile flag that each process polls * from time to time is not safe. * For example, a thread blocked on a monitor wait will remain blocked * if the thread that was going to notify it spots the shut-down flag * and terminates. *

* For JCSP processes, there is a general solution to this [`Graceful Termination * and Graceful Resetting', P.H.Welch, Proceedings of OUG-10, pp. 310-317, * Ed. A.W.P.Bakkers, IOS Press (Amsterdam), ISBN 90 5199 011 1, April, 1989], * based on the careful distribution of poison over the network's normal * communication channels. *

* However, JCSP now supports graceful termination of process networks and sub-networks * through a notion of poisoning synchoronisation objects (e.g. channels) * – see {@link Poisonable}. * * @see org.jcsp.lang.CSProcess * @see org.jcsp.lang.Parallel * @see org.jcsp.awt.ActiveApplet * @see org.jcsp.lang.Poisonable * @see org.jcsp.lang.PoisonException * * @author P.H. Welch * @author P.D. Austin */ public class ProcessManager implements CSProcess { /** * The maximum priority value for running a process. */ public static final int PRIORITY_MAX = Thread.MAX_PRIORITY; /** * The normal priority value for running a process. */ public static final int PRIORITY_NORM = Thread.NORM_PRIORITY; /** * The minimum priority value for running a process. */ public static final int PRIORITY_MIN = Thread.MIN_PRIORITY; /** The CSProcess to be executed by this ProcessManager */ private final CSProcess process; /** The thread supporting the CSProcess being executed by this ProcessManager */ private Thread thread; /** * @param proc the {@link CSProcess} to be executed by this ProcessManager */ public ProcessManager(CSProcess proc) { this.process = proc; thread = new Thread() { public void run() { try { Parallel.addToAllParThreads(this); process.run(); } catch (Throwable e) { Parallel.uncaughtException("org.jcsp.lang.ProcessManager", e); } finally { Parallel.removeFromAllParThreads(this); } } }; thread.setDaemon(true); } //}}} //{{{ public void start () /** * Start the managed process (but keep running ourselves). */ public void start() { thread.start(); } /** * Start the managed process at a specified priority * (but keep running ourselves). The priority of the * ProcessManager that this is called upon * will remain at the specified priority once the process * has terminated. * * The priority should be specified as an int between * PRIORITY_MIN and PRIORITY_MAX. * * @param priority the priority at which to start the process. */ public void start(int priority) { thread.setPriority(priority); start(); } /** * Stop (permanently) the managed process. * * This method now calls interrupt(), which will not always stop the process. * * @deprecated */ public void stop() { interrupt(); } /** * Interrupt the managed process. This will usually cause the process to throw a * {@link ProcessInterruptedException}, which will likely halt the process. */ public void interrupt() { thread.interrupt(); } /** * Join the managed process (that is wait for it to terminate). */ public void join() { try { thread.join(); } catch (InterruptedException e) { throw new ProcessInterruptedException("Joining process " + process); } } /** *

* Run the managed process (that is start it and wait for it to terminate). * This will adjust the priority of the calling process to the priority of * this ProcessManager and then return the priority to the * previous value once the managed process has terminated. *

* *

* The managed process can be run at the caller's priority simply by directly * calling the CSProcess object's run() method. *

*/ public void run() { int oldPriority = Thread.currentThread().getPriority(); Thread.currentThread().setPriority(thread.getPriority()); process.run(); Thread.currentThread().setPriority(oldPriority); } /** *

* Public mutator for setting the ProcessManager object's * process' priority. *

*

* The priority should be specified as an int between * PRIORITY_MIN and PRIORITY_MAX. *

* * @param priority the priority to use. */ public void setPriority(int priority) { thread.setPriority(priority); } /** *

* Public accessor for obtaining the ProcessManager object's * process' priority. *

* * @return the priority at which the ProcessManager object's * process will be run. */ public int getPriority() { return thread.getPriority(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneCallChannel.java0000644000000000000000000004510411105701167020263 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * This is the super-class for one-to-one interface-specific CALL channels. *

* Shortcut to the Constructor and Method Summaries. * *

Description

* Normal method invocation between objects is sometimes refered to as message-passing * between a client (the invoker of the method) object and a server object * (the invoked). Information flows from the client (the method name and parameter values) * to the server, which reacts in some way (possibly changing state) and may return * information back to the client (via the method result or, indirectly, by changing values * referenced by the method parameters). *

* This corresponds loosely with the client-server communication pattern between * active processes, but where information flows over a pair of channels connecting * them. However, there are major semantic differences between the two mechanisms. * A server process is in charge of its own life, can act spontaenously and * can refuse to accept a client call. A server object is passive, never does * anything unless invoked and, then, has no choice but to obey. We must be careful, * therefore, not to become confused by the same words computer scientists have chosen * to mean very different things. *

* CALL channels risk deepening this confusion. They provide a method interface for * client-server communication between active processes, yet their semantics * remain those of a synchronising zero-buffered channel. However, the attraction of * replacing a sequence of channel write(s) and read (matched at * the other end of the channel-pair by a sequence of channel read(s) and * write) with a single method invocation (and a single matching * {@link #accept accept}) makes this risk worthwhile. *

* [Note: CALL channels were part of the occam3 language specification. * They provide an extended rendezvous in the sense of an Ada entry, * but are considerably more flexible and lightweight.] * *

Converting a Method Interface into a Variant CALL Channel

* A CALL channel must be individually constructed to support a specific method * interface. This is done by extending this class to implement that * interface in the manner outlined below. The calling (i.e. client) * process just sees that interface and invokes its methods. The callee * (i.e. server) process just sees the {@link #accept accept} method * of the CALL channel and invokes that (supplying itself as argument). Both actions * are voluntary and have to occur for the communication to take place. *

* * Consider the following: *

 * interface Foo {
 * 
 *   public Bar calculate (...);
 *   public void processQuery (...);
 *   public boolean closeValve (...);
 * 
 * }
 * 
* * Deriving the corresponding CALL channel is mechanical and could easilly be automated: *
 * import org.jcsp.lang.*;
 * 
 * public class One2OneFooChannel extends One2OneCallChannel implements Foo {
 * 
 *   public static final int CALCULATE = 0;           // optional
 *   public static final int PROCESS_QUERY = 1;       // optional
 *   public static final int CLOSE_VALVE = 2;         // optional
 * 
 *   public Bar calculate (...) {
 *     join ();                                       // ready to make the CALL
 *     Bar result = ((Foo) server).calculate (...);
 *     selected = CALCULATE;                          // optional
 *     fork ();                                       // call finished
 *     return result;
 *   }
 * 
 *   public void processQuery (...) {
 *     join ();                                       // ready to make the CALL
 *     ((Foo) server).processQuery (...);
 *     selected = PROCESS_QUERY;                      // optional
 *     fork ();                                       // call finished
 *   }
 * 
 *   public boolean closeValve (...) {
 *     join ();                                       // ready to make the CALL
 *     boolean result = ((Foo) server).closeValve (...);
 *     selected = CLOSE_VALVE;                        // optional
 *     fork ();                                       // call finished
 *     return result;
 *   }
 * 
 * }
 * 
* The above methods will be called by the client process. * The {@link #join join} will not complete until the server invokes * an {@link #accept accept} on this channel. * That accept will not complete until the client reaches * the {@link #fork fork}. This gives the zero-buffered fully synchronised * semantics of CSP channel communication. *

* In between the join and the fork, the client and server * processes are locked together in extended rendezvous, commonly executing * the chosen method in the server environment. * [Actually, it is the client that invokes the method on the server, * temporarilly referenced by the {@link #server server} field from this * One2OneCallChannel super-class and blocked waiting for its accept * to complete.] * Setting the {@link #selected selected} field is optional. However, its value * is returned to the server by the {@link #accept accept} method and * can be used (as in the above) to let the server know which of its methods * the client invoked. *

* [Note: a One2OneFooChannel is only safe to use between a single * client and a single server. Any-1, 1-Any and Any-Any * versions may be derived from {@link Any2OneCallChannel}, {@link One2AnyCallChannel} * and {@link Any2AnyCallChannel} (respectively) using exactly the same pattern * as above.] * *

Calling a CALL Channel

* All the client needs to see is the method interface * implemented by the CALL channel. For example: *
 * import org.jcsp.lang.*;
 * 
 * public class A implements CSProcess {
 * 
 *   private final Foo out;
 * 
 *   public A (final Foo out) {
 *     this.out = out;
 *   }
 * 
 *   public void run () {
 *     ...
 *     Bar t = out.calculate (...);
 *     ...
 *     out.processQuery (...);
 *     ...
 *     if (! out.closeValve (...)) ...;
 *     ...
 *   }
 * 
 * }
 * 
* [Note: this means, of course, that a client is blind to the variety of CALL channel * it is calling. It may be connected to its server(s) via a 1-1, Any-1, * 1-Any or Any-Any link without any change in its coding.] * *

Accepting a CALL Channel

* To receive the calls forwarded by the CALL channel, the server needs to implement * the same interface. To accept a call, it invokes the * {@link #accept accept} method of the CALL channel, passing itself (usually * this) as the argument. All it needs to see, therefore, is * the {@link ChannelAccept} interface implemented by the channel. For example: *
 * import org.jcsp.lang.*;
 * 
 * class B implements CSProcess, Foo {
 * 
 *   private final ChannelAccept in;
 * 
 *   public B (final One2OneFooChannel in) {
 *     this.in = in;
 *   }
 * 
 *   ...  other fields, methods etc.
 * 
 *   ...  implementation of Foo methods
 * 
 *   public void run () {        // controls when Foo invocations are acceptable
 *     ...
 *     in.accept (this);                   // don't care which method was called
 *     ...
 *     switch (in.accept (this)) {         // care which method was called
 *       case One2OneFooChannel.CALCULATE:
 *         ...
 *       break;
 *       case One2OneFooChannel.PROCESS_QUERY:
 *         ...
 *       break;
 *       case One2OneFooChannel.CLOSE_VALVE:
 *         ...
 *       break;
 *     }]
 *     ...
 *     in.accept (this);                   // don't care which method was called
 *     ...
 *   }
 * 
 * }
 * 
* However, it is not very secure for a server process (like B) to advertise * a standard method interface (like Foo). In the above example, there is * the danger that someone might try to invoke one of the Foo methods * directly on an instance of B (e.g. by plugging an instance of B, * instead of the CALL channel, into an instance of A). * That would not be a good idea! *

* It is also semantically misleading - B's interface is through the CALL channel * passed to its constructor, not through its (necessarilly public) Foo * methods. *

* So, B should not be the public server process - we need to hide * its directly invocable methods. A simple way to do this is to wrap it up in * another process that simply omits the public declaration of the relevant interface: *

 * import org.jcsp.lang.*;
 * 
 * public class B2 implements CSProcess {            // no Foo interface
 * 
 *   private final B b;
 * 
 *   public B2 (final One2OneFooChannel in) {
 *     b = new B (in);
 *   }
 * 
 *   public void run () {
 *     b.run ();
 *   }
 * 
 * }
 * 
* Notice that this wrapper imposes no run-time overhead, apart from a small start-up cost. * The hidden inner process does all the work and has direct access to the CALL * channel and, hence, to the client. *

* [Note: the only difference needed in the server code to support * Any-1, 1-Any and Any-Any CALL channels is in the parameter * declaration that specifies the variety to be used. For complete flexibility, * constructors (or setFooChannel methods) for each kind * (i.e. One2OneFooChannel, * Any2OneFooChannel, * One2AnyFooChannel and * Any2AnyFooChannel * may be provided.] * *

ALTing on a CALL Channel

* This class is a sub-class of {@link Guard} and, therefore, its derived CALL channels * may be included in a Guard array associated with an {@link Alternative}. * Hence, the server may ALT between any mixture of CALL channels, ordinary * channels, {@link CSTimer timeouts} and {@link Skip Skips}. *

* However, when implementing the server, the CALL channel field needs to be declared as * an {@link AltingChannelAccept}, rather than a {@link ChannelAccept}. * So, in the above example, the first field declaration of B * needs to become: *

 *   private final AltingChannelAccept in;
 * 
* See Any2OneCallChannel for an example of ALTing between CALL channels. *

* [Note: a server may ALT on a Any-1 CALL channel with this same change. * However, as for ordinary channels, ALTing over 1-Any or Any-Any versions * is not supported.] * *

Building a CALL Channel Network

* Network building with CALL channels is the same as building with ordinary * channels. First construct the channels and, then, construct the processes * - plugging in the channels as required and running them in {@link Parallel}. *

* For example, the simple two process network: *

* is implemented by: *
 *     One2OneFooChannel c = new One2OneFooChannel ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new A (c),
 *         new B2 (c)
 *       }
 *     ).run ();
 * 
*

* [Note: simple network examples using * Any-1, * 1-Any * and Any-Any CALL channels * are given in their respective classes.] * *

Example

* Please see Any2OneCallChannel for an example that includes one server, * ALTing between two (Any-1) CALL channels, and lots of clients. * * @see org.jcsp.lang.Any2OneCallChannel * @see org.jcsp.lang.One2AnyCallChannel * @see org.jcsp.lang.Any2AnyCallChannel * @see org.jcsp.lang.Alternative * * @author P.H. Welch */ public abstract class One2OneCallChannel extends AltingChannelAccept implements Serializable { /** * This is used to synchronise the calling and accepting process. */ final private One2OneChannelImpl c = new One2OneChannelImpl(); /** * This holds a reference to a server process so that a client may * make the call. The reference is only valid between the {@link #join join} * and {@link #fork fork} elements of the standard * calling sequence. * As shown in that sequence, it will need casting up to the relevant interface * supported by the specific CALL channel derived from this class. */ protected CSProcess server; /** * This may be set during the standard calling sequence to record * which method was invoked by a client. It is only safe to do this between * the {@link #join join} and {@link #fork fork} elements of * that sequence. Either all the CALL * channel methods should do this or none - in the latter case, its default * value remains as zero. Its value is returned to a server as the result * the server's invocation of {@link #accept accept}. */ protected int selected = 0; /** * This is invoked by a server when it commits to accepting a CALL * from a client. The parameter supplied must be a reference to this server * - see the example above. It will not complete until a CALL * has been made. If the derived CALL channel has set the {@link #selected} field * in the way defined by the standard calling sequence, * the value returned by this method will indicate which method was called. * * @param server the server process receiving the CALL. */ public int accept(CSProcess server) { this.server = server; c.read(); // ready to ACCEPT the CALL c.read(); // wait until the CALL is complete return selected; } /** * This is invoked by a client during the standard calling * sequence. It will not complete until a server invokes * an {@link #accept accept} on this channel. In turn, that accept * will not complete until the client invokes a {@link #fork fork}, * after having made its CALL on the server. */ protected void join() { c.write(null); } /** * This is invoked by a client during the standard calling * sequence. A server must have invoked an {@link #accept accept} * for the client to have got this far in the sequence - see * the {@link #join join}. This call unblocks that accept, * releasing the server and client to resume separate lives. */ protected void fork() { c.write(null); } /** * This is one of the {@link Guard} methods needed by the {@link Alternative} class. */ boolean enable(Alternative alt) { return c.readerEnable(alt); } /** * This is one of the {@link Guard} methods needed by the {@link Alternative} class. */ boolean disable() { return c.readerDisable(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneChannelIntImpl.java0000644000000000000000000000510611105701167020770 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements an any-to-one integer channel, * safe for use by many writers and one reader.Refer to the {@link Any2OneChannelInt} interface for * a fuller description. * * @see org.jcsp.lang.One2OneChannelIntImpl * @see org.jcsp.lang.One2AnyChannelIntImpl * @see org.jcsp.lang.Any2AnyChannelIntImpl * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin and P.H. Welch */ class Any2OneChannelIntImpl extends Any2OneIntImpl { Any2OneChannelIntImpl() { super(new One2OneChannelIntImpl()); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/MultiwaySynchronisation.java0000644000000000000000000000377311113671251021664 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; interface MultiwaySynchronisation {} jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableAltingChannelInputImpl.java0000644000000000000000000000550211113671251023260 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class RejectableAltingChannelInputImpl extends RejectableAltingChannelInput { private ChannelInternals channel; private int immunity; RejectableAltingChannelInputImpl(ChannelInternals _channel, int _immunity) { channel = _channel; immunity = _immunity; } public boolean pending() { return channel.readerPending(); } boolean disable() { return channel.readerDisable(); } boolean enable(Alternative alt) { return channel.readerEnable(alt); } public void endRead() { channel.endRead(); } public Object read() { return channel.read(); } public Object startRead() { return channel.startRead(); } public void poison(int strength) { if (strength > immunity) { channel.readerPoison(strength); } } public void reject() { channel.readerPoison(Integer.MAX_VALUE); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BlackHoleChannel.java0000644000000000000000000000661411105701167020051 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements {@link ChannelOutput} with black hole semantics. *

Description

* BlackHoleChannel is an implementation of {@link ChannelOutput} that yields * black hole semantics for the channel. Writers may always write but there can be * no readers. Any number of writers may share the same black hole. *

* Note: BlackHoleChannels are used for masking off unwanted outputs * from processes. They are useful when we want to reuse an existing process component * intact, but don't need some of its output channels (i.e. we don't want to redesign * and reimplement the component to remove the redundant channels). Normal channels cannot * be plugged in and left dangling as this may deadlock (parts of) the component being * reused. *

* * @see org.jcsp.lang.ChannelOutput * @see org.jcsp.lang.One2OneChannel * @see org.jcsp.lang.Any2OneChannel * @see org.jcsp.lang.One2AnyChannel * @see org.jcsp.lang.Any2AnyChannel * * @author P.H. Welch */ public class BlackHoleChannel implements ChannelOutput { /** * Write an Object to the channel and lose it. * * @param object the object to write to the channel. */ public void write(Object object) { } public void poison(int strength) { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyImpl.java0000644000000000000000000000667711113671251017041 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class One2AnyImpl implements One2AnyChannel, ChannelInternals { private ChannelInternals channel; /** The mutex on which readers must synchronize */ private final Mutex readMutex = new Mutex(); One2AnyImpl(ChannelInternals _channel) { channel = _channel; } public SharedChannelInput in() { return new SharedChannelInputImpl(this,0); } public ChannelOutput out() { return new ChannelOutputImpl(channel,0); } public void endRead() { channel.endRead(); readMutex.release(); } public Object read() { readMutex.claim(); //A poison exception might be thrown, hence the try/finally: try { return channel.read(); } finally { readMutex.release(); } } //begin never used: public boolean readerDisable() { return false; } public boolean readerEnable(Alternative alt) { return false; } public boolean readerPending() { return false; } //end never used public void readerPoison(int strength) { readMutex.claim(); channel.readerPoison(strength); readMutex.release(); } public Object startRead() { readMutex.claim(); try { return channel.startRead(); } catch (RuntimeException e) { channel.endRead(); readMutex.release(); throw e; } } //begin never used public void write(Object obj) { channel.write(obj); } public void writerPoison(int strength) { channel.writerPoison(strength); } //end never used } jcsp-1.1-rc4.orig/src/org/jcsp/lang/package.html0000644000000000000000000001631711077567615016373 0ustar This provides classes and interfaces corresponding to the fundamental primitives of CSP.

Processes, Networks and Synchronisation

In JCSP, a process is an instance of a class implementing the {@link org.jcsp.lang.CSProcess} interface - its behaviour being determined by the implementation of its run() method. Processes may be composed in {@link org.jcsp.lang.Sequence} or {@link org.jcsp.lang.Parallel} (or {@link org.jcsp.lang.PriParallel}), the result of this composition being another process. Processes may also be spawned to run concurrently with the spawning process - see {@link org.jcsp.lang.ProcessManager}. A collection of parallel processes is called a network.

Processes encapsulate both data and algorithms. Parallel processes interact either by synchronised communication along {@link org.jcsp.lang.Channel}s (the cleanest and simplest way) or by synchronised access to shared objects. The latter synchronisation may be achieved through channel signals or by a range of other JCSP primitives (such as {@link org.jcsp.lang.Barrier}, {@link org.jcsp.lang.AltingBarrier}, {@link org.jcsp.lang.Bucket} or {@link org.jcsp.lang.Crew}).

Channels

Channels come in two varieties: those that carry Object references and those that carry ints. For completeness, JCSP should provide channels specific to all the Java primitive types. These could trivially be added but, so far, do not seem to be needed in practice. Specialised channels, using Java generics, are easy to add and will be done soon – please mail us if you have urgent need.

Channels (from the Point of View of a Process)

Processes should drive their channels through channel ends: {@link org.jcsp.lang.ChannelInput} / {@link org.jcsp.lang.ChannelOutput} (for Object channels) and {@link org.jcsp.lang.ChannelInputInt} / {@link org.jcsp.lang.ChannelOutputInt} (for int channels). To allow choice of receiving input (see next paragraph), processes must drive their channels through {@link org.jcsp.lang.AltingChannelInput} / {@link org.jcsp.lang.AltingChannelInputInt} (rather than {@link org.jcsp.lang.ChannelInput} / {@link org.jcsp.lang.ChannelInputInt}).

Processes may passively wait for a number of events using {@link org.jcsp.lang.Alternative}. These events include channel inputs ({@link org.jcsp.lang.AltingChannelInput} / {@link org.jcsp.lang.AltingChannelInputInt}), channel accepts ({@link org.jcsp.lang.AltingChannelAccept}), alting barriers ({@link org.jcsp.lang.AltingBarrier}), timeouts ({@link org.jcsp.lang.CSTimer}) and skips ({@link org.jcsp.lang.Skip}). If more than one event is ready, an {@link org.jcsp.lang.Alternative#select() arbitrary}, {@link org.jcsp.lang.Alternative#priSelect() prioritised} or {@link org.jcsp.lang.Alternative#select() fair} choice can be made between them. The super-interface for all these ALTable events is {@link org.jcsp.lang.Guard}.

Channels (from the Point of View of a Network)

Actual channels must be constructed by the {@link org.jcsp.lang.Parallel} network builder with appropriate channel ends passed to the processes needing them (usually via their constructors). Four varieties are available for Object channels: {@link org.jcsp.lang.One2OneChannel}, {@link org.jcsp.lang.Any2OneChannel}, {@link org.jcsp.lang.One2AnyChannel} and {@link org.jcsp.lang.Any2AnyChannel}. Similarly, four varieties are available for int channels: {@link org.jcsp.lang.One2OneChannelInt}, {@link org.jcsp.lang.Any2OneChannelInt}, {@link org.jcsp.lang.One2AnyChannelInt} and {@link org.jcsp.lang.Any2AnyChannelInt}. Please note that the last two in each set are not broadcasting channels - broadcasting has to be achieved by active processes (e.g. {@link org.jcsp.plugNplay.Delta}). Channels are constructed by the static manufacturing methods of the {@link org.jcsp.lang.Channel} class. Input and output channel ends are obtained from channels by their in() and out methods, respectively.

Note that the default semantics for all the above channels are zero-buffering and full synchronisation. This means that a writer to a channel will wait for a matching reader and vice-versa - whoever gets to the channel first will wait for its partner. Various forms of buffering can be introduced by splicing active buffer processes into these channels. However, because this is a common need, JCSP provides a range of plug-ins that can be used to create channels with the common varieties of buffering: {@link org.jcsp.util.Buffer blocking FIFO}, {@link org.jcsp.util.OverWriteOldestBuffer overwriting (oldest) FIFO}, {@link org.jcsp.util.OverWritingBuffer overwriting (latest) FIFO} and {@link org.jcsp.util.InfiniteBuffer infinite FIFO}. That set of plug-ins is for Object channels and comes from the {@link org.jcsp.util} package. A similar set for int channels is provided in {@link org.jcsp.util.ints}.

It is the network builder's responsibility to decide whether to use 1-1, any-1, 1-any or any-any channels and whether to incorporate buffers in them. The process designer is not concerned with these decisions - only with whether the channel is for input or output and what type of information it carries.

Call Channels

Call Channels provide a method interface for client-server communication between active processes, yet their semantics remain those of a synchronising zero-buffered channel. Without them, we would normally have to set up a pair of channels (giving bi-directional communication) and use a sequence of channel write(s) and read (at the client end) matched by a sequence of channel read(s) and write (at the server end).

The client process sees a server-specific method interface and invokes it in the normal way - however, the invocation will block until the server chooses to accept the call. The server sees the {@link org.jcsp.lang.ChannelAccept} interface - invoking an {@link org.jcsp.lang.ChannelAccept#accept accept} will block until the client makes a call.

The network builder constructs a server-specific actual call channel by sub-classing from one of {@link org.jcsp.lang.One2OneCallChannel}, {@link org.jcsp.lang.Any2OneCallChannel}, {@link org.jcsp.lang.One2AnyCallChannel} and {@link org.jcsp.lang.Any2AnyCallChannel}. Precise rules for making this extension are given in their documentation.

Symmetric Channels

Thanks to alting barriers ({@link org.jcsp.lang.AltingBarrier}), symmetric channels are now available: {@link org.jcsp.lang.One2OneChannelSymmetric} and {@link org.jcsp.lang.One2OneChannelSymmetricInt}. These work the same as ordinary channels but, in addition, their output ends can be used as guards in a choice ({@link org.jcsp.lang.Alternative}). It is quite safe for both the sending and receiving process to be alting on these symmetric channels. jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedConnectionServerImpl.java0000644000000000000000000000744011105701167022171 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This class does not need to be used by standard JCSP users. It is exposed so that the connection * mechanism can be extended for custom connections. * * @author Quickstone Technologies Limited */ public class SharedConnectionServerImpl implements SharedConnectionServer { private AltingConnectionServerImpl connectionServerToUse; private ChannelInput synchIn; private ChannelOutput synchOut; private ConnectionWithSharedAltingServer parent; protected SharedConnectionServerImpl(AltingChannelInput openIn, AltingChannelInput requestIn, ChannelInput synchIn, SharedChannelOutput synchOut, ConnectionWithSharedAltingServer parent) { connectionServerToUse = new AltingConnectionServerImpl(openIn, requestIn); this.synchOut = synchOut; this.synchIn = synchIn; this.parent = parent; } public Object request() { if (connectionServerToUse.getServerState() == AltingConnectionServerImpl.SERVER_STATE_CLOSED) synchOut.write(null); return connectionServerToUse.request(); } public void reply(Object data) { reply(data, false); } public void reply(Object data, boolean close) { connectionServerToUse.reply(data, close); if (connectionServerToUse.getServerState() == AltingConnectionServerImpl.SERVER_STATE_CLOSED) synchIn.read(); } public void replyAndClose(Object data) { reply(data, true); } public SharedConnectionServer duplicate() { return parent.server(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelInternals.java0000644000000000000000000000473211113671251020162 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; interface ChannelInternals { public Object read(); public void write(Object obj); public Object startRead(); public void endRead(); public boolean readerEnable(Alternative alt); public boolean readerDisable(); public boolean readerPending(); /*//For Symmetric channel, later: public boolean writerEnable(Alternative alt); public boolean writerDisable(); public boolean writerPending(); */ public void readerPoison(int strength); public void writerPoison(int strength); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Sequence.java0000644000000000000000000005110511105701167016477 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This constructor taks an array of CSProcesses * and returns a CSProcess that is the sequential composition of * its process arguments. *

* Shortcut to the Constructor and Method Summaries. *

Description

* The Sequence constructor taks an array of CSProcesses * and returns a CSProcess that is * the sequential composition of its process arguments. *

* Note: for those familiar with the occam programming * language, the Sequence class gives the semantics of the * SEQ construct. *

* This class is included for completeness. Sequential code is normally * be handled by sequential Java code. If we need to run some * CSProcesses in sequence, we can just execute their run * methods in sequence. However, using this Sequence class * lets us switch between sequential and parallel composition of processes * with a single word change (replace Sequence by Parallel) * in our code. For some applications (e.g. the example below), this may provide * a useful comparison. *

* CSProcesses can be added to a Sequence object either via the * {@link #Sequence(CSProcess[]) constructor} or the {@link #addProcess addProcess} * methods. If a call to addProcess is made while the * run method is executing, the extra process(es) will not be * executed until the next time run is invoked. *

* CSProcesses can be removed from Sequence object via * the {@link #removeProcess removeProcess} or * {@link #removeAllProcesses removeAllProcesses} method. * If a call to removeProcess or removeAllProcesses * is made while the run method is executing, the process will * not be removed from the network until the next time run is * invoked. *

*

Example - Matrix Multiply (in Sequence and in Parallel)

*

* The following example illustrates a simple transformation of sequential code * into parallel code. On a shared-memory parallel machine (e.g. a Symmetric * Multi-Processor) and depending on the overheads for starting up and shutting * down the concurrency and the scale of the problem to which it is applied, * the parallel code will terminate earlier than its sequential equivalent. * *

Sequential Implementation

* The example is simple matrix multiplication. The standard implementation * consists of three nested for-loops, the innermost of which computes * the dot-product of a row (of the first matrix) against a column (of * the second) to produce one element of the result matrix. It is expressed * here as a static method, which would belong to some larger collection of * static methods providing a general matrix handling class: *
 *   public static void multiply (final double[][] X,
 *                                final double[][] Y,
 *                                final double[][] Z) {
 * 
 *     ...  check (X[0].length == Y.length)
 *     ...  check (X.length == Z.length)
 *     ...  check (Y[0].length == Z[0].length)
 * 
 *     for (int i = 0; i < X.length; i++) {
 *       final double[] Xi = X[i];
 *       final double[] Zi = Z[i];
 *       for (int j = 0; j < Y[0].length; j++) {
 *         double sum = 0.0d;
 *         for (int k = 0; k < Y.length; k++) {
 *           sum += Xi[k]*Y[k][j];
 *         }
 *         Zi[j] = sum;
 *       }
 *     }
 * 
 *   }
 * 
* The method computes the matrix multiplication of X by Y, * leaving the result in Z. * The (hidden) checks ensure that the supplied arrays have compatible * dimensions for multiplication, throwing * a {@link java.lang.RuntimeException java.lang.RuntimeException} * if they are not. * The abbreviations Xi and Zi are not strictly * necessary, but for those brought up in an occam world are automatic * good practice - the Xi[k] reference * in the O(n3)-innermost loop saves * an array index computation and check. * *

Parallel Implementation

* The two outer for-loops of multiply * set up the particular row and column * pairs for the dot-product computed by the innermost loop. * Unnecessarilly, they impose an ordering in which those dot-products * are computed. Each dot-product computes one element of the result * matrix and is independent of its sibling dot-products. * The sequential constraint may, therefore, be removed and all elements * of the result matrix may be computed in parallel. *

* If this were occam, all we would need to do is replace the two outer * for-loops with par-loops. Since this is Java, we have * to jump through some slightly higher syntactic hoops. First, we need * to transform the body of the for-loop into a process and * use the loop to assign each one to consecutive elements of a process * array. Then, we simply run the array in parallel: *

 *   public static void parMultiply (final double[][] X,
 *                                   final double[][] Y,
 *                                   final double[][] Z) {
 * 
 *     ...  check array dimensions are compatible
 * 
 *     final CSProcess[] rowProcess = new CSProcess[X.length];
 * 
 *     for (int i = 0; i < X.length; i++) {
 *       final int ii = i;
 *       rowProcess[ii] = new CSProcess () {
 *         public void run () {
 *           final double[] Xi = X[ii];
 *           final double[] Zi = Z[ii];
 *           final double[][] YY = Y;
 *           for (int j = 0; j < YY[0].length; j++) {
 *             double sum = 0.0d;
 *             for (int k = 0; k < YY.length; k++) {
 *               sum += Xi[k]*YY[k][j];
 *             }
 *             Zi[j] = sum;
 *           }
 *         }
 *       };
 *     }
 * 
 *     new Parallel (rowProcess).run ();
 * 
 *   }
 * 
* [Note: anonymous inner classes, as in the above code, may only access * global variables that are qualified as final - hence, the need * to freeze the loop control index, i, as ii. * The abreviation YY, of Y, is so that access to that matrix * is via a variable local to the process. The global Y * could have been used, but at the cost of needless run-time overhead.] * *

Back to Sequential Implementation

* Having expressed this algorithm in terms of processes, we come to the * motivation for this example. To run a collection of processes, we must decide * whether to run them is parallel or sequence. JCSP makes either * decision equally easy to implement. The above coding ran them in parallel. * To revert to running them is sequence, all we need do is change the last line * of executable code to: *
 *     new Sequence (rowProcess).run ();
 * 
* It would probably be good to name this new method seqMultiply (instead * or parMultiply!). * Of course, it has the same behaviour as the original sequential multiply and * suffers only slightly increased overheads - negligible for matrices above a modest size. * *

Sequence versus Parallel

* Beware that it is only in certain circumstances that Sequence and Parallel * can be interchanged without upsetting the semantics of the system. The processes under * their control must be finite (i.e. they must all terminate), they must engage in * no synchronisations (e.g. channel communication) either between themselves or with * other processes and they must obey CREW-parallel usage rules (i.e. if one process * updates some data, no other process may look at it). These are fulfilled by * the rowProcess array, each of whose processes computes a separate row * (Zi) of the target result matrix (Z). * *

Exercise

* The above parMultiply has transformed only the outermost * for-loop of multiply into a par-loop. Current SMPs * do not scale well above 4 or 8 processors, so we do not need very large matrices * for this code to demonstrate high parallel efficiencies. Future architectures, * however, may offer much higher levels of physical concurrency that efficiently * support much finer granularities of process. For those machines and as an interesting * exercise, parallelise the middle for-loop. To exploit even finer levels * of parallel granularity, parallelise the innermost for-loop so that it * computes its dot-product in O(log(n)) time - rather than the O(n) time of * the sequential code. * *

Two Important Modifications on parMultiply

* The first time it is run, the JCSP {@link org.jcsp.lang.Parallel} process * creates a new {@link java.lang.Thread} for all but one of its component processes, * running its last component in the thread invoking the run. * When (and if) all those component processes terminate, the Parallel * run terminates but leaves the newly created threads parked for later use. * Subsequent runs of the Parallel process resuse those parked threads. * So the overhead of thread creation occurs only for the first run. *

* In parMultiply, however, the Parallel * process is anonymous and local to the method and so can never be used again. * Worse, the threads it created and parked are left parked - wasting space for * the remainder of the program. Repeated invocations of parMultiply, * therefore, will leak memory. *

* There are two ways to fix this. The first is to accept that the Parallel * process created by parMultiply remains local to it (and, hence, un-reusable) * and, explicitly, to unpark and terminate its unwanted threads. This can be done by * invoking {@link org.jcsp.lang.Parallel#releaseAllThreads releaseAllThreads} on * the Parallel after it has been run - the memory associated with * those threads will be released. A temporary name for the process needs to be * assigned and the last executable line of parMultiply * becomes the three lines: *

 *     final Parallel par = new Parallel (rowProcess);
 *     par.run ();
 *     par.releaseAllThreads ();
 * 
* * The second way to improve things is to save the Parallel process for later * runs. There is no easy way for doing this local to the class to which * parMultiply belongs. parMultiply is static and may be * invoked with matrix parameters of different dimensions. So, a static data * structure would need to be set up and consulted each time parMultiply was * invoked to see if a suitable Parallel process had already been saved. *

* Much better is to give the user of parMultiply the responsibilty of * looking after - and directly using, reusing and (if necessary) terminating the threads * in - the Parallel process. So, we change the method into something that * manufactures a process that does parallel matrix multiplication. * That multiplication will be specific to the three matrices given as parameters * (i.e. it performs Z = X*Y on those matrices only): *

 *   public static Parallel makeParMultiply (final double[][] X,
 *                                           final double[][] Y,
 *                                           final double[][] Z) {
 * 
 *     ...  check array dimensions are compatible                     // as before
 * 
 *     final CSProcess[] rowProcess = new CSProcess[X.length];        // as before
 * 
 *     for (int i = 0; i < X.length; i++) {                           // as before
 *       final int ii = i;                                            // as before
 *       rowProcess[ii] = new CSProcess () {                          // as before
 *         public void run () {                                       // as before
 *           final double[] Xi = X[ii];                               // as before
 *           final double[] Zi = Z[ii];                               // as before
 *           final double[][] YY = Y;                                 // as before
 *           for (int j = 0; j < YY[0].length; j++) {                 // as before
 *             double sum = 0.0d;                                     // as before
 *             for (int k = 0; k < YY.length; k++) {                  // as before
 *               sum += Xi[k]*YY[k][j];                               // as before
 *             }                                                      // as before
 *             Zi[j] = sum;                                           // as before
 *           }                                                        // as before
 *         }                                                          // as before
 *       };                                                           // as before
 *     }                                                              // as before
 * 
 *     return new Parallel (rowProcess);
 * 
 *   }
 * 
* The invoker of makeParMultiply gets back a parallel process that can be * invoked as often as needed and incurs a thread creation overhead only on its first use. * The data for the matrix parameters may be freely changed between invocations - each * invocation will work on whatever data is present at the time. All the user must * remember is that the manufactured parallel process is good only for working with * the matrix objects specified originally to makeParMultiply as its parameters. * For example, if Matrix is the class to which makeParMultiply belongs: *
 *     final Parallel par = Matrix.makeParMultiply (X, Y, Z);
 * 
 *     while (...) {
 *       ...  set up matrices X and Y
 *       par.run ();
 *       ...  do something with the result matrix Z
 *     }
 * 
 *     par.releaseAllThreads ();
 * 
* * * @see org.jcsp.lang.CSProcess * @see org.jcsp.lang.Parallel * * @author P.D. Austin * @author P.H. Welch */ public class Sequence implements CSProcess { /** The processes to be executed in sequence */ private CSProcess[] processes; /** The number of processes in this Sequence */ private int nProcesses = 0; // invariant : (0 <= nProcesses <= processes.length) /** * Construct a new Sequence object initially without any processes. */ public Sequence() { this(null); } /** * Construct a new Sequence object with the processes specified. * * @param processes the processes to be executed in sequence */ public Sequence(CSProcess[] processes) { if (processes != null) { nProcesses = processes.length; this.processes = new CSProcess[nProcesses]; System.arraycopy(processes, 0, this.processes, 0, nProcesses); } else { nProcesses = 0; this.processes = new CSProcess[0]; } } /** * Add the process to the Sequence object. * The extended network * will be executed the next time run() is invoked. * * @param process The CSProcess to be added */ public synchronized void addProcess(CSProcess process) { if (process != null) { final int targetProcesses = nProcesses + 1; if (targetProcesses > processes.length) { final CSProcess[] tmp = processes; processes = new CSProcess[2 * targetProcesses]; System.arraycopy(tmp, 0, processes, 0, nProcesses); } processes[nProcesses] = process; nProcesses = targetProcesses; } } /** * Add the array of processes to the Sequence object. * The extended network * will be executed the next time run() is invoked. * * @param newProcesses the processes to be added */ public synchronized void addProcess(CSProcess[] newProcesses) { if (processes != null) { final int extra = newProcesses.length; final int targetProcesses = nProcesses + extra; if (targetProcesses > processes.length) { final CSProcess[] tmp = processes; processes = new CSProcess[2 * targetProcesses]; System.arraycopy(tmp, 0, processes, 0, nProcesses); } System.arraycopy(newProcesses, 0, processes, nProcesses, extra); nProcesses = targetProcesses; } } /** * Remove a process from the Sequence object. The cut-down network * will be executed the next time run() is invoked. * * @param process the process to be removed */ public synchronized void removeProcess(CSProcess process) { for (int i = 0; i < nProcesses; i++) { if (processes[i] == process) { if (i < nProcesses - 1) System.arraycopy(processes, i + 1, processes, i, nProcesses - (i + 1)); nProcesses--; processes[nProcesses] = null; return; } } } /** * Remove all processes from the Sequence object. The cut-down network * will not be executed until the next time run() is invoked. */ public synchronized void removeAllProcesses() { for (int i = 0; i < nProcesses; i++) processes[i] = null; nProcesses = 0; } /** * Run the sequential composition of the processes registered with this * Sequence object. */ public void run() { for (int i = 0; i < nProcesses; i++) processes[i].run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyChannelIntImpl.java0000644000000000000000000000501011105701167020770 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements an any-to-any integer channel, * safe for use by many writers and many readers. Refer to the {@link Any2AnyChannelInt} interface * for more details. * * @see org.jcsp.lang.One2OneChannelImpl * @see org.jcsp.lang.Any2OneChannelImpl * @see org.jcsp.lang.One2AnyChannelImpl * * @author P.D. Austin and P.H. Welch */ class Any2AnyChannelIntImpl extends Any2AnyIntImpl { Any2AnyChannelIntImpl() { super(new One2OneChannelIntImpl()); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedOne2AnyChannelIntImpl.java0000644000000000000000000001161011105701167022430 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.*; /** * This implements a one-to-any integer channel with user-definable buffering, * safe for use by many writers and many readers. *

Description

* BufferedOne2AnyChannelIntImpl implements a one-to-any integer channel with * user-definable buffering. It is safe for use by any number of reading * processes but ony one writer. Reading processes compete with each other * to use the channel. Only one reader and the writer will actually be using * the channel at any one time. This is taken care of by * BufferedOne2AnyChannelIntImpl -- user processes just read from or write to it. *

* Please note that this is a safely shared channel and not * a multicaster. Currently, multicasting has to be managed by * writing active processes (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example of broadcasting). *

* All reading processes and writing processes commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ints.ChannelDataStoreInt ChannelDataStoreInt} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * *

Implementation Note and Caution

* Fair servicing of readers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * 1-any channels. * * @see org.jcsp.lang.BufferedOne2OneChannelIntImpl * @see org.jcsp.lang.BufferedOne2AnyChannelIntImpl * @see org.jcsp.lang.BufferedAny2AnyChannelIntImpl * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin * @author P.H. Welch */ class BufferedOne2AnyChannelIntImpl extends One2AnyIntImpl { public BufferedOne2AnyChannelIntImpl(ChannelDataStoreInt data) { super(new BufferedOne2OneChannelIntImpl(data)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Poisonable.java0000644000000000000000000001143611113671251017024 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * All channel-ends implement this inteface. *

* Channels are immune to poisoning unless explicitly constructed to be poisonable * (by those static methods in {@link Channel} that prescribe a level * of immunity – e.g. {@link Channel#one2one(int) this one}). *

*

* Poisonable channels are immune to poisons with strength below the level * of immunity given when they were constructed. * Above this level, the poison will take effect. *

*

* Any attempt to use a poisoned channel will cause a {@link PoisonException} * to be thrown. * Processes blocked on a channel that gets poisoned will be awoken with * a thrown {@link PoisonException}. *

*

* Poisoning is an effective technique for the safe interruption of processes and * termination of process networks or sub-networks (of any connected topology). * Note that poisoning a channel is non-blocking. * Also, poisoning an already poisoned channel does no (extra) harm. *

*

* The algorithm is simple. * One or more processes may independently decide to poison their environment * and terminate. * To do this, they poison their external channels, tidy up and die. * Any process accessing or waiting on a poisoned channel gets a {@link PoisonException} * thrown: this should be caught, local affairs settled and external channels * posioned before the process terminates. * That's all. *

*

* An example is shown in {@link org.jcsp.plugNplay.Generate} and * here, * where the channels in the example network are constructed to be poisonable * (with an immunity of zero) and FairMuxTime initiates the shut-down * (by injecting poison of strength 42). *

*

* To bring down only a sub-network, the internal channels of the subnet * should have an immunity lower than its external channels. * One of the subnet processes must choose (or be told) to release poison with * strength one greater than the subnet channel immunity. * That will terminate just the subnet, leaving the surrounding processes unaffected * – until they next try to communicate with the shut-down subnet. * This is no problem so long as the subnet is being replaced, which is * the usual reason for closing the previous one. *

* * @see org.jcsp.lang.PoisonException */ public interface Poisonable { /** * This injects poison into the channel. * If the channel was not explicitly constructed to be poisonable or * if the strength of poison is not greater than the channel immunity level, * the poison will have no effect. * * @param strength the strength of the poison (must be >= 0). * */ public void poison(int strength); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelInputImpl.java0000644000000000000000000000531411113671251021300 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class AltingChannelInputImpl extends AltingChannelInput { private ChannelInternals channel; private int immunity; AltingChannelInputImpl(ChannelInternals _channel, int _immunity) { channel = _channel; immunity = _immunity; } public boolean pending() { return channel.readerPending(); } boolean disable() { return channel.readerDisable(); } boolean enable(Alternative alt) { return channel.readerEnable(alt); } public void endRead() { channel.endRead(); } public Object read() { return channel.read(); } public Object startRead() { return channel.startRead(); } public void poison(int strength) { if (strength > immunity) { channel.readerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableAny2OneChannelIntImpl.java0000644000000000000000000000421211113671251023000 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class PoisonableAny2OneChannelIntImpl extends Any2OneIntImpl { PoisonableAny2OneChannelIntImpl(int _immunity) { super(new PoisonableOne2OneChannelIntImpl(_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelOutputSymmetricImpl.java0000644000000000000000000000503311105701167023375 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; class AltingChannelOutputSymmetricImpl extends AltingChannelOutput implements MultiwaySynchronisation { private final AltingBarrier ab; private final ChannelOutput out; private boolean syncDone = false; public AltingChannelOutputSymmetricImpl ( AltingBarrier ab, ChannelOutput out) { this.ab = ab; this.out = out; } boolean enable (Alternative alt) { syncDone = ab.enable (alt); return syncDone; } boolean disable () { syncDone = ab.disable (); return syncDone; } public void write (Object o) { if (!syncDone) ab.sync (); syncDone = false; out.write (o); } public boolean pending () { syncDone = ab.poll (10); return syncDone; } public void poison(int strength) { out.poison(strength); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneImpl.java0000644000000000000000000000617411113671251017031 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class Any2OneImpl implements ChannelInternals, Any2OneChannel { private ChannelInternals channel; private final Object writeMonitor = new Object(); Any2OneImpl(ChannelInternals _channel) { channel = _channel; } //Begin never used: public void endRead() { channel.endRead(); } public Object read() { return channel.read(); } public boolean readerDisable() { return channel.readerDisable(); } public boolean readerEnable(Alternative alt) { return channel.readerEnable(alt); } public boolean readerPending() { return channel.readerPending(); } public void readerPoison(int strength) { channel.readerPoison(strength); } public Object startRead() { return channel.startRead(); } //End never used public void write(Object obj) { synchronized (writeMonitor) { channel.write(obj); } } public void writerPoison(int strength) { synchronized (writeMonitor) { channel.writerPoison(strength); } } public AltingChannelInput in() { return new AltingChannelInputImpl(channel,0); } public SharedChannelOutput out() { return new SharedChannelOutputImpl(this,0); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionWithSharedAltingClient.java0000644000000000000000000000433311105701167023310 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This interface is just * * @author Quickstone Technologies Limited */ interface ConnectionWithSharedAltingClient { public SharedAltingConnectionClient client(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableBufferedOne2OneChannel.java0000644000000000000000000002565011105701167023152 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.*; /** * This implements a one-to-one object channel with user-definable buffering. *

Description

* BufferedOne2OneChannel implements a one-to-one object channel with * user-definable buffering. Multiple readers or multiple writers are * not allowed -- these are catered for by {@link BufferedAny2OneChannel}, * {@link BufferedOne2AnyChannel} or {@link BufferedAny2AnyChannel}. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ChannelDataStore ChannelDataStore} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.BufferedAny2OneChannel * @see org.jcsp.lang.BufferedOne2AnyChannel * @see org.jcsp.lang.BufferedAny2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin * @author P.H. Welch */ class PoisonableBufferedOne2OneChannel implements One2OneChannel, ChannelInternals { /** The ChannelDataStore used to store the data for the channel */ private final ChannelDataStore data; private final Object rwMonitor = new Object(); private Alternative alt; //Only passed to channel-ends, not used directly: private int immunity; private int poisonStrength = 0; /** * Constructs a new BufferedOne2OneChannel with the specified ChannelDataStore. * * @param data the ChannelDataStore used to store the data for the channel */ public PoisonableBufferedOne2OneChannel(ChannelDataStore data, int _immunity) { if (data == null) throw new IllegalArgumentException ("Null ChannelDataStore given to channel constructor ...\n"); this.data = (ChannelDataStore) data.clone(); immunity = _immunity; } private boolean isPoisoned() { return poisonStrength > 0; } /** * Reads an Object from the channel. * * @return the object read from the channel. */ public Object read () { synchronized (rwMonitor) { if (data.getState () == ChannelDataStore.EMPTY) { //Reader only sees poison if buffer is empty: if (isPoisoned()) { throw new PoisonException(poisonStrength); } try { rwMonitor.wait (); while (data.getState () == ChannelDataStore.EMPTY && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.read (int)\n" + e.toString () ); } if (isPoisoned()) { throw new PoisonException(poisonStrength); } } rwMonitor.notify (); return data.get (); } } public Object startRead() { synchronized (rwMonitor) { if (data.getState () == ChannelDataStore.EMPTY) { // Reader only sees poison if buffer is empty: if (isPoisoned()) { throw new PoisonException(poisonStrength); } try { rwMonitor.wait (); while (data.getState () == ChannelDataStore.EMPTY && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.read (int)\n" + e.toString () ); } // Reader only sees poison if buffer is empty: if (isPoisoned()) { throw new PoisonException(poisonStrength); } } return data.startGet(); } } public void endRead() { synchronized(rwMonitor) { data.endGet(); rwMonitor.notify (); } } /** * Writes an Object to the channel. * * @param value the object to write to the channel. */ public void write (Object value) { synchronized (rwMonitor) { //Writer always sees poison: if (isPoisoned()) { throw new PoisonException(poisonStrength); } data.put (value); if (alt != null) { alt.schedule (); } else { rwMonitor.notify (); } if (data.getState () == ChannelDataStore.FULL) { try { rwMonitor.wait (); while (data.getState () == ChannelDataStore.FULL && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXWrite); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.write (Object)\n" + e.toString () ); } if (isPoisoned()) { throw new PoisonException(poisonStrength); } } } } /** * turns on Alternative selection for the channel. Returns true if the * channel has data that can be read immediately. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class which will control the selection * @return true if the channel has data that can be read, else false */ public boolean readerEnable (Alternative alt) { synchronized (rwMonitor) { if (isPoisoned()) { //If it's poisoned, it will be ready whether because of the poison, or because //the buffer has data in it return true; } else if (data.getState () == ChannelDataStore.EMPTY) { this.alt = alt; return false; } else { return true; } } } /** * turns off Alternative selection for the channel. Returns true if the * channel contained data that can be read. *

* Note: this method should only be called by the Alternative class * * @return true if the channel has data that can be read, else false */ public boolean readerDisable () { synchronized (rwMonitor) { alt = null; return data.getState () != ChannelDataStore.EMPTY || isPoisoned(); } } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. *

* This method is provided for convenience. Its functionality can be provided * by Pri Alting the channel against a SKIP guard, although * at greater run-time and syntactic cost. For example, the following code * fragment: *

 *   if (c.pending ()) {
 *     Object x = c.read ();
 *     ...  do something with x
 *   } else (
 *     ...  do something else
 *   }
 * 
* is equivalent to: *
 *   if (c_pending.priSelect () == 0) {
 *     Object x = c.read ();
 *     ...  do something with x
 *   } else (
 *     ...  do something else
 * }
 * 
* where earlier would have had to have been declared: *
 * final Alternative c_pending =
 *   new Alternative (new Guard[] {c, new Skip ()});
 * 
* * @return state of the channel. */ public boolean readerPending () { synchronized (rwMonitor) { return (data.getState () != ChannelDataStore.EMPTY) || isPoisoned(); } } /** * Returns the AltingChannelInput to use for this channel. * As BufferedOne2OneChannel implements * AltingChannelInput itself, this method simply returns * a reference to the object that it is called on. * * @return the AltingChannelInput object to use for this * channel. */ public AltingChannelInput in() { return new AltingChannelInputImpl(this,immunity); } /** * Returns the ChannelOutput object to use for this channel. * As BufferedOne2OneChannel implements * ChannelOutput itself, this method simply returns * a reference to the object that it is called on. * * @return the ChannelOutput object to use for this * channel. */ public ChannelOutput out() { return new ChannelOutputImpl(this,immunity); } public void writerPoison(int strength) { if (strength > 0) { synchronized (rwMonitor) { this.poisonStrength = strength; //Poison by writer does *NOT* clear the buffer rwMonitor.notifyAll(); if (null != alt) { alt.schedule(); } } } } public void readerPoison(int strength) { if (strength > 0) { synchronized (rwMonitor) { this.poisonStrength = strength; //Poison by reader clears the buffer: data.removeAll(); rwMonitor.notifyAll(); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyChannelImpl.java0000644000000000000000000000477011105701167020331 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements an any-to-any object channel, * safe for use by many writers and many readers. Refer to the {@link Any2AnyChannel} interface * for more details. * * @see org.jcsp.lang.One2OneChannelImpl * @see org.jcsp.lang.Any2OneChannelImpl * @see org.jcsp.lang.One2AnyChannelImpl * * @author P.D. Austin and P.H. Welch */ class Any2AnyChannelImpl extends Any2AnyImpl { Any2AnyChannelImpl() { super(new One2OneChannelImpl()); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ProcessInterruptedException.java0000644000000000000000000000614011105701167022451 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This is thrown if a process is interrupted whilst blocked during synchronisation * - processes should never be interrupted. * *

Description

* This is caused by accessing the Java thread executing a JCSP process and invoking its * java.lang.Thread.interrupt() method. * If this is done to a process blocked on a JCSP synchronisation primitive (such as * a channel communication or timeout), the process will wake up prematurely * -- invalidating the semantics of that primitive. * The wake up is intercepted and this {@link java.lang.Error} is thrown. *

* Some browsers, when shutting down an applet, may do this to processes * spawned by an {@link org.jcsp.awt.ActiveApplet} that have not died naturally. * * Alternatively, this may be raised by processes stopped prematurely as a result of * a call to Parallel.destroy, or by calling stop on the * ProcessManager responsible for the process (or network). * * @author P.H. Welch */ //}}} public class ProcessInterruptedException extends Error { public ProcessInterruptedException (String s) { super ("\n*** Interrupting a running process is not compatible with JCSP\n" + "*** Please don't do this!\n" + s); // System.out.println ("Someone is creating a ProcessInterruptedException!\n" + s); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedChannelOutputIntImpl.java0000644000000000000000000000463311113671251022147 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class SharedChannelOutputIntImpl implements SharedChannelOutputInt { private ChannelInternalsInt channel; private int immunity; SharedChannelOutputIntImpl(ChannelInternalsInt _channel, int _immunity) { channel = _channel; immunity = _immunity; } public void write(int object) { channel.write(object); } public void poison(int strength) { if (strength > immunity) { channel.writerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableBufferedAny2AnyChannelInt.java0000644000000000000000000000435111113671251023633 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.ChannelDataStoreInt; class PoisonableBufferedAny2AnyChannelInt extends Any2AnyIntImpl { PoisonableBufferedAny2AnyChannelInt(ChannelDataStoreInt _data, int _immunity) { super(new PoisonableBufferedAny2AnyChannelInt(_data,_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/StandardConnectionFactory.java0000644000000000000000000001021111105701167022030 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

* Implements a factory for creating connections. *

* * @author Quickstone Technologies Limited */ public class StandardConnectionFactory implements ConnectionFactory, ConnectionArrayFactory { /** * @see ConnectionFactory#createOne2One */ public One2OneConnection createOne2One() { return new One2OneConnectionImpl(); } /** * @see ConnectionFactory#createAny2One */ public Any2OneConnection createAny2One() { return new Any2OneConnectionImpl(); } /** * @see ConnectionFactory#createOne2Any */ public One2AnyConnection createOne2Any() { return new One2AnyConnectionImpl(); } /** * @see ConnectionFactory#createAny2Any */ public Any2AnyConnection createAny2Any() { return new Any2AnyConnectionImpl(); } /** * @see ConnectionArrayFactory#createOne2One */ public One2OneConnection[] createOne2One(int n) { One2OneConnection[] toReturn = new One2OneConnection[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2One(); return toReturn; } /** * @see ConnectionArrayFactory#createAny2One */ public Any2OneConnection[] createAny2One(int n) { Any2OneConnection[] toReturn = new Any2OneConnection[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2One(); return toReturn; } /** * @see ConnectionArrayFactory#createOne2Any */ public One2AnyConnection[] createOne2Any(int n) { One2AnyConnection[] toReturn = new One2AnyConnection[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2Any(); return toReturn; } /** * @see ConnectionArrayFactory#createAny2Any */ public Any2AnyConnection[] createAny2Any(int n) { Any2AnyConnection[] toReturn = new Any2AnyConnection[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2Any(); return toReturn; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableChannel.java0000644000000000000000000000504411105701167020261 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a channel that allows readers to either accept (read) or * reject data offered by the writer. * * @author Quickstone Technologies Limited * * @deprecated This channel is superceded by the poison mechanisms, please see {@link PoisonException}. It remains only because it is used by some of the networking features. */ public interface RejectableChannel { public RejectableChannelInput in(); public RejectableChannelOutput out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyConnection.java0000644000000000000000000000502511105701167020222 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * An interface for a connection which can be used by only one client but which can be used by multiple * concurrent servers. * * @author Quickstone Technologies Limited */ public interface One2AnyConnection extends ConnectionWithSharedAltingServer { /** * Returns the client part of the connection. */ public AltingConnectionClient client(); /** * Returns the server part of the connection. */ public SharedConnectionServer server(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Alternative.java0000644000000000000000000013615311113671251017213 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; //{{{ javadoc /** * This enables a process to wait passively for and choose * between a number of {@link Guard} events. *

* Shortcut to the Constructor and Method Summaries. *

Description

* The Alternative class enables a CSProcess to wait passively for and * choose between a number of {@link Guard} events. This is known as * ALTing. *

* Note: for those familiar with the occam multiprocessing * language, this gives the semantics of the ALT and * PRI ALT constructs, extended with a built-in implementation * of the classical FAIR ALT. *

* The Alternative constructor takes an array of guards. Processes * that need to Alt over more than one set of guards will need a separate * Alternative instance for each set. *

* Eight types of Guard are provided in jcsp.lang: *

    *
  • * {@link AltingChannelInput}: object channel input -- * ready if unread data is pending in the channel. *
  • * {@link AltingChannelInputInt}: integer channel input -- * ready if unread data is pending in the channel. *
  • * {@link AltingChannelOutput}: object channel output -- * ready if a reading process can take the offered data * ({@link One2OneChannelSymmetric symmetric} channels only). *
  • * {@link AltingChannelOutputInt}: integer channel output -- * ready if a reading process can take the offered data * ({@link One2OneChannelSymmetricInt symmetric} channels only). *
  • * {@link AltingChannelAccept}: CALL accept -- * ready if an unaccepted call is pending. *
  • * {@link AltingBarrier}: barrier synchronisation -- * ready if all enrolled processes are offering to synchronise. *
  • * {@link CSTimer}: timeout -- * ready if the timeout has expired (timeout * values are absolute time values, not delays) *
  • * {@link Skip}: skip -- * always ready. *
*

* By invoking one of the following methods, a process may passively wait for * one or more of the guards associated with an Alternative object * to become ready. The methods differ in the way they choose which guard * to select in the case when two or more guards are ready: *

    *
  • * {@link #select() select} waits for one or more of the guards * to become ready. If more than one become ready, it makes an * arbitrary choice between them (and corresponds to the * occam ALT). *
  • * {@link #priSelect() priSelect} also waits for one or more of * the guards to become ready. However, if more than one becomes ready, * it chooses the first one listed (and corresponds to the * occam PRI ALT). Note: the use of * priSelect between channel inputs and a skip guard (at lowest * priority) gives us a polling operation on the readiness * of those channels. *
  • * {@link #fairSelect() fairSelect} also waits for one or more * of the guards to become ready. If more than one become ready, it * prioritises its choice so that the guard it chose the last time * it was invoked has lowest priority this time. This corresponds * to a common occam idiom used for real-time applications. * If fairSelect is used * in a loop, a ready guard has the guarantee that no other guard will be * serviced twice before it will be serviced. This enables * an upper bound on service times to be calculated and ensures that no * ready guard can be indefinitely starved. *
*

* Finally, each guard may be * pre-conditioned with a run-time test * to decide if it should be considered in the current choice. This allows * considerable flexibilty -- for example, we can decide whether timeouts * shoud be set, channels refused or polling enabled depending * on the run-time state of the Alting process. *

*

Examples

*

A Fair Multiplexor

* This example demonstrates a process that fairly multiplexes traffic * from its array of input channels to its single output channel. No input * channel will be starved, regardless of the eagerness of its competitors. *
 * import org.jcsp.lang.*;
 * 
 * public class FairPlex implements CSProcess {
 * 
 *   private final AltingChannelInput[] in;
 *   private final ChannelOutput out;
 * 
 *   public FairPlex (final AltingChannelInput[] in, final ChannelOutput out) {
 *     this.in = in;
 *     this.out = out;
 *   }
 * 
 *   public void run () {
 * 
 *     final Alternative alt = new Alternative (in);
 * 
 *     while (true) {
 *       final int index = alt.fairSelect ();
 *       out.write (in[index].read ());
 *     }
 * 
 *   }
 * 
 * }
 * 
* Note that if priSelect were used above, higher-indexed channels would be * starved if lower-indexed channels were continually demanding service. * If select were used, no starvation analysis is possible. * The select mechanism should only be used when starvation is not an issue. * *

A Fair Multiplexor with a Timeout and Poisoning

* This example demonstrates a process that fairly multiplexes traffic * from its input channels to its single output channel, but which timeouts * after a user-settable time. Whilst running, no input channel * will be starved, regardless of the eagerness of its competitors. * The process also illustrates the poisoning of channels, following the timeout. *
 * import org.jcsp.lang.*;
 * 
 * public class FairPlexTime implements CSProcess {
 * 
 *   private final AltingChannelInput[] in;
 *   private final ChannelOutput out;
 *   private final long timeout;
 * 
 *   public FairPlexTime (final AltingChannelInput[] in, final ChannelOutput out,
 *                        final long timeout) {
 *     this.in = in;
 *     this.out = out;
 *     this.timeout = timeout;
 *   }
 * 
 *   public void run () {
 * 
 *     final Guard[] guards = new Guard[in.length + 1];
 *     System.arraycopy (in, 0, guards, 0, in.length);
 * 
 *     final CSTimer tim = new CSTimer ();
 *     final int timerIndex = in.length;
 *     guards[timerIndex] = tim;
 * 
 *     final Alternative alt = new Alternative (guards);
 * 
 *     boolean running = true;
 *     tim.setAlarm (tim.read () + timeout);
 *     while (running) {
 *       final int index = alt.fairSelect ();
 *       if (index == timerIndex) {
 *         running = false;
 *       } else {
 *         out.write (in[index].read ());
 *       }
 *     }
 *     System.out.println ("\n\r\tFairPlexTime: timed out ... poisoning all channels ...");
 *     for (int i = 0; i < in.length; i++) {
 *       in[i].poison (42);                       // assume: channel immunity < 42
 *     }
 *     out.poison (42);                           // assume: channel immunity < 42
 * 
 *   }
 * 
 * }
 * 
* Note that if priSelect were used above, higher-indexed guards would be * starved if lower-indexed guards were continually demanding service -- and * the timeout would never be noticed. * If select were used, no starvation analysis is possible. *

* Sometimes we need to use priSelect to impose a specific * (as opposed to fair) choice that overcomes the external scheduling of events. * For example, if we were concerned that the timeout above should * be responded to immediately and unconcerned about the fair servicing of its * channels, we should put its CSTimer as the first element of its Guard * array and use priSelect. *

* To demonstrate FairPlexTime, consider: *

 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * class FairPlexTimeTest {
 * 
 *   public static void main (String[] args) {
 * 
 *     final One2OneChannel[] a = Channel.one2OneArray (5, 0);     // poisonable channels (zero immunity)
 *     final One2OneChannel b = Channel.one2One (0);               // poisonable channels (zero immunity)
 *
 *     final long timeout = 5000;                                  // 5 seconds
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Generate (a[0].out (), 0),
 *         new Generate (a[1].out (), 1),
 *         new Generate (a[2].out (), 2),
 *         new Generate (a[3].out (), 3),
 *         new Generate (a[4].out (), 4),
 *         new FairPlexTime (Channel.getInputArray (a), b.out (), timeout),
 *         new Printer (b.in (), "FairPlexTimeTest ==> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* where {@link org.jcsp.plugNplay.Generate} sends its given Integer down its output channel * as often as it can. * This results in continuous demands on FairPlexTime by all its clients * and demonstrates its fair servicing of those demands. *

* The {@link org.jcsp.plugNplay.Generate} and {@link org.jcsp.plugNplay.Printer} are * programmed to deal with being poisoned. * Here is the run() method for Generate: *

 * public void run() {
 *   try {
 *     while (true) {
 *       out.write (N);
 *     }
 *   } catch (PoisonException p) {
 *     // the 'out' channel must have been posioned ... nothing left to do!
 *   }
 * }
 * 
* In general, there will be things to do – especially if there is more * than one channel. * For example, here is the catch block at the end of the run() * method for {@link org.jcsp.plugNplay.Delta} (which has a single input channel-end, * in, and an array of output channel-ends, out): *
 *   } catch (PoisonException p) {
 *     // don't know which channel was posioned ... so, poison them all!
 *     int strength = p.getStrength ();   // use same strength of poison
 *     in.poison (strength);
 *     for  (int i = 0; i < out.length; i++) {
 *       out[i].poison (strength);
 *     }
 *   }
 * 
* *

A Simple Traffic Flow Regulator

* The Regulate process controls the rate of flow of traffic from its input * to output channels. It produces a constant rate of output flow, regardless of * the rate of its input. At the end of each timeslice defined by the required output * rate, it outputs the last object input during that timeslice. If nothing has come * in during a timeslice, the previous output will be repeated (note: this will be a * null if nothing has ever arrived). If the input flow is greater than * the required output flow, data will be discarded. *

* The interval (in msecs) defining the output flow rate is given by a constructor argument. * This can be changed at any time by sending a new interval (as a Long) * down the reset channel. *

* Note: this example shows how simple it is to program time-regulated functionality * like that performed by java.awt.Component.repaint. *

 * package org.jcsp.plugNplay;
 *
 * import org.jcsp.lang.*;
 * 
 * public class Regulate implements CSProcess {
 * 
 *   private final AltingChannelInput in, reset;
 *   private final ChannelOutput out;
 *   private final long initialInterval;
 * 
 *   public Regulate (final AltingChannelInput in, final AltingChannelInput reset,
 *                    final ChannelOutput out, final long initialInterval) {
 *     this.in = in;
 *     this.reset = reset;
 *     this.out = out;
 *     this.initialInterval = initialInterval;
 *   }
 * 
 *   public void run () {
 * 
 *     final CSTimer tim = new CSTimer ();
 * 
 *     final Guard[] guards = {reset, tim, in};              // prioritised order
 *     final int RESET = 0;                                  // index into guards
 *     final int TIM = 1;                                    // index into guards
 *     final int IN = 2;                                     // index into guards
 * 
 *     final Alternative alt = new Alternative (guards);
 * 
 *     Object x = null;                                      // holding object
 * 
 *     long interval = initialInterval;
 * 
 *     long timeout = tim.read () + interval;
 *     tim.setAlarm (timeout);
 * 
 *     while (true) {
 *       switch (alt.priSelect ()) {
 *         case RESET:
 *           interval = ((Long) reset.read ()).longValue ();
 *           timeout = tim.read ();                          // fall through
 *         case TIM:
 *           out.write (x);
 *           timeout += interval;
 *           tim.setAlarm (timeout);
 *         break;
 *         case IN:
 *           x = in.read ();
 *         break;
 *       }
 *     }
 * 
 *   }
 * 
 * }
 * 
*

* To demonstrate Regulate, consider: *

 * class RegulateTest {
 * 
 *   public static void main (String[] args) {
 * 
 *     final One2OneChannel a = Channel.one2One ();
 *     final One2OneChannel b = Channel.one2One ();
 *     final One2OneChannel c = Channel.one2One ();
 * 
 *     final One2OneChannel reset = Channel.one2one (new OverWriteOldestBuffer (1));
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),                               // generate numbers
 *         new FixedDelay (250, a.in (), b.out ()),              // let them through every quarter second
 *         new Regulate (b.in (), reset.in (), c.out (), 1000),  // initially sample every second
 *         new CSProcess () {
 *           public void run () {
 *             Long[] sample = {new Long (1000), new Long (250), new Long (100)};
 *             int[] count = {10, 40, 100};
 *             while (true) {
 *               for (int cycle = 0; cycle < sample.length; cycle++) {
 *                 reset.write (sample[cycle]);
 *                 System.out.println ("\nSampling every " + sample[cycle] + " ms ...\n");
 *                 for (int i = 0; i < count[cycle]; i++) {
 *                   Integer n = (Integer) c.read ();
 *                   System.out.println ("\t==> " + n);
 *                 }
 *               }
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* The reader may like to consider the danger of deadlock in the above system if * the reset channel were not an overwriting one. * *
*

Polling

* Sometimes, we want to handle incoming channel data if it's there, but get on with * something else if all is quiet. This can be done by PRI ALTing * the channels we wish to poll against a SKIP guard: *
 * import org.jcsp.lang.*;
 * 
 * public class Polling implements CSProcess {
 * 
 *   private final AltingChannelInput in0;
 *   private final AltingChannelInput in1;
 *   private final AltingChannelInput in2;
 *   private final ChannelOutput out;
 * 
 *   public Polling (final AltingChannelInput in0, final AltingChannelInput in1,
 *                   final AltingChannelInput in2, final ChannelOutput out) {
 *     this.in0 = in0;
 *     this.in1 = in1;
 *     this.in2 = in2;
 *     this.out = out;
 *   }
 * 
 *   public void run() {
 * 
 *     final Skip skip = new Skip ();
 *     final Guard[] guards = {in0, in1, in2, skip};
 *     final Alternative alt = new Alternative (guards);
 * 
 *     while (true) {
 *       switch (alt.priSelect ()) {
 *         case 0:
 *           ...  process data pending on channel in0 ...
 *         break;
 *         case 1:
 *           ...  process data pending on channel in1 ...
 *         break;
 *         case 2:
 *           ...  process data pending on channel in2 ...
 *         break;
 *         case 3:
 *           ...  nothing available for the above ...
 *           ...  so get on with something else for a while ...
 *           ...  then loop around and poll again ...
 *         break;
 *       }
 *     }
 * 
 *   }
 * 
 * }
 * 
* The above technique lets us poll any {@link Guard} events, including * timeouts. If we just want to poll channels for input events, see * the {@link AltingChannelInput#pending pending} methods of the various * ``...2One...'' channels for a more direct and efficient way. *

* Note: polling is an often overused technique. Make sure your design would * not be better suited with a blocking ALT and with the `something else' done by * a process running in parallel. * * *

The `Wot-no-Chickens?' Canteen

* This examples demonstrates the use of pre-conditions on the ALT * guards. The Canteen process buffers a supply of chickens. It can * hold a maximum of 20 chickens. Chickens are supplied on the supply * line in batches of, at most, 4. Chickens are requested by hungry philosophers * who share the request line to the Canteen. In response to * such requests, one chicken is delivered down the deliver line. *

* The Canteen refuses further supplies if it has no room for the maximum * (4) batch supply. The Canteen refuses requests from the philosophers * if it has no chickens. *

 * import org.jcsp.lang.*;
 * 
 * public class Canteen implements CSProcess {
 * 
 *   private final AltingChannelInput supply;    // from the cook
 *   private final AltingChannelInput request;   // from a philosopher
 *   private final ChannelOutput deliver;        // to a philosopher
 * 
 *   public Canteen (final AltingChannelInput supply,
 *                   final AltingChannelInput request,
 *                   final ChannelOutput deliver) {
 *     this.supply = supply;
 *     this.request = request;
 *     this.deliver = deliver;
 *   }
 * 
 *   public void run() {
 * 
 *     final Guard[] guard = {supply, request};
 *     final boolean[] preCondition = new boolean[guard.length];
 *     final int SUPPLY = 0;
 *     final int REQUEST = 1;
 * 
 *     final Alternative alt = new Alternative (guard);
 * 
 *     final int maxChickens = 20;
 *     final int maxSupply = 4;
 *     final int limitChickens = maxChickens - maxSupply;
 * 
 *     final Integer oneChicken = new Integer (1);
 *     // ready to go!
 * 
 *     int nChickens = 0;
 *     // invariant : 0 <= nChickens <= maxChickens
 * 
 *     while (true) {
 *       preCondition[SUPPLY] = (nChickens <= limitChickens);
 *       preCondition[REQUEST] = (nChickens > 0);
 *       switch (alt.priSelect (preCondition)) {
 *         case SUPPLY:
 *           nChickens += ((Integer) supply.read ()).intValue ();  // <= maxSupply
 *         break;
 *         case REQUEST:
 *           Object dummy = request.read ();
 *           // we have to still input the signal
 *           deliver.write (oneChicken);
 *           // preCondition ==> (nChickens > 0)
 *           nChickens--;
 *         break;
 *       }
 *     }
 * 
 *   }
 * 
 * }
 * 
*

* Contrast the above programming of the canteen as a CSP process rather * than a monitor. A monitor cannot refuse a callback when noone has the lock, * even though it may not be in a state to process it. In the above, a supply * method would have to cope with its being called when there is no room to take the supply. * A request method would have to be dealt with even though there may be no chickens * to deliver. Monitors manage such problems by putting their callers on hold * (wait), but that means that their methods have to rely on each other to get * out of any resulting embarassment (using notify). * And that means that the logic of those methods has to be tightly coupled, which * makes reasoning about them hard. This gets worse the more interdependent methods * the monitor has. *

* On the other hand, the above Canteen process simply refuses service on * its supply and request channels if it can't cope, leaving * the supplying or requesting processes waiting harmlessly on those channels. * The service responses can assume their run-time set pre-conditions and have * independent -- and trivial -- logic. When circumstances permit, * the blocked processes are serviced in the normal way. *

*

Implementation Footnote

* This Alternative class and the various channel classes * (e.g. {@link One2OneChannel}) are mutually dependent monitors -- they see instances * of each other and invoke each others' strongly interdependent methods. This logic * is inspired by the published algorithms and data structures burnt into the microcode * of the transputer some 15 years ago (1984). Getting this logic `right' * in the context of Java monitors is something we have done (n + 1) times, * only to find it flawed n times with an unsuspected race-hazard months * (sometimes years) later. Hopefully, we have it right now ... but a proof * of correctness is really needed! *

* To this end, a formal (CSP) model of Java's monitor primitives * (the synchronized keyword and the wait, notify and * notifyAll methods of the Object class) has been built. * This has been used for the formal verification of the JCSP implementation * of channel read and write, along with the correctness of * 2-way channel input Alternatives. * Details and references are listed under * `A CSP Model * for Java Threads' on the JCSP web-site. * [The proof uses the FDR * model checker. Model checkers do not easily allow verification of results containing * free variables - such as the correctness of the n-way Alternative. * An investigation of this using formal transformation of one system of CSP equations * into another, rather than model checking is being considered.] *

* The transputer designers always said that getting its microcoded scheduler * logic right was one of their hardest tasks. Working directly with the monitor * concept means working at a similar level of difficulty for application programs. * One of the goals of JCSP is to protect users from ever having to work at that level, * providing instead a range of CSP primitives whose ease of use scales well with * application complexity -- and in whose implementation those monitor complexities * are correctly distilled and hidden. * * @see org.jcsp.lang.Guard * @see org.jcsp.lang.AltingChannelInput * @see org.jcsp.lang.AltingChannelInputInt * @see org.jcsp.lang.AltingChannelAccept * @see org.jcsp.lang.AltingBarrier * @see org.jcsp.lang.CSTimer * @see org.jcsp.lang.Skip * * @author P.H. Welch and P.D. Austin */ //}}} public class Alternative { /** The monitor synchronising the writers and alting reader */ protected Object altMonitor = new Object (); private static final int enabling = 0; private static final int waiting = 1; private static final int ready = 2; private static final int inactive = 3; /** The state of the ALTing process. */ private int state = inactive; /** The array of guard events from which we are selecting. */ private final Guard[] guard; /** The index of the guard with highest priority for the next select. */ private int favourite = 0; // invariant: 0 <= favourite < guard.length /** The index of the selected guard. */ private int selected; // after the enable/disable sequence : // 0 <= selected < guard.length private final int NONE_SELECTED = -1; /** This indicates whether an AltingBarrier is one of the Guards. */ private boolean barrierPresent; /** This flag is set by a successful AltingBarrier enable/disable. */ private boolean barrierTrigger = false; /** The index of a selected AltingBarrier. */ private int barrierSelected; /** * This is the index variable used during the enable/disable sequences. * This has been made global to simplify the call-back (setTimeout) from * a CSTimer that is being enabled. That call-back sets the timeout, msecs * and timeIndex variables below. The latter variable is needed only to * work around the bug that Java wait-with-timeouts sometimes return early. */ private int enableIndex; /** This flag is set if one of the enabled guards was a CSTimer guard. */ private boolean timeout = false; /** If one or more guards were CSTimers, this holds the earliest timeout. */ private long msecs; /** * If one or more guards were CSTimers, this holds the index of the one * with the earliest timeout. */ private int timeIndex; /** * Construct an Alternative object operating on the {@link Guard} * array of events. Supported guard events are channel inputs * ({@link AltingChannelInput} and {@link AltingChannelInputInt}), * CALL channel accepts ({@link AltingChannelAccept}), * barriers ({@link AltingBarrier}), * timeouts ({@link CSTimer}) and skips ({@link Skip}). *

* * @param guard the event guards over which the select operations will be made. */ public Alternative(final Guard[] guard) { this.guard = guard; for (int i = 0; i < guard.length; i++) { if (guard[i] instanceof MultiwaySynchronisation) { barrierPresent = true; return; } } barrierPresent = false; } /** * Returns the index of one of the ready guards. The method will block * until one of the guards becomes ready. If more than one is ready, * an arbitrary choice is made. */ public final int select() { return fairSelect (); // a legal implementation of arbitrary choice! } /** * Returns the index of one of the ready guards. The method will block * until one of the guards becomes ready. If more than one is ready, * the one with the lowest index is selected. */ public final int priSelect () { // if (barrierPresent) { // throw new AlternativeError ( // "*** Cannot 'priSelect' with an AltingBarrier in the Guard array" // ); // } state = enabling; favourite = 0; enableGuards (); synchronized (altMonitor) { if (state == enabling) { state = waiting; try { if (timeout) { long delay = msecs - System.currentTimeMillis (); if (delay > Spurious.earlyTimeout) { altMonitor.wait (delay); /* while ((state == waiting) && ((delay = (msecs - System.currentTimeMillis ())) > Spurious.earlyTimeout)) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelectWithTimeout); } altMonitor.wait (delay); } if ((state == waiting) && (delay > 0)) { if (Spurious.logging) { SpuriousLog.incEarlyTimeouts (); } } */ while (state == waiting) { delay = msecs - System.currentTimeMillis (); if (delay > Spurious.earlyTimeout) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelectWithTimeout); } altMonitor.wait (delay); } else { if ((delay > 0) && (Spurious.logging)) { SpuriousLog.incEarlyTimeouts (); } break; } } // System.out.println (state + " [" + delay + "]"); } } else { altMonitor.wait (); while (state == waiting) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelect); } altMonitor.wait (); } } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from Alternative.priSelect ()\n" + e.toString () ); } state = ready; } } disableGuards (); state = inactive; timeout = false; return selected; } /** * Returns the index of one of the ready guards. The method will block * until one of the guards becomes ready. Consequetive invocations will * service the guards `fairly' in the case when many guards are always * ready. Implementation note: the last guard serviced has the lowest * priority next time around. */ public final int fairSelect () { state = enabling; enableGuards (); synchronized (altMonitor) { if (state == enabling) { state = waiting; try { if (timeout) { long delay = msecs - System.currentTimeMillis (); // NOTE: below is code that demonstrates whether wait (delay) // sometimes returns early! Because this happens in some JVMs, // we are forced into a workaround - see disableGuards (). // long now = System.currentTimeMillis (); // long delay = msecs - now; if (delay > Spurious.earlyTimeout) { altMonitor.wait (delay); /* while ((state == waiting) && ((delay = msecs - System.currentTimeMillis ()) > Spurious.earlyTimeout)) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelectWithTimeout); } altMonitor.wait (delay); } if ((state == waiting) && (delay > 0)) { if (Spurious.logging) { SpuriousLog.incEarlyTimeouts (); } } */ while (state == waiting) { delay = msecs - System.currentTimeMillis (); if (delay > Spurious.earlyTimeout) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelectWithTimeout); } altMonitor.wait (delay); } else { if ((delay > 0) && (Spurious.logging)) { SpuriousLog.incEarlyTimeouts (); } break; } } } // long then = System.currentTimeMillis (); // System.out.println ("*** fairSelect: " + msecs + // ", " + now + ", " + delay + // ", " + then); } else { altMonitor.wait (); while (state == waiting) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelect); } altMonitor.wait (); } } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from Alternative.fairSelect/select ()\n" + e.toString () ); } state = ready; } } disableGuards (); state = inactive; favourite = selected + 1; if (favourite == guard.length) favourite = 0; timeout = false; return selected; } /** * Enables the guards for selection. If any of the guards are ready, * it sets selected to the ready guard's index, state to ready and returns. * Otherwise, it sets selected to NONE_SELECTED and returns. */ private final void enableGuards () { if (barrierPresent) { // System.out.println ("ENABLE barrier(s) present ..."); AltingBarrierCoordinate.startEnable (); } barrierSelected = NONE_SELECTED; for (enableIndex = favourite; enableIndex < guard.length; enableIndex++) { if (guard[enableIndex].enable (this)) { // if (guard[enableIndex] instanceof AltingChannelInput) { // System.out.println ("CHANNEL ENABLE " + enableIndex + " SUCCEED"); // } else { // System.out.println ("ENABLE " + enableIndex + " SUCCEED"); // } selected = enableIndex; state = ready; if (barrierTrigger) { barrierSelected = selected; barrierTrigger = false; } else if (barrierPresent) { // System.out.println ("ENABLE " + enableIndex + " NON-BARRIER SUCCEED"); AltingBarrierCoordinate.finishEnable (); } return; } // else { // if (guard[enableIndex] instanceof AltingChannelInput) { // System.out.println ("CHANNEL ENABLE " + enableIndex + " FAIL"); // } else { // System.out.println ("ENABLE " + enableIndex + " FAIL"); // } // } } for (enableIndex = 0; enableIndex < favourite; enableIndex++) { if (guard[enableIndex].enable (this)) { // if (guard[enableIndex] instanceof AltingChannelInput) { // System.out.println ("CHANNEL ENABLE " + enableIndex + " SUCCEED"); // } else { // System.out.println ("ENABLE " + enableIndex + " SUCCEED"); // } selected = enableIndex; state = ready; if (barrierTrigger) { barrierSelected = selected; barrierTrigger = false; } else if (barrierPresent) { // System.out.println ("ENABLE " + enableIndex + " NON-BARRIER SUCCEED"); AltingBarrierCoordinate.finishEnable (); } return; } // else { // if (guard[enableIndex] instanceof AltingChannelInput) { // System.out.println ("CHANNEL ENABLE " + enableIndex + " FAIL"); // } else { // System.out.println ("ENABLE " + enableIndex + " FAIL"); // } // } } // System.out.println ("ENABLE ALL FAIL"); selected = NONE_SELECTED; if (barrierPresent) { AltingBarrierCoordinate.finishEnable (); } } /** * Disables the guards for selection. Sets selected to the index of * the ready guard, taking care of priority/fair choice. */ private void disableGuards () { if (selected != favourite) { // else there is nothing to disable int startIndex = (selected == NONE_SELECTED) ? favourite - 1: selected - 1; if (startIndex < favourite) { for (int i = startIndex; i >= 0; i--) { if (guard[i].disable ()) { selected = i; if (barrierTrigger) { if (barrierSelected != NONE_SELECTED) { throw new JCSP_InternalError ( "*** Second AltingBarrier completed in ALT sequence: " + barrierSelected + " and " + i ); } barrierSelected = selected; barrierTrigger = false; } } } startIndex = guard.length - 1; } for (int i = startIndex; i >= favourite; i--) { if (guard[i].disable ()) { selected = i; if (barrierTrigger) { if (barrierSelected != NONE_SELECTED) { throw new JCSP_InternalError ( "\n*** Second AltingBarrier completed in ALT sequence: " + barrierSelected + " and " + i ); } barrierSelected = selected; barrierTrigger = false; } } } if (selected == NONE_SELECTED) { // System.out.println ("disableGuards: NONE_SELECTED ==> " + timeIndex); // NOTE: this is a work-around for Java wait-with-timeouts sometimes // returning early. If this did not happen, we would not get here! selected = timeIndex; } } if (barrierSelected != NONE_SELECTED) { // We must choose a barrier sync selected = barrierSelected; // if one is ready - so that all AltingBarrierCoordinate.finishDisable (); // parties make the same choice. } } /** * This is the call-back from enabling a CSTimer guard. It is part of the * work-around for Java wait-with-timeouts sometimes returning early. * It is still in the flow of control of the ALTing process. */ void setTimeout (long msecs) { if (timeout) { if (msecs < this.msecs) { this.msecs = msecs; timeIndex = enableIndex; } } else { timeout = true; this.msecs = msecs; timeIndex = enableIndex; } } /** * This is a call-back from an AltingBarrier. * It is still in the flow of control of the ALTing process. */ void setBarrierTrigger () { barrierTrigger = true; } /** * This is the wake-up call to the process ALTing on guards controlled * by this object. It is in the flow of control of a process writing * to an enabled channel guard. */ void schedule () { synchronized (altMonitor) { switch (state) { case enabling: state = ready; break; case waiting: state = ready; altMonitor.notify (); break; // case ready: case inactive: // break } } } /////////////////// The pre-conditioned versions of select /////////////////// /** * Returns the index of one of the ready guards whose preCondition * index is true. The method will block until one of these guards becomes * ready. If more than one is ready, an arbitrary choice is made. *

* Note: the length of the preCondition array must be the * same as that of the array of guards with which this object was constructed. *

* * @param preCondition the guards from which to select */ public final int select (boolean[] preCondition) { return fairSelect (preCondition); // a legal implementation of arbitrary choice! } /** * Returns the index of one of the ready guards whose preCondition * index is true. The method will block until one of these guards becomes * ready. If more than one is ready, the one with the lowest index is selected. *

* Note: the length of the preCondition array must be the * same as that of the array of guards with which this object was constructed. *

* * @param preCondition the guards from which to select */ public final int priSelect (boolean[] preCondition) { // if (barrierPresent) { // throw new AlternativeError ( // "*** Cannot 'priSelect' with an AltingBarrier in the Guard array" // ); // } if (preCondition.length != guard.length) { throw new IllegalArgumentException ( "*** org.jcsp.lang.Alternative.select called with a preCondition array\n" + "*** whose length does not match its guard array" ); } state = enabling; favourite = 0; enableGuards (preCondition); synchronized (altMonitor) { if (state == enabling) { state = waiting; try { if (timeout) { long delay = msecs - System.currentTimeMillis (); if (delay > Spurious.earlyTimeout) { altMonitor.wait (delay); while (state == waiting) { delay = msecs - System.currentTimeMillis (); if (delay > Spurious.earlyTimeout) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelectWithTimeout); } altMonitor.wait (delay); } else { if ((delay > 0) && (Spurious.logging)) { SpuriousLog.incEarlyTimeouts (); } break; } } } } else { altMonitor.wait (); while (state == waiting) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelect); } altMonitor.wait (); } } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from Alternative.priSelect (boolean[])\n" + e.toString () ); } state = ready; } } disableGuards (preCondition); state = inactive; timeout = false; return selected; } /** * Returns the index of one of the ready guards whose preCondition index * is true. The method will block until one of these guards becomes ready. * Consequetive invocations will service the guards `fairly' in the case * when many guards are always ready. Implementation note: the last * guard serviced has the lowest priority next time around. *

* Note: the length of the preCondition array must be the * same as that of the array of guards with which this object was constructed. *

* * @param preCondition the guards from which to select */ public final int fairSelect (boolean[] preCondition) { if (preCondition.length != guard.length) { throw new IllegalArgumentException ( "*** org.jcsp.lang.Alternative.select called with a preCondition array\n" + "*** whose length does not match its guard array" ); } state = enabling; enableGuards (preCondition); synchronized (altMonitor) { if (state == enabling) { state = waiting; try { if (timeout) { long delay = msecs - System.currentTimeMillis (); if (delay > Spurious.earlyTimeout) { altMonitor.wait (delay); while (state == waiting) { delay = msecs - System.currentTimeMillis (); if (delay > Spurious.earlyTimeout) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelectWithTimeout); } altMonitor.wait (delay); } else { if ((delay > 0) && (Spurious.logging)) { SpuriousLog.incEarlyTimeouts (); } break; } } } } else { altMonitor.wait (); while (state == waiting) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.AlternativeSelect); } altMonitor.wait (); } } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from Alternative.fairSelect/select (boolean[])\n" + e.toString () ); } state = ready; } } disableGuards (preCondition); state = inactive; favourite = selected + 1; if (favourite == guard.length) favourite = 0; timeout = false; return selected; } /** * Enables the guards for selection. The preCondition must be true for * an guard to be selectable. If any of the guards are ready, it sets * selected to the ready guard's index, state to ready and returns. * Otherwise, it sets selected to NONE_SELECTED and returns. *

* * @return true if and only if one of the guards is ready */ private final void enableGuards (boolean[] preCondition) { if (barrierPresent) { AltingBarrierCoordinate.startEnable (); } barrierSelected = NONE_SELECTED; for (enableIndex = favourite; enableIndex < guard.length; enableIndex++) { if (preCondition[enableIndex] && guard[enableIndex].enable (this)) { selected = enableIndex; state = ready; if (barrierTrigger) { barrierSelected = selected; barrierTrigger = false; } else if (barrierPresent) { AltingBarrierCoordinate.finishEnable (); } return; } } for (enableIndex = 0; enableIndex < favourite; enableIndex++) { if (preCondition[enableIndex] && guard[enableIndex].enable (this)) { selected = enableIndex; state = ready; if (barrierTrigger) { barrierSelected = selected; barrierTrigger = false; } else if (barrierPresent) { AltingBarrierCoordinate.finishEnable (); } return; } } selected = NONE_SELECTED; if (barrierPresent) { AltingBarrierCoordinate.finishEnable (); } } /** * Disables the guards for selection. The preCondition must be true for * an guard to be selectable. Sets selected to the index of the ready guard, * taking care of priority/fair choice. */ private void disableGuards (boolean[] preCondition) { if (selected != favourite) { // else there is nothing to disable int startIndex = (selected == NONE_SELECTED) ? favourite - 1: selected - 1; if (startIndex < favourite) { for (int i = startIndex; i >= 0; i--) { if (preCondition[i] && guard[i].disable ()) { selected = i; if (barrierTrigger) { if (barrierSelected != NONE_SELECTED) { throw new JCSP_InternalError ( "*** Second AltingBarrier completed in ALT sequence: " + barrierSelected + " and " + i ); } barrierSelected = selected; barrierTrigger = false; } } } startIndex = guard.length - 1; } for (int i = startIndex; i >= favourite; i--) { if (preCondition[i] && guard[i].disable ()) { selected = i; if (barrierTrigger) { if (barrierSelected != NONE_SELECTED) { throw new JCSP_InternalError ( "*** Second AltingBarrier completed in ALT sequence: " + barrierSelected + " and " + i ); } barrierSelected = selected; barrierTrigger = false; } } } if (selected == NONE_SELECTED) { // System.out.println ("disableGuards: NONE_SELECTED ==> " + timeIndex); // NOTE: this is a work-around for Java wait-with-timeouts sometimes // returning early. If this did not happen, we would not get here! selected = timeIndex; } } if (barrierSelected != NONE_SELECTED) { // We must choose a barrier sync selected = barrierSelected; // if one is ready - so that all AltingBarrierCoordinate.finishDisable (); // parties make the same choice. } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelInputIntSymmetricImpl.java0000644000000000000000000000525111105701167023651 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; class AltingChannelInputIntSymmetricImpl extends AltingChannelInputInt implements MultiwaySynchronisation { private final AltingBarrier ab; private final ChannelInputInt in; private boolean syncDone = false; public AltingChannelInputIntSymmetricImpl ( AltingBarrier ab, ChannelInputInt in) { this.ab = ab; this.in = in; } boolean enable (Alternative alt) { syncDone = ab.enable (alt); return syncDone; } boolean disable () { syncDone = ab.disable (); return syncDone; } public int read () { if (!syncDone) ab.sync (); syncDone = false; return in.read (); } public boolean pending () { syncDone = ab.poll (10); return syncDone; } public void poison(int strength) { in.poison(strength); } public void endRead() { in.endRead(); } public int startRead() { if (!syncDone) ab.sync(); syncDone = false; return in.read(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelInputInt.java0000644000000000000000000001004511113671251021126 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This extends {@link Guard} and {@link ChannelInputInt} * to enable a process * to choose between many integer input (and other) events. *

* A reading-end, obtained from a one-one or any-one * channel by invoking its in() method, will extend this abstract class. *

Description

* AltingChannelInputInt extends {@link Guard} and {@link ChannelInputInt} * to enable a process * to choose between many integer input (and other) events. The methods inherited from * Guard are of no concern to users of this package. *

*

Example

*
 * import org.jcsp.lang.*;
 * 
 * public class AltingIntExample implements CSProcess {
 * 
 *   private final AltingChannelInputInt in0, in1;
 *   
 *   public AltingIntExample (final AltingChannelInputInt in0,
 *                            final AltingChannelInputInt in1) {
 *     this.in0 = in0;
 *     this.in1 = in1;
 *   }
 * 
 *   public void run () {
 * 
 *     final Guard[] altChans = {in0, in1};
 *     final Alternative alt = new Alternative (altChans);
 * 
 *     while (true) {
 *       switch (alt.select ()) {
 *         case 0:
 *           System.out.println ("in0 read " + in0.read ());
 *         break;
 *         case 1:
 *           System.out.println ("in1 read " + in1.read ());
 *         break;
 *       }
 *     }
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.lang.Guard * @see org.jcsp.lang.Alternative * @author P.D. Austin and P.H. Welch */ public abstract class AltingChannelInputInt extends Guard implements ChannelInputInt { /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. * * @return state of the channel. */ public abstract boolean pending(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableBufferedOne2AnyChannel.java0000644000000000000000000000432211113671251023150 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ChannelDataStore; class PoisonableBufferedOne2AnyChannel extends One2AnyImpl { PoisonableBufferedOne2AnyChannel(ChannelDataStore _data, int _immunity) { super(new PoisonableBufferedOne2OneChannel(_data,_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedChannelOutputImpl.java0000644000000000000000000000461711113671251021476 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class SharedChannelOutputImpl implements SharedChannelOutput { private ChannelInternals channel; private int immunity; SharedChannelOutputImpl(ChannelInternals _channel, int _immunity) { channel = _channel; immunity = _immunity; } public void write(Object object) { channel.write(object); } public void poison(int strength) { if (strength > immunity) { channel.writerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingConnectionServerImpl.java0000644000000000000000000002026011105701167022174 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This class does not need to be used by standard JCSP users. It is exposed so that the connection * mechanism can be extended for custom connections. * * @author Quickstone Technologies Limited */ public class AltingConnectionServerImpl extends AltingConnectionServer { /** * Server state. The server is initially CLOSED the first request will take it to the * RECEIVED state. A reply will take it back to OPEN or CLOSED depending * on the mode of reply. From the OPEN or CLOSED state a further request can * occur. */ protected static final int SERVER_STATE_CLOSED = 1; /** * Server state. The server is initially CLOSED the first request will take it to the * RECEIVED state. A reply will take it back to OPEN or CLOSED depending * on the mode of reply. From the OPEN or CLOSED state a further request can * occur. */ protected static final int SERVER_STATE_OPEN = 2; /** * Server state. The server is initially CLOSED the first request will take it to the * RECEIVED state. A reply will take it back to OPEN or CLOSED depending * on the mode of reply. From the OPEN or CLOSED state a further request can * occur. */ protected static final int SERVER_STATE_RECEIVED = 3; private int currentServerState; private AltingChannelInput openIn; private AltingChannelInput furtherRequestIn; private ChannelInput currentInputChannel; private ChannelOutput toClient = null; private ConnectionServerMessage msg = null; /** * Constructs a new server instance. This must be called by a subclass which is responsible for * creating the channels. */ protected AltingConnectionServerImpl(AltingChannelInput openIn, AltingChannelInput furtherRequestIn) { super(openIn); this.openIn = openIn; this.furtherRequestIn = furtherRequestIn; this.currentInputChannel = openIn; currentServerState = SERVER_STATE_CLOSED; } /** * Receives some data from a client once a connection * has been established. This will block until the client * calls request(Object) but by establishing * a connection. * * @return the Object sent by the client. */ public Object request() throws IllegalStateException { if (currentServerState == SERVER_STATE_RECEIVED) throw new IllegalStateException ("Cannot call request() twice on ConnectionServer without replying to the client first."); ConnectionClientMessage msg = (ConnectionClientMessage)currentInputChannel.read(); if (currentServerState == SERVER_STATE_CLOSED) { if (msg instanceof ConnectionClientOpenMessage) { //channel to use to reply to client toClient = ((ConnectionClientOpenMessage) msg).replyChannel; setAltingChannel(furtherRequestIn); currentInputChannel = furtherRequestIn; //create a new msg for connection established //don't know if client implementation will have finished with //message after connection closed this.msg = new ConnectionServerMessage(); } else throw new IllegalStateException("Invalid message received from client"); } currentServerState = SERVER_STATE_RECEIVED; return msg.data; } /** * Sends some data back to the client after a request * has been received but keeps the connection open. After calling * this method, the server should call recieve() * to receive a further request. * * @param data the data to send to the client. */ public void reply(Object data) throws IllegalStateException { reply(data, false); } /** * Sends some data back to the client after a request * has been received. The closed parameter indicates whether or not * the connection should be closed. The connection will be closed * iff close is true. * * @param data the data to send to the client. * @param close boolean indicating whether or not the * connection should be closed. */ public void reply(Object data, boolean close) throws IllegalStateException { if (currentServerState != SERVER_STATE_RECEIVED) throw new IllegalStateException ("Cannot call reply(Object, boolean) on a ConnectionServer that has not received an unacknowledge request."); //set open to true before replying msg.data = data; msg.open = !close; toClient.write(msg); if (close) { currentServerState = SERVER_STATE_CLOSED; toClient = null; setAltingChannel(openIn); currentInputChannel = openIn; } else currentServerState = SERVER_STATE_OPEN; } /** * Sends some data back to the client and closes the connection. * This method will not block. After calling this method, the * server may call accept() in order to allow another * connection to this server to be established. * * If this method did not take any data to send back to the client, * and the server was meant to call reply(Object) followed * by a close(), then there would be a race hazard at the * client as it would not know whether the connection had * remained open or not. * * @param data the data to send back to client. */ public void replyAndClose(Object data) throws IllegalStateException { reply(data, true); } protected int getServerState() { return currentServerState; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedConnectionClient.java0000644000000000000000000000567511105701167021327 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

* Defines an interface for a client end of a connection that * can be shared by multiple clients. *

*

* This object cannot itself be shared between concurrent processes * but duplicate objects can be generated that can be used by * multiple concurrent processes. This can be achieved using * the {@link #duplicate()} method. *

*

* See {@link ConnectionClient} for a fuller explanation * of how to use connection client objects. *

* * @author Quickstone Technologies Limited */ public interface SharedConnectionClient extends ConnectionClient { /** * Returns a duplicates SharedConnectionClient object * which may be used by another process to this instance. * * @return a duplicate SharedConnectionClient object. */ public SharedConnectionClient duplicate(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableChannelOutput.java0000644000000000000000000000552411105701167021505 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a channel output end which may reject data if the reader is not prepared * to receive it and calls reject instead of read on the input channel end. * * @author Quickstone Technologies Limited * * @deprecated This channel is superceded by the poison mechanisms, please see {@link PoisonException}. It remains only because it is used by some of the networking features. */ public interface RejectableChannelOutput extends ChannelOutput { /** * Writes data over the channel. * * @param o an object to write over the channel. * @throws ChannelDataRejectedException if the reader rejects the data instead of reading it from the channel. */ public void write(Object o) throws ChannelDataRejectedException; } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyConnection.java0000644000000000000000000000517411105701167020235 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a connection shared by multiple clients and multiple servers. * * @author Quickstone Technologies Limited */ public interface Any2AnyConnection extends ConnectionWithSharedAltingClient, ConnectionWithSharedAltingServer { /** * Returns a reference to the client end of the connection for use by the client processes. */ public SharedAltingConnectionClient client(); /** * Returns a reference to the server end of the connection for use by the server processes. */ public SharedConnectionServer server(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyConnectionImpl.java0000644000000000000000000001122011105701167021044 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.Buffer; /** * This class is an implementation of Any2AnyConnection. * Each end is safe to be used by one thread at a time. * * @author Quickstone Technologies Limited */ class Any2AnyConnectionImpl extends AbstractConnectionImpl implements Any2AnyConnection { private One2OneChannel chanToServer; private One2OneChannel chanFromServer; private Any2OneChannel chanClientSynch; private Any2OneChannel chanServerSynch; /** * Initializes all the attributes to necessary values. * Channels are created using the static factory in the * ChannelServer inteface. * * Constructor for One2OneConnectionImpl. */ public Any2AnyConnectionImpl() { super(); chanToServer = ConnectionServer.FACTORY.createOne2One(new Buffer(1)); chanFromServer = ConnectionServer.FACTORY.createOne2One(new Buffer(1)); chanClientSynch = ConnectionServer.FACTORY.createAny2One(new Buffer(1)); chanServerSynch = ConnectionServer.FACTORY.createAny2One(new Buffer(1)); } /** * Returns a SharedAltingConnectionClient object for this * connection. This method can be called multiple times to return a new * SharedAltingConnectionClient object each time. Any object * created can only be used by one process at a time but the set of * objects constructed can be used concurrently. * * @return a new SharedAltingConnectionClient object. */ public SharedAltingConnectionClient client() { return new SharedAltingConnectionClient( chanFromServer.in(), chanClientSynch.in(), chanToServer.out(), chanToServer.out(), chanClientSynch.out(), chanFromServer.out(), this); } /** * Returns a SharedConnectionServer object for this * connection. This method can be called multiple times to return a new * SharedConnectionServer object each time. Any object * created can only be used by one process at a time but the set of * objects constructed can be used concurrently. * * @return a new SharedConnectionServer object. */ public SharedConnectionServer server() { return new SharedConnectionServerImpl( chanToServer.in(), chanToServer.in(), chanServerSynch.in(), chanServerSynch.out(), this); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedAny2OneChannel.java0000644000000000000000000001130311105701167021132 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.*; /** * This implements an any-to-one object channel with user-definable buffering, * safe for use by many writers and one reader. *

Description

* BufferedAny2OneChannel implements an any-to-one object channel with * user-definable buffering. It is safe for use by many writing processes * but only one reader. Writing processes compete with each other to use * the channel. Only the reader and one writer will * actually be using the channel at any one time. This is taken care of by * BufferedAny2OneChannel -- user processes just read from or write to it. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ChannelDataStore ChannelDataStore} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * *

Implementation Note and Caution

* Fair servicing of writers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * any-1 channels. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.BufferedOne2OneChannel * @see org.jcsp.lang.BufferedOne2AnyChannel * @see org.jcsp.lang.BufferedAny2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin * @author P.H. Welch */ class BufferedAny2OneChannel extends Any2OneImpl { /** * Constructs a new BufferedAny2OneChannel with the specified ChannelDataStore. * * @param data The ChannelDataStore used to store the data for the channel */ public BufferedAny2OneChannel(ChannelDataStore data) { super(new BufferedOne2OneChannel(data)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/StandardChannelFactory.java0000644000000000000000000003161011105701167021307 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ChannelDataStore; /** *

This class acts as a Factory for creating * channels. It can create non-buffered and buffered channels * and also arrays of non-buffered and buffered channels.

* *

The Channel objects created by this Factory are formed of * separate objects for the read and write ends. Therefore the * ChannelInput object cannot be cast into the * ChannelOutput object and vice-versa.

* *

The current implementation uses an instance of the * RiskyChannelFactory to construct the underlying * raw channels.

* * @author Quickstone Technologies Limited */ public class StandardChannelFactory implements ChannelFactory, ChannelArrayFactory, BufferedChannelFactory, BufferedChannelArrayFactory { private static StandardChannelFactory defaultInstance = new StandardChannelFactory(); /** * Constructs a new factory. */ public StandardChannelFactory() { super(); } /** * Returns a default instance of a channel factory. */ public static StandardChannelFactory getDefaultInstance() { return defaultInstance; } /** * Constructs and returns a One2OneChannel object. * * @return the channel object. * * @see org.jcsp.lang.ChannelFactory#createOne2One() */ public One2OneChannel createOne2One() { return new One2OneChannelImpl(); } /** * Constructs and returns an Any2OneChannel object. * * @return the channel object. * * @see org.jcsp.lang.ChannelFactory#createAny2One() */ public Any2OneChannel createAny2One() { return new Any2OneChannelImpl(); } /** * Constructs and returns a One2AnyChannel object. * * @return the channel object. * * @see org.jcsp.lang.ChannelFactory#createOne2Any() */ public One2AnyChannel createOne2Any() { return new One2AnyChannelImpl(); } /** * Constructs and returns an Any2AnyChannel object. * * @return the channel object. * * @see org.jcsp.lang.ChannelFactory#createAny2Any() */ public Any2AnyChannel createAny2Any() { return new Any2AnyChannelImpl(); } /** * Constructs and returns an array of One2OneChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2One(int) */ public One2OneChannel[] createOne2One(int n) { One2OneChannel[] toReturn = new One2OneChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2One(); return toReturn; } /** * Constructs and returns an array of Any2OneChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2One(int) */ public Any2OneChannel[] createAny2One(int n) { Any2OneChannel[] toReturn = new Any2OneChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2One(); return toReturn; } /** * Constructs and returns an array of One2AnyChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createOne2Any(int) */ public One2AnyChannel[] createOne2Any(int n) { One2AnyChannel[] toReturn = new One2AnyChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2Any(); return toReturn; } /** * Constructs and returns an array of Any2AnyChannel * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelArrayFactory#createAny2Any(int) */ public Any2AnyChannel[] createAny2Any(int n) { Any2AnyChannel[] toReturn = new Any2AnyChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2Any(); return toReturn; } /** *

Constructs and returns a One2OneChannel object which * uses the specified ChannelDataStore object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStore to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelFactory#createOne2One(org.jcsp.util.ChannelDataStore) * @see org.jcsp.util.ChannelDataStore */ public One2OneChannel createOne2One(ChannelDataStore buffer) { return new BufferedOne2OneChannel(buffer); } /** *

Constructs and returns a Any2OneChannel object which * uses the specified ChannelDataStore object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStore to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelFactory#createAny2One(org.jcsp.util.ChannelDataStore) * @see org.jcsp.util.ChannelDataStore */ public Any2OneChannel createAny2One(ChannelDataStore buffer) { return new BufferedAny2OneChannel(buffer); } /** *

Constructs and returns a One2AnyChannel object which * uses the specified ChannelDataStore object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStore to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelFactory#createOne2Any(org.jcsp.util.ChannelDataStore) * @see org.jcsp.util.ChannelDataStore */ public One2AnyChannel createOne2Any(ChannelDataStore buffer) { return new BufferedOne2AnyChannel(buffer); } /** *

Constructs and returns a Any2AnyChannel object which * uses the specified ChannelDataStore object as a buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. *

* * @param buffer the ChannelDataStore to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelFactory#createAny2Any(org.jcsp.util.ChannelDataStore) * @see org.jcsp.util.ChannelDataStore */ public Any2AnyChannel createAny2Any(ChannelDataStore buffer) { return new BufferedAny2AnyChannel(buffer); } /** *

Constructs and returns an array of One2OneChannel objects * which use the specified ChannelDataStore object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStore to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelArrayFactory#createOne2One(org.jcsp.util.ChannelDataStore,int) * @see org.jcsp.util.ChannelDataStore */ public One2OneChannel[] createOne2One(ChannelDataStore buffer, int n) { One2OneChannel[] toReturn = new One2OneChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2One(buffer); return toReturn; } /** *

Constructs and returns an array of Any2OneChannel objects * which use the specified ChannelDataStore object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStore to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelArrayFactory#createAny2One(org.jcsp.util.ChannelDataStore,int) * @see org.jcsp.util.ChannelDataStore */ public Any2OneChannel[] createAny2One(ChannelDataStore buffer, int n) { Any2OneChannel[] toReturn = new Any2OneChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2One(buffer); return toReturn; } /** *

Constructs and returns an array of One2AnyChannel objects * which use the specified ChannelDataStore object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStore to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelArrayFactory#createOne2Any(org.jcsp.util.ChannelDataStore,int) * @see org.jcsp.util.ChannelDataStore */ public One2AnyChannel[] createOne2Any(ChannelDataStore buffer, int n) { One2AnyChannel[] toReturn = new One2AnyChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createOne2Any(buffer); return toReturn; } /** *

Constructs and returns an array of Any2AnyChannel objects * which use the specified ChannelDataStore object as a * buffer. *

*

The buffer supplied to this method is cloned before it is inserted into * the channel. This is why an array of buffers is not required. *

* * @param buffer the ChannelDataStore to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelArrayFactory#createAny2Any(org.jcsp.util.ChannelDataStore,int) * @see org.jcsp.util.ChannelDataStore */ public Any2AnyChannel[] createAny2Any(ChannelDataStore buffer, int n) { Any2AnyChannel[] toReturn = new Any2AnyChannel[n]; for (int i = 0; i < n; i++) toReturn[i] = createAny2Any(buffer); return toReturn; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedAny2AnyChannelIntImpl.java0000644000000000000000000001167711105701167022453 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.*; /** * This implements an any-to-any integer channel with user-definable buffering, * safe for use by many writers and many readers. *

Description

* BufferedAny2AnyChannelIntImpl implements an any-to-any integer channel with * user-definable buffering. It is safe for use by any number of reading or * writing processes. Reading processes compete with each other to use * the channel. Writing processes compete with each other to use the channel. * Only the reader and one writer will * actually be using the channel at any one time. This is taken care of by * BufferedAny2AnyChannelIntImpl -- user processes just read from or write to it. *

* Please note that this is a sefely shared channel and not * a multicaster. Currently, multicasting has to be managed by * writing active processes (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example of broadcasting). *

* All reading processes and writing processes commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ints.ChannelDataStoreInt ChannelDataStoreInt} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * *

Implementation Note and Caution

* Fair servicing of readers and writers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * any-any channels. * * @see org.jcsp.lang.BufferedOne2OneChannel * @see org.jcsp.lang.BufferedOne2AnyChannel * @see org.jcsp.lang.BufferedAny2AnyChannel * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin * @author P.H. Welch */ class BufferedAny2AnyChannelIntImpl extends Any2AnyIntImpl { public BufferedAny2AnyChannelIntImpl(ChannelDataStoreInt data) { super(new BufferedOne2OneChannelIntImpl(data)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelOutputInt.java0000644000000000000000000000762311113671251020200 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for writing to integer channels. *

* A writing-end, conforming to this interface, * is obtained from a channel by invoking its out() method. *

Description

* ChannelOutputInt defines the interface for writing to integer channels. * The interface contains only one method - write(int o). * This method will block the calling process until the int has * been accepted by the channel. In the (default) case of a zero-buffered * synchronising CSP channel, this happens only when a process at the other * end of the channel invokes (or has already invoked) a read(). *

* ChannelOutputInt variables are used to hold integer channels * that are going to be used only for output by the declaring process. * This is a security matter -- by declaring a ChannelOutputInt * interface, any attempt to input from the channel will generate * a compile-time error. For example, the following code fragment will * not compile: * *

 * int doRead (ChannelOutputInt c) {
 *   return c.read ();   // illegal
 * }
 * 
* * When configuring a CSProcess with output integer channels, they should * be declared as ChannelOutputInt variables. The actual channel passed, * of course, may belong to any channel class that implements * ChannelOutputInt. * *

Example

*
 * void doWrite (ChannelOutputInt c, int i) {
 *   c.write (i);
 * }
 * 
* * @see org.jcsp.lang.SharedChannelOutputInt * @see org.jcsp.lang.ChannelInputInt * @author P.D. Austin */ public interface ChannelOutputInt extends Poisonable { /** * Write an int to the channel. * * @param i the integer to write to the channel */ public void write(int i); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedConnectionServer.java0000644000000000000000000000515511105701167021350 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

* Defines an interface for a server end of a connection that * can be shared by multiple concurrent processes. *

*

* SharedConnectionServer objects cannot have * their requests ALTed over. *

* * @author Quickstone Technologies Limited */ public interface SharedConnectionServer extends ConnectionServer { /** *

* Creates a duplicate copy of the connection end. *

* * @return the duplicate SharedConnectionServer * object. * */ public SharedConnectionServer duplicate(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableBufferedAny2AnyChannel.java0000644000000000000000000000432211113671251023156 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ChannelDataStore; class PoisonableBufferedAny2AnyChannel extends Any2AnyImpl { PoisonableBufferedAny2AnyChannel(ChannelDataStore _data, int _immunity) { super(new PoisonableBufferedOne2OneChannel(_data,_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableBufferedAny2OneChannel.java0000644000000000000000000000432211113671251023150 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ChannelDataStore; class PoisonableBufferedAny2OneChannel extends Any2OneImpl { PoisonableBufferedAny2OneChannel(ChannelDataStore _data, int _immunity) { super(new PoisonableBufferedOne2OneChannel(_data,_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BarrierError.java0000644000000000000000000000451611105701167017333 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; //{{{ javadoc /** * This is thrown for an illegal operation on an Barrier. * *

Description

* Currently, there is only one cause: more processes have resigned than were * enrolled. * * @author P.H. Welch */ //}}} public class BarrierError extends Error { public BarrierError (String s) { super (s); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyChannelInt.java0000644000000000000000000001344111113671251020146 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for a one-to-any integer channel, * safe for use by one writer and many readers. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Channels may be {@link Channel#one2anyInt() synchronising}, * {@link Channel#one2anyInt(org.jcsp.util.ints.ChannelDataStoreInt) buffered}, * {@link Channel#one2anyInt(int) poisonable} * or {@link Channel#one2anyInt(org.jcsp.util.ints.ChannelDataStoreInt,int) both} * (i.e. buffered and poisonable). *

*

Description

* One2AnyChannelInt is an interface for a channel which is safe * for use by many reading processes but only one writer. Reading processes * compete with each other to use the channel. Only one reader and the writer will * actually be using the channel at any one time. This is managed by the * channel – user processes just read from or write to it. *

* Please note that this is a safely shared channel and not * a broadcaster. Currently, broadcasting has to be managed by * writing an active process (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example). *

*

* All reading processes and the writing process commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

*

* The default semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. A reading process must wait * for the matching writer and vice-versa. *

*

* The static methods of {@link Channel} construct channels with * either the default semantics or with buffering to user-specified capacity * and a range of blocking/overwriting policies. * Various buffering plugins are given in the org.jcsp.util package, but * careful users may write their own. *

*

* The {@link Channel} methods also provide for the construction of * {@link Poisonable} channels and for arrays of channels. * *

Implementation Note and Caution

* Fair servicing of readers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * 1-any channels. * * @see org.jcsp.lang.Channel * @see org.jcsp.lang.One2OneChannelInt * @see org.jcsp.lang.Any2OneChannelInt * @see org.jcsp.lang.Any2AnyChannelInt * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin and P.H. Welch */ public interface One2AnyChannelInt { /** * Returns the input end of the channel. */ public SharedChannelInputInt in(); /** * Returns the output end of the channel. */ public ChannelOutputInt out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableOne2AnyChannelIntImpl.java0000644000000000000000000000421211113671251023000 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class PoisonableOne2AnyChannelIntImpl extends One2AnyIntImpl { PoisonableOne2AnyChannelIntImpl(int _immunity) { super(new PoisonableOne2OneChannelIntImpl(_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BasicOne2OneChannelSymmetricInt.java0000644000000000000000000000426511105701167023004 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; class BasicOne2OneChannelSymmetricInt implements One2OneChannelSymmetricInt { private final AltingBarrier[] ab = AltingBarrier.create (2); private final One2OneChannelInt c = Channel.one2oneInt(); public AltingChannelInputInt in () { return new AltingChannelInputIntSymmetricImpl (ab[0], c.in()); } public AltingChannelOutputInt out (){ return new AltingChannelOutputIntSymmetricImpl (ab[1], c.out()); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelOutput.java0000644000000000000000000000757311113671251020670 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This extends {@link Guard} and {@link ChannelOutput} * to enable a process * to choose between many integer output (and other) events. *

* A writing-end, obtained only from a {@link One2OneChannelSymmetric symmetric} * channel by invoking its out() method, will implement this interface. *

Description

* AltingChannelOutput extends {@link Guard} and {@link ChannelOutput} * to enable a process * to choose between many integer output (and other) events. The methods inherited from * Guard are of no concern to users of this package. *

*

Example

*
 * import org.jcsp.lang.*;
 * 
 * public class AltingOutputExample implements CSProcess {
 * 
 *   private final AltingChannelOutput out0, out1;
 *   
 *   public AltingOutputExample (final AltingChannelOutput out0,
 *                               final AltingChannelOutput out1) {
 *     this.out0 = out0;
 *     this.out1 = out1;
 *   }
 * 
 *   public void run () {
 * 
 *     final Guard[] altChans = {out0, out1};
 *     final Alternative alt = new Alternative (altChans);
 * 
 *     while (true) {
 *       switch (alt.select ()) {
 *         case 0:
 *           out0.write (new Integer (0));
 *           System.out.println ("out0 written");
 *         break;
 *         case 1:
 *           out1.write (new Integer (1));
 *           System.out.println ("out1 written");
 *         break;
 *       }
 *     }
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.lang.Guard * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.One2OneChannelSymmetric * @see org.jcsp.lang.AltingChannelOutputInt * @author P.H. Welch */ //}}} public abstract class AltingChannelOutput extends Guard implements ChannelOutput { // nothing alse to add /** * Returns whether the receiver is committed to read from this channel. *

* Note: if this returns true, you must commit to write down this channel. * * @return state of the channel. */ public abstract boolean pending (); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Bucket.java0000644000000000000000000004162511105701167016152 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // 2006 Neil Brown // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * This enables bucket synchronisation between a set of processes. *

* Shortcut to the Constructor and Method Summaries. * *

Description

* A bucket is a non-deterministic cousin of a {@link Barrier}. A bucket is * somewhere to {@link #fallInto fallInto} when a process needs somewhere to park * itself. There is no limit on the number of processes that can fallInto * a bucket - and all are blocked when they do. * Release happens when a process (and it will have * to be another process) chooses to {@link #flush flush} that bucket. * When that happens, all processes in the bucket (which may be none) are * rescheduled for execution. *

* Buckets are a non-deterministic primitive, since the decision to flush * is a free (internal) choice of the process concerned and the scheduling * of that flush impacts on the semantics. * Usually, only one process is given responsibility for flushing a bucket * (or set of buckets). * Flushing a bucket does not block the flusher. *

* Note: this notion of bucket corresponds to * the BUCKET * synchronisation primitive added to * the KRoC * occam language system. * *

Implementation Note

* The {@link #fallInto fallInto} and {@link #flush flush} * methods of Bucket are just a re-badging of the * {@link java.lang.Object#wait() wait} and * {@link java.lang.Object#notifyAll() notifyAll} methods of * {@link java.lang.Object} - but without the need to gain a monitor lock and * without the need to look out for the wait being interrupted. *

* Currently, though, this is how they are implemented. * Beware that a notifyAll carries an O(n) overhead (where n is * the number of processes being notified), since each notified process must regain * the monitor lock before it can exit the synchronized region. * Future JCSP implementations of Bucket will look to follow occam kernels * and reduce the overheads of both fallInto and flush to O(1). * *

A Simple Example

* This consists of 10 workers, one bucket and one flusher: *

* Here is the code for this network: *
 * import org.jcsp.lang.*;
 * 
 * public class BucketExample1 {
 * 
 *   public static void main (String[] args) {
 * 
 *     final int nWorkers = 10;
 * 
 *     final int second = 1000;
 *     // JCSP timer units are milliseconds
 *     final int interval = 5*second;
 *     final int maxWork = 10*second;
 * 
 *     final long seed = new CSTimer ().read ();
 *     // for the random number generators
 * 
 *     final Bucket bucket = new Bucket ();
 * 
 *     final Flusher flusher = new Flusher (interval, bucket);
 * 
 *     final Worker[] workers = new Worker[nWorkers];
 *     for (int i = 0; i < workers.length; i++) {
 *       workers[i] = new Worker (i, i + seed, maxWork, bucket);
 *     }
 * 
 *     System.out.println ("*** Flusher: interval = " + interval
 *                         + " milliseconds");
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         flusher,
 *         new Parallel (workers)
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* A Worker cycle consists of one shift (which takes a random amount of time) * and, then, falling into the bucket: *
 * import org.jcsp.lang.*;
 * import java.util.*;
 * 
 * public class Worker implements CSProcess {
 * 
 *   private final int id;
 *   private final long seed;
 *   private final int maxWork;
 *   private final Bucket bucket;
 * 
 *   public Worker (int id, long seed, int maxWork, Bucket bucket) {
 *     this.id = id;
 *     this.seed = seed;
 *     this.maxWork = maxWork;
 *     this.bucket = bucket;
 *   }
 * 
 *   public void run () {
 * 
 *     final Random random = new Random (seed);
 *     // each process gets a different seed
 * 
 *     final CSTimer tim = new CSTimer ();
 *     final int second = 1000;
 *     // JCSP timer units are milliseconds
 * 
 *     final String working = "\t... Worker " + id
 *                            + " working ...";
 *     final String falling = "\t\t\t     ... Worker " + id
 *                            + " falling ...";
 *     final String flushed = "\t\t\t\t\t\t  ... Worker "
 *                            + id + " flushed ...";
 * 
 *     while (true) {
 *       System.out.println (working);
 *       tim.sleep (random.nextInt (maxWork));
 *       //These lines represent one unit of work
 * 
 *       System.out.println (falling);
 *       bucket.fallInto ();
 *       System.out.println (flushed);
 *     }
 *   }
 * 
 * }
 * 
* The Flusher just flushes the bucket at preset time intervals: *
import org.jcsp.lang.*;
 * import java.util.*;
 * 
 * public class Flusher implements CSProcess {
 * 
 *   private final int interval;
 *   private final Bucket bucket;
 * 
 *   public Flusher (int interval, Bucket bucket) {
 *     this.interval = interval;
 *     this.bucket = bucket;
 *   }
 * 
 *   public void run () {
 * 
 *     final CSTimer tim = new CSTimer ();
 *     long timeout = tim.read () + interval;
 * 
 *     while (true) {
 *       tim.after (timeout);
 *       System.out.println ("*** Flusher: about to flush ...");
 *       final int n = bucket.flush ();
 *       System.out.println ("*** Flusher: number flushed = " + n);
 *       timeout += interval;
 *     }
 *   }
 * 
 * }
 * 
* * *

The Flying Dingbats

* This consists of many buckets, a single bucket keeper (responsible for * flushing the buckets) and flock of Dingbats (who regularly fall into various * buckets). Here is the system diagram: *

* And here is the network code: *
 * import org.jcsp.lang.*;
 * 
 * public class BucketExample2 {
 * 
 *   public static void main (String[] args) {
 * 
 *     final int minDingbat = 2;
 *     final int maxDingbat = 10;
 *     final int nDingbats = (maxDingbat - minDingbat) + 1;
 * 
 *     final int nBuckets = 2*maxDingbat;
 * 
 *     final Bucket[] bucket = Bucket.create (nBuckets);
 * 
 *     final int second = 1000;
 *     // JCSP timer units are milliseconds
 *     final int tick = second;
 *     final BucketKeeper bucketKeeper = new BucketKeeper (tick, bucket);
 * 
 *     final Dingbat[] dingbats = new Dingbat[nDingbats];
 *     for (int i = 0; i < dingbats.length; i++) {
 *       dingbats[i] = new Dingbat (i + minDingbat, bucket);
 *     }
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         bucketKeeper,
 *         new Parallel (dingbats)
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* The BucketKeeper keeps time, flushing buckets in sequence at a steady rate. * When the last one has been flushed, it starts again with the first: *
 * import org.jcsp.lang.*;
 * 
 * class BucketKeeper implements CSProcess {
 * 
 *   private final long interval;
 *   private final Bucket[] bucket;
 * 
 *   public BucketKeeper (long interval, Bucket[] bucket) {
 *     this.interval = interval;
 *     this.bucket = bucket;
 *   }
 * 
 *   public void run () {
 * 
 *     String[] spacer = new String[bucket.length];
 *     spacer[0] = "";
 *     for (int i = 1; i < spacer.length; i++) {
 *       spacer[i] = spacer[i - 1] + "  ";
 *     }
 * 
 *     final CSTimer tim = new CSTimer ();
 *     long timeout = tim.read ();
 *     int index = 0;
 * 
 *     while (true) {
 *       final int n = bucket[index].flush ();
 *       if (n == 0) {
 *         System.out.println (spacer[index] + "*** bucket " +
 *                             index + " was empty ...");
 *       }
 *       index = (index + 1) % bucket.length;
 *       timeout += interval;
 *       tim.after (timeout);
 *     }
 *   }
 * 
 * }
 * 
* So the buckets represent time values. A process falling into one of them will sleep * until the prescribed time when the BucketKeeper next flushes it. *

* Dingbats live the following cycle. First, they do some work (rather brief * in the following code). Then, they work out which bucket to fall into and fall into it * - that is all. In this case, Dingbats just fly on id buckets * from whence they were just flushed (where id is the Dingbat number * indicated in the above network diagram): *

 * import org.jcsp.lang.*;
 * 
 * public class Dingbat implements CSProcess {
 * 
 *   private final int id;
 *   private final Bucket[] bucket;
 * 
 *   public Dingbat (int id, Bucket[] bucket) {
 *     this.id = id;
 *     this.bucket = bucket;
 *   }
 * 
 *   public void run () {
 * 
 *     int logicalTime = 0;
 * 
 *     String[] spacer = new String[bucket.length];
 *     spacer[0] = "";
 *     for (int i = 1; i < spacer.length; i++) {
 *       spacer[i] = spacer[i - 1] + "  ";
 *     }
 * 
 *     String message = "Hello world from " + id + " ==> time = ";
 * 
 *     while (true) {
 *       logicalTime += id;
 *       final int slot = logicalTime % bucket.length;
 *       // assume: id <= bucket.length
 *       bucket[slot].fallInto ();
 *       System.out.println (spacer[slot] + message + logicalTime);
 *       // one unit of work
 *     }
 *   }
 * 
 * }
 * 
* *

Danger - Race Hazard

* This example contains a race hazard whose elimination is left as an exercise * for the reader. The problem is to ensure that all flushed Dingbats have settled * in their next chosen buckets before the BucketKeeper next flushes it. * If a Dingbat is a bit slow, it may fall into its chosen bucket too late - * the BucketKeeper has already flushed it and the creature will have to remain * there until the next cycle. *

* With the rate of flushing used in the above system, this is unlikely to happen. * But it is just possible - if something suspended execution of the system for * a few seconds immediately following a flush, then the BucketKeeper could * be rescheduled before the flying Dingbats. * *

Acknowledgement

* This example is from a discrete event modelling approach due to Jon Kerridge (Napier * University, Scotland). The Dingbats could easilly model their own timeouts * for themselves. However, setting a timeout is an O(n) operation * (where n is the number of processes setting them). Here, there is only one * process setting timeouts (the BucketKeeper) and the bucket operations * fallInto and flush have O(1) costs (at least, that is * the case for occam). *

* Of course, removal of the above race hazard means that the timeout by * the BucketKeeper can also be eliminated. The buckets can be flushed just as * soon as it knows that the previously flushed Dingbats have settled. * In this way, the event model can proceed at full speed, maintaining correct * simulated time - each bucket representing one time unit - without needing any * timeouts in the simulation itself. *

* * @see org.jcsp.lang.Barrier * * @author P.H. Welch */ public class Bucket implements Serializable { /** * The number of processes currently enrolled on this bucket. */ private int nHolding = 0; /** * The monitor lock used for synchronization */ private final Object bucketLock = new Object(); /** * Barrier uses an even/odd flag because the barrier cannot sync without every process * Bucket can happily keep working while old processes are waiting around, so a flag is not enough * Instead, a count must be used. Theoretically this is unsafe, but the likelihood of the bucket * completing 4 *billion* cycles before the process wakes up is somewhat slim. */ private int bucketCycle = 0; /** * Fall into the bucket. * The process doing this will be blocked until the next {@link #flush}. */ public void fallInto() { synchronized (bucketLock) { nHolding++; // System.out.println ("Bucket.fallInto : " + nHolding); try { int spuriousCycle = bucketCycle; bucketLock.wait (); while (spuriousCycle == bucketCycle) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.BucketFallInto); } bucketLock.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from Bucket.fallInto ()\n" + e.toString ()); } } } /** * Flush the bucket. All held processes will be released. * It returns the number that were released. *

* @return the number of processes flushed. */ public int flush () { synchronized (bucketLock) { // System.out.println ("Bucket.flush : " + nHolding); final int tmp = nHolding; nHolding = 0; bucketCycle += 1; bucketLock.notifyAll (); return tmp; } } /** * This returns the number of processes currently held in the bucket. * Note that this number is volatile - for information only! * By the time the invoker of this method receives it, it might have changed (because * of further processes falling into the bucket or someone flushing it). *

* @return the number of processes currently held in the bucket. */ public int holding () { synchronized (bucketLock) { return nHolding; } } /** * Creates an array of Buckets. *

* * @param n the number of Buckets to create in the array * @return the array of Buckets */ public static Bucket[] create (int n) { Bucket[] buckets = new Bucket[n]; for (int i = 0; i < n; i++) { buckets[i] = new Bucket (); } return buckets; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableOne2OneChannel.java0000644000000000000000000000673711105701167021461 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

This implements a one-to-one object channel * for use by a single writer and single reader. Refer to {@link One2OneChannel} for a * description of this behaviour.

* *

Additionally, this channel supports a reject operation. The reader may call * the reject method to force any current writer to abort with a * ChannelDataRejectedException. Subsequent read and write attempts will immediately cause a * ChannelDataRejectedException.

* *

Note that the reject operation cannot be called concurrently to a read.

* * @author Quickstone Technologies Limited * * @deprecated This channel is superceded by the poison mechanisms, please see {@link PoisonException}. It remains only because it is used by some of the networking features. */ public class RejectableOne2OneChannel implements RejectableChannel { private One2OneChannelImpl innerChannel; /** * Constructs a new channel. */ public RejectableOne2OneChannel() { innerChannel = (One2OneChannelImpl)Channel.one2one(); } public RejectableAltingChannelInput inAlt() { return new RejectableAltingChannelInputImpl(innerChannel,0); } public RejectableChannelInput in() { return new RejectableChannelInputImpl(innerChannel,0); } public RejectableChannelOutput out() { return new RejectableChannelOutputImpl(innerChannel,0); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedAltingConnectionClient.java0000644000000000000000000001050111105701167022446 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

* Implements a client end of a Connection which can have multiple * client processes. *

*

* This object cannot itself be shared between concurrent processes * but duplicate objects can be generated that can be used by * multiple concurrent processes. This can be achieved using * the {@link #duplicate()} method. *

*

* The reply from the server can be ALTed over. *

* * @author Quickstone Technologies Limited */ public class SharedAltingConnectionClient extends AltingConnectionClientImpl implements SharedConnectionClient { private ChannelInput synchIn; private ChannelOutput synchOut; private ConnectionWithSharedAltingClient parent; protected SharedAltingConnectionClient(AltingChannelInput fromServer, ChannelInput synchIn, ChannelOutput openToServer, ChannelOutput reqToServer, SharedChannelOutput synchOut, ChannelOutput backToClient, ConnectionWithSharedAltingClient parent) { super(fromServer, openToServer, reqToServer, backToClient); this.synchIn = synchIn; this.synchOut = synchOut; this.parent = parent; } protected final void claim() { synchOut.write(null); } protected final void release() { synchIn.read(); } /** *

* Returns a SharedConnectionClient object that is * a duplicate of the object on which this method is called. *

*

* This allows a process using a SharedAltingConnectionClient * object to pass references to the connection client to multiple * processes. *

*

* The object returned can be cast into a * SharedConnectionClient object. *

* * @return a duplicate SharedAltingConnectionClient object. */ public SharedConnectionClient duplicate() { return parent.client(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelOutput.java0000644000000000000000000000767611113671251017535 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for writing to object channels. *

* A writing-end, conforming to this interface, * is obtained from a channel by invoking its out() method. *

Description

* ChannelOutput defines the interface for writing to object channels. * The interface contains only one method - write(Object o). * This method will block the calling process until the Object has * been accepted by the channel. In the (default) case of a zero-buffered * synchronising CSP channel, this happens only when a process at the other * end of the channel invokes (or has already invoked) a read(). *

* ChannelOutput variables are used to hold channels * that are going to be used only for output by the declaring process. * This is a security matter -- by declaring a ChannelOutput * interface, any attempt to input from the channel will generate * a compile-time error. For example, the following code fragment will * not compile: * *

 * Object doRead (ChannelOutput c) {
 *   return c.read ();   // illegal
 * }
 * 
* * When configuring a CSProcess with output channels, they should * be declared as ChannelOutput variables. The actual channel passed, * of course, may belong to any channel class that implements * ChannelOutput. *

* Instances of any class may be written to a channel. * *

Example

*
 * void doWrite (ChannelOutput c, Object o) {
 *   c.write (o);
 * }
 * 
* * @see org.jcsp.lang.SharedChannelOutput * @see org.jcsp.lang.ChannelInput * @author P.D. Austin */ public interface ChannelOutput extends Poisonable { /** * Write an Object to the channel. * * @param object the object to write to the channel */ public void write(Object object); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionArrayFactory.java0000644000000000000000000000743211105701167021361 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a factory that can create arrays of connections. * * @author Quickstone Technologies Limited */ public interface ConnectionArrayFactory { /** * Constructs and returns an array of instances of an implementation of * One2OneConnection. * * @param n the number of One2OneConnection objects * to construct. * * @return the constructed array of One2OneConnection * objects. */ public One2OneConnection[] createOne2One(int n); /** * Constructs and returns an array of instances of an implementation of * Any2OneConnection. * * @param n the number of Any2OneConnection objects * to construct. * * @return the constructed array of Any2OneConnection * objects. */ public Any2OneConnection[] createAny2One(int n); /** * Constructs and returns an array of instances of an implementation of * One2AnyConnection. * * @param n the number of One2AnyConnection objects * to construct. * * @return the constructed array of One2AnyConnection * objects. */ public One2AnyConnection[] createOne2Any(int n); /** * Constructs and returns an array of instances of an implementation of * Any2AnyConnection. * * @param n the number of Any2AnyConnection objects * to construct. * * @return the constructed array of Any2AnyConnection * objects. */ public Any2AnyConnection[] createAny2Any(int n); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableOne2OneChannelIntImpl.java0000644000000000000000000002521011113671251022773 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class PoisonableOne2OneChannelIntImpl implements One2OneChannelInt, ChannelInternalsInt { /** The monitor synchronising reader and writer on this channel */ private Object rwMonitor = new Object (); /** The (invisible-to-users) buffer used to store the data for the channel */ private int hold; /** The synchronisation flag */ private boolean empty = true; /** * This flag indicates that the last transfer went OK. The purpose is to not * throw a PoisonException to the writer side when the last transfer went * OK, but the reader side injected poison before the writer side finished * processing of the last write transfer. */ private boolean done = false; /** * 0 means unpoisoned */ private int poisonStrength = 0; /** * Immunity is passed to the channel-ends, and is not used directly by the channel algorithms */ private int immunity; /** The Alternative class that controls the selection */ private Alternative alt; /** Flag to deal with a spurious wakeup during a write */ private boolean spuriousWakeUp = true; private boolean isPoisoned() { return poisonStrength > 0; } PoisonableOne2OneChannelIntImpl(int _immunity) { immunity = _immunity; } /*************Methods from One2OneChannel******************************/ /** * Returns the AltingChannelInput to use for this channel. * As One2OneChannelImpl implements * AltingChannelInput itself, this method simply returns * a reference to the object that it is called on. * * @return the AltingChannelInput object to use for this * channel. */ public AltingChannelInputInt in() { return new AltingChannelInputIntImpl(this,immunity); } /** * Returns the ChannelOutput object to use for this channel. * As One2OneChannelImpl implements * ChannelOutput itself, this method simply returns * a reference to the object that it is called on. * * @return the ChannelOutput object to use for this * channel. */ public ChannelOutputInt out() { return new ChannelOutputIntImpl(this,immunity); } /*************Methods from ChannelOutput*******************************/ /** * Writes an Object to the channel. * * @param value the object to write to the channel. */ public void write(int value) { synchronized (rwMonitor) { if (isPoisoned()) { throw new PoisonException(poisonStrength); } hold = value; if (empty) { empty = false; if (alt != null) { alt.schedule(); } } else { empty = true; rwMonitor.notify(); } try { rwMonitor.wait(); while (spuriousWakeUp && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record(SpuriousLog.One2OneChannelWrite); } rwMonitor.wait(); } spuriousWakeUp = true; } catch (InterruptedException e) { throw new ProcessInterruptedException( "*** Thrown from One2OneChannel.write (Object)\n" + e.toString()); } if (done) { done = false; } else if (isPoisoned()) { throw new PoisonException(poisonStrength); } else { done = true; } } } /** ***********Methods from AltingChannelInput************************* */ /** * Reads an Object from the channel. * * @return the object read from the channel. */ public int read () { synchronized (rwMonitor) { if (isPoisoned()) { throw new PoisonException(poisonStrength); } if (empty) { empty = false; try { rwMonitor.wait (); while (!empty && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from One2OneChannel.read ()\n" + e.toString ()); } } else { empty = true; } spuriousWakeUp = false; if (isPoisoned()) { throw new PoisonException(poisonStrength); } else { done = true; rwMonitor.notify(); return hold; } } } public int startRead() { synchronized (rwMonitor) { if (isPoisoned()) { throw new PoisonException(poisonStrength); } if (empty) { empty = false; try { rwMonitor.wait (); while (!empty && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from One2OneChannel.read ()\n" + e.toString ()); } } else { empty = true; } if (isPoisoned()) { throw new PoisonException(poisonStrength); } return hold; } } public void endRead() { synchronized (rwMonitor) { spuriousWakeUp = false; rwMonitor.notify (); } } /** * turns on Alternative selection for the channel. Returns true if the * channel has data that can be read immediately. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class which will control the selection * @return true if the channel has data that can be read, else false */ public boolean readerEnable (Alternative alt) { synchronized (rwMonitor) { if (isPoisoned()) { return true; } if (empty) { this.alt = alt; return false; } else { return true; } } } /** * turns off Alternative selection for the channel. Returns true if the * channel contained data that can be read. *

* Note: this method should only be called by the Alternative class * * @return true if the channel has data that can be read, else false */ public boolean readerDisable () { synchronized (rwMonitor) { alt = null; return !empty || isPoisoned(); } } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. *

* This method is provided for convenience. Its functionality can be provided * by Pri Alting the channel against a SKIP guard, although * at greater run-time and syntactic cost. For example, the following code * fragment: *

	   *   if (c.pending ()) {
	   *     Object x = c.read ();
	   *     ...  do something with x
	   *   } else (
	   *     ...  do something else
	   *   }
	   * 
* is equivalent to: *
	   *   if (c_pending.priSelect () == 0) {
	   *     Object x = c.read ();
	   *     ...  do something with x
	   *   } else (
	   *     ...  do something else
	   * }
	   * 
* where earlier would have had to have been declared: *
	   * final Alternative c_pending =
	   *   new Alternative (new Guard[] {c, new Skip ()});
	   * 
* * @return state of the channel. */ public boolean readerPending () { synchronized (rwMonitor) { return !empty || isPoisoned(); } } public void writerPoison(int strength) { if (strength > 0) { synchronized (rwMonitor) { this.poisonStrength = strength; rwMonitor.notifyAll(); if (null != alt) { alt.schedule(); } } } } public void readerPoison(int strength) { if (strength > 0) { synchronized (rwMonitor) { this.poisonStrength = strength; rwMonitor.notifyAll(); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelInternalsInt.java0000644000000000000000000000472611113671251020640 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; interface ChannelInternalsInt { public int read(); public void write(int obj); public int startRead(); public void endRead(); public boolean readerEnable(Alternative alt); public boolean readerDisable(); public boolean readerPending(); /*//For Symmetric channel, later: public boolean writerEnable(Alternative alt); public boolean writerDisable(); public boolean writerPending(); */ public void readerPoison(int strength); public void writerPoison(int strength); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedChannelOutputInt.java0000644000000000000000000000474211113671251021326 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is the same as {@link ChannelOutputInt} except that it is guaranteed * safe to pass on to more than one internal process for parallel writing. *

* A writing-end, obtained from an any-one or any-any * channel by invoking its in() method, will implement this interface. * * @author Quickstone Technologies Limited */ public interface SharedChannelOutputInt extends ChannelOutputInt { } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelInputIntImpl.java0000644000000000000000000000476011113671251020620 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class ChannelInputIntImpl implements ChannelInputInt { private ChannelInternalsInt channel; private int immunity; ChannelInputIntImpl(ChannelInternalsInt _channel, int _immunity) { channel = _channel; immunity = _immunity; } public void endRead() { channel.endRead(); } public int read() { return channel.read(); } public int startRead() { return channel.startRead(); } public void poison(int strength) { if (strength > immunity) { channel.readerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/CSTimer.java0000644000000000000000000002232111105701167016233 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is a {@link Guard} for setting timeouts in an {@link Alternative}. *

Description

* CSTimer is a {@link Guard} for setting timeouts in an * {@link Alternative}. It also provides the current system time * and can set straight (i.e. committed) timeouts. The timeouts * are in terms of absolute time values - not relative delays. *

* Note: for those familiar with the occam multiprocessing * language, CSTimer gives the semantics of the * TIMER type (including its use as a guard in an * ALT construct). *

* Warning: a CSTimer records the timeout value for use by an * {@link Alternative}. Therefore, different CSTimers * must be used by different processes - the same CSTimer * must not be shared. *

* Implementation note: all CSTimers currently * use the same System.currentTimeMillis time. *

*

Examples

* The use of a CSTimer for setting timeouts on channel input is documented * in the {@link Alternative} class (see the examples * A Fair Multiplexor with a Timeout * and A Simple Traffic Flow Regulator). *

* Here, we just show its use for setting committed timeouts. Regular * generates a regular stream of output on its out channel. The rate * of output is determined by its interval parameter. Recall that timeouts * implemented by CSTimer are in terms of absolute time values. * Notice that the sequence of output times maintains * an arithmetic progression. Any delays in completing each cycle (e.g. caused by * the process scheduler or the lateness of the process synchronising with us to accept * our data) will be compensated for automatically - the output sequence always returns * to its planned schedule whenever it can. *

 * import org.jcsp.lang.*;
 *  
 * public class Regular implements CSProcess {
 *  
 *   final private ChannelOutput out;
 *   final private Integer N;
 *   final private long interval;
 *  
 *   public Regular (final ChannelOutput out, final int n, final long interval) {
 *     this.out = out;
 *     this.N = new Integer (n);
 *     this.interval = interval;
 *   }
 *  
 *   public void run () {
 *  
 *     final CSTimer tim = new CSTimer ();
 *     long timeout = tim.read ();       // read the (absolute) time once only
 *  
 *     while (true) {
 *       out.write (N);
 *       timeout += interval;            // set the next (absolute) timeout
 *       tim.after (timeout);            // wait until that (absolute) timeout
 *     }
 *   }
 *  
 * }
 * 
* * For convenience, a {@link #sleep sleep} method that blocks for a specified * time period (in milliseconds) is also provided. This has the same semantics as * {@link java.lang.Thread#sleep(long) java.lang.Thread.sleep}. * [Note: programming a regular sequence of events is a little easier using * {@link #after after} (as in the above) rather than {@link #sleep sleep}.] * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.Guard * * @author P.D. Austin * @author P.H. Welch */ public class CSTimer extends Guard { /** * The absolute timeout value set for the Alternative. * * If this is used without setAlarm(msecs) ever having been invoked, * the wake-up call is set at time zero, which will always be in * the past. So, the Alternative will see the timeout * as having occurred. * */ private long msecs = 0; /** * Sets the absolute timeout value that will trigger an Alternative * select operation (when this CSTimer is one of the guards * with which that Alternative was constructed). * * @param msecs the absolute timeout value. */ public void setAlarm(final long msecs) { this.msecs = msecs; } /** * Returns the alarm value that has been set by the previous call to * {@link #setAlarm(long)}. */ public long getAlarm() { return msecs; } /** * Sets the absolute timeout value that will trigger an Alternative * select operation (when this CSTimer is one of the guards * with which that Alternative was constructed). * * @param msecs the absolute timeout value. * * @deprecated Use {@link #setAlarm(long)} - this name caused confusion with * the idea of setting the current time (a concept that is not supported). */ public void set(final long msecs) { this.msecs = msecs; } /** * Returns the current system time in msecs. * * @return the current system time in msecs */ public long read() { return System.currentTimeMillis(); } /** * Puts the process to sleep until an absolute time is reached. * * @param msecs the absolute time awaited. Note: if this time has already been reached, this returns straight away. */ public void after(final long msecs) { final long delay = msecs - System.currentTimeMillis(); if (delay > 0) try { Thread.sleep(delay); } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from CSTimer.after (long)\n" + e.toString()); } } /** * Puts the process to sleep for a specified time (milliseconds). * * @param msecs the length of the sleep period. Note: if this is negative, this returns straight away. */ public void sleep(final long msecs) { if (msecs > 0) try { Thread.sleep(msecs); } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from CSTimer.sleep (long)\n" + e.toString()); } } /** * Enables this guard. * * @param alt the Alternative doing the enabling. */ boolean enable (Alternative alt) { if ((msecs - System.currentTimeMillis ()) <= Spurious.earlyTimeout) { return true; } else { alt.setTimeout (msecs); return false; } } /** * Disables this guard. */ boolean disable () { // final long now = System.currentTimeMillis (); // System.out.println ("*** CSTimer.disable: " + msecs + ", " + now); // return (msecs <= now); return ((msecs - System.currentTimeMillis ()) <= Spurious.earlyTimeout); // WARNING: the above is an insufficient test to see if the timeout // has expired ... since Java wait-with-timeouts sometimes return // early! See the implementation of Alternative for a work-around. } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyCallChannel.java0000644000000000000000000005752211113671251020305 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * This is the super-class for any-to-any interface-specific CALL channels, * safe for use by many clients and many servers. *

* Shortcut to the Constructor and Method Summaries. * *

Description

* Please see {@link One2OneCallChannel} for general information about CALL channels. * Documented here is information specific to this any-any version. * *

Converting a Method Interface into a Variant CALL Channel

* Constructing a any-any CALL channel for a specific interface * follows exactly the same pattern as in the 1-1 case. Of course, it must * extend Any2AnyCallChannel rather than One2OneCallChannel. *

* For example, using the same Foo * interface as before, we derive: *

 * import org.jcsp.lang.*;
 * 
 * public class Any2AnyFooChannel extends Any2AnyCallChannel implements Foo {
 * 
 *   ...  same body as One2OneFooChannel
 * 
 * }
 * 
* *

Calling a CALL Channel

* All the client needs to see is the method interface * implemented by the CALL channel. So far as the client is concerned, therefore, * there is no difference between any of the varieties of CALL channel * - it just makes the call. * *

Accepting a CALL Channel

* The mechanics of accepting a CALL channel are the same for all varieties. * However, the server should declare which kind (or kinds) it allows * to be attached: *
 * import org.jcsp.lang.*;
 * 
 * class B implements CSProcess, Foo {
 * 
 *   private final ChannelAccept in;
 * 
 *   public B (final One2OneFooChannel in) {         // original constructor
 *     this.in = in;
 *   }
 * 
 *   public B (final Any2AnyFooChannel in) {       // additional constructor
 *     this.in = in;
 *   }
 * 
 *   ...  rest as before
 * 
 * }
 * 
* When wrapping the above to hide its raw method interface, don't forget to include * the extra constructor(s): *
 * import org.jcsp.lang.*;
 * 
 * public class B2 implements CSProcess {            // no Foo interface
 * 
 *   private final B b;
 * 
 *   public B2 (final One2OneFooChannel in) {        // original constructor
 *     b = new B (in);
 *   }
 * 
 *   public B2 (final Any2AnyFooChannel in) {      // additional constructor
 *     b = new B (in);
 *   }
 * 
 *   public void run () {
 *     b.run ();
 *   }
 * 
 * }
 * 
* *

ALTing on a CALL Channel

* As for ordinary channels, ALTing over 1-any or any-any versions * is not supported. Hence, a server can only choose to {@link #accept accept} * or not to accept a Any2AnyFooChannel - it cannot back off because * of some other event. * *

Building a CALL Channel Network

* Network building with CALL channels is the same as building with ordinary * channels. First construct the channels and, then, construct the processes * - plugging in the channels as required and running them in {@link Parallel}. *

* For example, the network consisting of several clients and several servers: *

* where A is unchanged from its definition * in
One2OneCallChannel, * is implemented by: *
 *     Any2AnyFooChannel c = new Any2AnyFooChannel ();
 * 
 *     final A[] aClients = new A[n_aClients];
 *     for (int i = 0; i < aClients.length; i++) {
 *       aClients[i] = new A (c);
 *     }
 * 
 *     final B2[] bServers = new B2[n_bClients];
 *     for (int i = 0; i < bServers.length; i++) {
 *       bServers[i] = new B2 (c);
 *     }
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Parallel (aClients),
 *         new Parallel (bServers)
 *       }
 *     ).run ();
 * 
* The clients compete with each other to find a server and the servers * compete with each other to find a client. A client must not care which * server it gets and vice-versa. The any-any CALL channel strictly * serialises client-server transactions - only one at a time can actually take place. * *

* It is a good idea, therefore, to restrict the duration of the CALL to as short a period * as possible, so that other clients and servers are not unnecessarilly delayed. * For instance, the any-any CALL can be used just to enable a client and server * find one another. During the CALL, the client could give the server * a private direct line (e.g. a 1-1 CALL channel) on which it promises to call back * after hanging up on the shared one. The server could reply with special * information (such as how long it is prepared to wait for that call back). In this way, * multiple client-server transactions could proceed concurrently. An example is * given below. * *

Example

* This further develops the CALL channel version of * the Wot-no-Chickens example, introduced in Any2OneCallChannel. *

* The college authorities have decided to charge its philosophers for all the chickens they are * consuming. Unfortunately, getting the canteen to collect money from the customers would mean * that its serviceTime would have to be increased from its present zero to one second. * Since the canteen can only do one thing at a time, a new form of delay would be introduced into * the system. Since the philosophers only think for a maximum of three seconds in between * trying to eat, having them wait around (possibly for several seconds) while their colleagues * make their purchases is deemed unacceptable. *

* The college has decided, therefore, to make some new investments. Students are to be employed * to sell the chickens from the canteen. Each student is equipped with a hot-plate on which can * be (indefinitely) stored one hot chicken, straight from the canteen. The student can get a chicken * from the canteen (if the canteen has some available) still with the same zero serviceTime * as before - the canteen has not changed. Students that have chickens compete with each other * to service any customers. Servicing a customer means collecting some money and giving change, * which takes one second, as well as handing over the chicken. *

* Hungry philosophers compete with each other to find any student who is ready for * a customer. Students and philosophers find each other through a any-any CALL * channel. However, if the full transaction (which includes a delay of one second) were * to take place over that shared channel, the college would be no better off! * The canteen-students system would still only be dealing with one customer at a time. *

* Therefore, the good idea mentioned at the end of * the previous section is employed to enable student-philosopher transactions to proceed * in parallel. The any-any shared channel is used only for a philosopher * to pass over a private direct 1-1 line to a student and to exchange names * (out of politeness). The bulk of all transactions takes place in parallel * over unshared lines. *

* Here is the fixed part of the network diagram for the new college. The 1-1 * channels for private communication between a philosopher (Prof) and * a student (Student) are dynamically connected, continually changing and, * therefore, not shown: *

* For this new system, the Canteen, * Chef and * Clock processes are unchanged. * The philosophers' behaviour has changed as described above and, so, we have chosen a new name for * their class - Prof. But first, we describe the new player on the block - * the Student. * *

The Student

* Each student process is a server on its studentService channel and * a client on its canteenService. * As with the Canteen server, * we have chosen to define the Student service interface and associated CALL * channel class as inner declarations: *
 * import org.jcsp.lang.*;
 * 
 * class Student implements CSProcess {
 * 
 *   public static interface Service {
 *     public String hello (String profId,
 *            Canteen.One2OneServiceChannel service);
 *   }
 * 
 *   public static class Any2AnyServiceChannel
 *    extends Any2AnyCallChannel implements Service {
 *     public String hello (String profId,
 *            Canteen.One2OneServiceChannel service) {
 *       join ();
 *       String n = ((Service) server).hello (profId, service);
 *       fork ();
 *       return n;
 *     }
 *   }
 * 
* Note that the hello CALL offers the caller's name and private 1-1 channel. * These will be saved and the student's name returned when the student accepts the CALL. * Notice also that that private channel instances the 1-1 Service channel * exported by the Canteen. * This is not surprising since the student, who will accept the CALL on that line, will be * acting on behalf of the canteen - one of many proxies set up by the college to reduce * the service bottleneck caused by the newly introduced charges. *

* Following the same pattern as for the Canteen, we next set up the constructor * and the local fields for saving its parameters: *

 *   private final String id;
 *   private final ChannelAccept studentService;
 *   // provide service on this line
 *   private final Canteen.Service canteenService;
 *   // act as a client on this line
 *   private final int serviceTime;
 * 
 *   public Student (String id, Any2AnyServiceChannel studentService,
 *                   Canteen.Service canteenService, int serviceTime) {
 *     this.id = id;
 *     this.studentService = studentService;
 *     this.canteenService = canteenService;
 *     this.serviceTime = serviceTime;
 *   }
 * 
* Now, we need to combine the exported interfaces into a single one so that the inner process * can be created (anonymously) by this wrapper's run method: *
 *   private interface inner extends CSProcess, Service, Canteen.Service {};
 * 
 *   public void run () {
 * 
 *     new inner () {
 * 
 *       private AltingChannelAccept service;
 *       // place holder for the private line
 *       private int nServed = 0;
 * 
 *       private final CSTimer tim = new CSTimer ();
 * 
* Impementations of the required CALL interfaces (including the one for the channel * privately supplied) come next: *
 *       public String hello (String profId,
 *              Canteen.One2OneServiceChannel service) {
 *         this.service = service;
 *         System.out.println ("   Student " + id + " -> Prof " +
 *                             profId + " : hello ... ");
 *         return id;
 *       }
 * 
 *       public int takeChicken (String profId) {
 *         System.out.println ("   Student " + id + " -> Prof +"
 *                             profId + " : that'll be 1-95 please ... ");
 *         tim.sleep (serviceTime);          // take the money and give any change
 *         nServed++;
 *         System.out.println ("   Student " + id + " -> Prof "
 *                             + profId + " : thank you - have a nice day ["
 *                             + nServed + " served]");
 *         return 1;
 *       }
 * 
* and the run method that conducts everything: *
 *       public void run () {
 *         System.out.println ("   Student " + id + " : starting ... ");
 *         while (true) {
 *           canteenService.takeChicken (id);
 *           // make a client CALL on the canteen
 *           System.out.println ("   Student " + id +
 *                               " : got chicken ... ready to serve ...");
 *           studentService.accept (this);     // customer makes contact
 *           service.accept (this);            // deal with customer
 *         }
 *       }
 * 
* Finally, don't forget to run this inner process: *
 *     }.run ();
 *   }
 * }
 * 
* *

The Professor

* Professors behave in pretty much the same way as * philosophers. * The only difference is that they communicate with * the student proxies, rather than directly with * the canteen. For this, * each needs to keep a private channel up its sleeve: *
 * import org.jcsp.lang.*;
 * 
 * class Prof implements CSProcess {
 * 
 *   private final String id;
 *   private final Student.Service studentService;
 *   private final int thinkTime;
 *   private final int eatTime;
 *   private final boolean greedy;
 * 
 *   public Prof (String id, Student.Service studentService,
 *                int thinkTime, int eatTime, boolean greedy) {
 *     this.id = id;
 *     this.studentService = studentService;
 *     this.thinkTime = thinkTime;
 *     this.eatTime = eatTime;
 *     this.greedy = greedy;
 *   }
 * 
 *   public void run () {
 *     final CSTimer tim = new CSTimer ();
 *     final Canteen.One2OneServiceChannel service =
 *           new Canteen.One2OneServiceChannel ();
 *     // This is the private channel for
 *     // direct communication with a student
 *     int nEaten = 0;
 *     while (true) {
 *       if (! greedy) {
 *         System.out.println ("   Prof " + id + " : thinking ...");
 *         tim.sleep (thinkTime);  // thinking
 *       }
 *       System.out.println ("   Prof " + id + " : gotta eat ...");
 *       String student = studentService.hello (id, service);
 *                        // find a student
 *       System.out.println ("   Prof " + id + " -> Student "
 *                            + student +
 *                            " : hi, can I have a chicken please?");
 *       int chicken = service.takeChicken (id);
 *                     // and pay up ...
 *       nEaten++;
 *       System.out.println ("   Prof " + id +
 *                           " : mmm ... that's good [" +
 *                           nEaten + " so far]");
 *       tim.sleep (eatTime);      // eating
 *     }
 *   }
 * 
 * }
 * 
* *

The New College

* The new charges slow down the speed with which the professors can get their chickens * (although not their eating of them). Most affected are the greedy ones who can * no longer consume at a rate approaching 10 per second (whilst supplies hold out) but * now have to wait a whole second simply to make a purchase. Bill, therefore, * should not get quite so sick. Notice that, so long as supplies hold out and there * are enough students, philosophers are not delayed by each other - their purchases * will be made in parallel. *

* For convenience, the college network diagram is reproduced here - naming some more * of the characters. The new college seems to have attracted some good students: *

* Here is the code: *
 * import org.jcsp.lang.*;
 * 
 * class NewCollege implements CSProcess {
 * 
 *   public void run () {
 * 
 *     final String[] profId = {"Bill", "Hilary", "Gennifer",
 *                              "Paula", "Monica"};
 *     final String[] studentId = {"Occam", "Babbage",
 *                                 "Einstein", "Turing"};
 * 
 *     final int thinkTime = 3000;             // 3 seconds
 *     final int eatTime = 100;                // 100 milliseconds
 * 
 *     final int studentServiceTime = 1000;    // 1 second
 * 
 *     final int canteenServiceTime = 0;       // 0 seconds
 *     final int canteenSupplyTime = 3000;     // 3 seconds
 *     final int maxChickens = 50;
 * 
 *     final Student.Any2AnyServiceChannel studentService
 *       = new Student.Any2AnyServiceChannel ();
 *     final Canteen.Any2OneServiceChannel canteenService
 *       = new Canteen.Any2OneServiceChannel ();
 *     final Canteen.Any2OneSupplyChannel supply
 *       = new Canteen.Any2OneSupplyChannel ();
 * 
 *     final Student[] students = new Student[studentId.length];
 *     for (int i = 0; i < students.length; i++) {
 *       students[i] = new Student (studentId[i], studentService,
 *                                  canteenService, studentServiceTime);
 *     }
 * 
 *     final Prof[] profs = new Prof[profId.length];
 *     for (int i = 0; i < profs.length; i++) {
 *       profs[i] = new Prof (profId[i], studentService,
 *                            thinkTime, eatTime, i == 0);
 *     }
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Clock (),
 *         new Canteen (canteenService, supply,
 *                      canteenServiceTime, canteenSupplyTime, maxChickens),
 *         new Parallel (students),
 *         new Parallel (profs),
 *         new Chef ("Pierre", 4, 2000, supply),
 *         // chefId, batchSize, batchTime
 *         new Chef ("Henri", 10, 20000, supply),
 *         new Chef ("Sid", 100, 150000, supply)
 *       }
 *     ).run ();
 * 
 *   }
 *   public static void main (String argv[]) {
 *     new NewCollege ().run ();
 *   }
 * }
 * 
* * @see org.jcsp.lang.One2OneCallChannel * @see org.jcsp.lang.Any2OneCallChannel * @see org.jcsp.lang.One2AnyCallChannel * @see org.jcsp.lang.Alternative * * @author P.H. Welch */ public abstract class Any2AnyCallChannel implements ChannelAccept, Serializable { /** * This is used to synchronise the calling and accepting process. */ final private Any2OneChannelImpl c = new Any2OneChannelImpl(); /** * This is used to synchronise the calling and accepting process. */ final private One2OneChannelImpl d = new One2OneChannelImpl(); /** * This holds a reference to a server process so that a client may * make the call. The reference is only valid between the {@link #join join} * and {@link #fork fork} elements of the standard *
calling sequence. * As shown in that sequence, it will need casting up to the relevant interface * supported by the specific CALL channel derived from this class. */ protected CSProcess server; /** * This may be set during the standard * calling sequence to record * which method was invoked by a client. It is only safe to do this between * the {@link #join join} and {@link #fork fork} elements of * that sequence. Either all the CALL * channel methods should do this or none - in the latter case, its default * value remains as zero. Its value is returned to a server as the result * the server's invocation of {@link #accept accept}. */ protected int selected = 0; /** * This is invoked by a server when it commits to accepting a CALL * from a client. The parameter supplied must be a reference to this server * - see the example from {@link One2OneCallChannel}. * It will not complete until a CALL has been made. If the derived CALL channel has set * the {@link #selected} field in the way defined by the standard * calling sequence, * the value returned by this method will indicate which method was called. * * @param server the server process receiving the CALL. */ public synchronized int accept(CSProcess server) { this.server = server; c.read(); // ready to ACCEPT the CALL d.read(); // wait until the CALL is complete return selected; } /** * This is invoked by a client during the standard * calling * sequence. It will not complete until a server invokes * an {@link #accept accept} on this channel. In turn, that accept * will not complete until the client invokes a {@link #fork fork}, * after having made its CALL on the server. */ protected void join() { c.write(null); } /** * This is invoked by a client during the standard * calling * sequence. A server must have invoked an {@link #accept accept} * for the client to have got this far in the sequence - see * the {@link #join join}. This call unblocks that accept, * releasing the server and client to resume separate lives. */ protected void fork() { d.write(null); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyIntImpl.java0000644000000000000000000000707111113671251017507 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class Any2AnyIntImpl implements Any2AnyChannelInt, ChannelInternalsInt { private ChannelInternalsInt channel; /** The mutex on which readers must synchronize */ private final Mutex readMutex = new Mutex(); private final Object writeMonitor = new Object(); Any2AnyIntImpl(ChannelInternalsInt _channel) { channel = _channel; } public SharedChannelInputInt in() { return new SharedChannelInputIntImpl(this,0); } public SharedChannelOutputInt out() { return new SharedChannelOutputIntImpl(this,0); } public void endRead() { channel.endRead(); readMutex.release(); } public int read() { readMutex.claim(); // A poison exception might be thrown, hence the try/finally: try { return channel.read(); } finally { readMutex.release(); } } //begin never used: public boolean readerDisable() { return false; } public boolean readerEnable(Alternative alt) { return false; } public boolean readerPending() { return false; } //end never used public void readerPoison(int strength) { readMutex.claim(); channel.readerPoison(strength); readMutex.release(); } public int startRead() { readMutex.claim(); try { return channel.startRead(); } catch (RuntimeException e) { channel.endRead(); readMutex.release(); throw e; } } public void write(int n) { synchronized (writeMonitor) { channel.write(n); } } public void writerPoison(int strength) { synchronized (writeMonitor) { channel.writerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableBufferedOne2AnyChannelInt.java0000644000000000000000000000435111113671251023625 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.ChannelDataStoreInt; class PoisonableBufferedOne2AnyChannelInt extends One2AnyIntImpl { PoisonableBufferedOne2AnyChannelInt(ChannelDataStoreInt _data, int _immunity) { super(new PoisonableBufferedOne2OneChannelInt(_data,_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2AnyChannelInt.java0000644000000000000000000001363111113671251020155 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines an interface for an any-to-any integer channel, * safe for use by many writers and many readers. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Channels may be {@link Channel#any2anyInt() synchronising}, * {@link Channel#any2anyInt(org.jcsp.util.ints.ChannelDataStoreInt) buffered}, * {@link Channel#any2anyInt(int) poisonable} * or {@link Channel#any2anyInt(org.jcsp.util.ints.ChannelDataStoreInt,int) both} * (i.e. buffered and poisonable). *

*

Description

* Any2AnyChannelInt is an interface for a channel which * is safe for use by many reading and writing processes. Reading processes * compete with each other to use the channel. Writing processes compete * with each other to use the channel. Only one reader and one writer will * actually be using the channel at any one time. This is managed by the * channel – user processes just read from or write to it. *

*

* Please note that this is a safely shared channel and not * a broadcaster or message gatherer. Currently, broadcasting or gathering has to be managed by * writing active processes (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example of broadcasting). *

*

* All reading processes and writing processes commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

*

* The default semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. A reading process must wait * for a matching writer and vice-versa. *

*

* The static methods of {@link Channel} construct channels with * either the default semantics or with buffering to user-specified capacity * and a range of blocking/overwriting policies. * Various buffering plugins are given in the org.jcsp.util package, but * careful users may write their own. *

*

* The {@link Channel} methods also provide for the construction of * {@link Poisonable} channels and for arrays of channels. * *

Implementation Note and Caution

* Fair servicing of readers and writers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * any-any channels. * * @see org.jcsp.lang.Channel * @see org.jcsp.lang.One2OneChannelInt * @see org.jcsp.lang.Any2OneChannelInt * @see org.jcsp.lang.One2AnyChannelInt * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin and P.H. Welch */ public interface Any2AnyChannelInt { /** * Returns the input channel end. */ public SharedChannelInputInt in(); /** * Returns the output channel end. */ public SharedChannelOutputInt out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Barrier.java0000644000000000000000000005650411113671251016324 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * This enables barrier synchronisation between a set of processes. *

* Shortcut to the Constructor and Method Summaries. * *

Description

* A channel is a CSP event in which only two processes (the reader and * the writer) synchronise. A barrier is a CSP event in which any number of * processes may synchronise. Any process synchronising on a barrier will be * blocked until all processes associated with that barrier have synchronised. * A process may not back off an attempted synchronisation - i.e. barriers cannot be * used as guards in an {@link Alternative}. * Applications needing that capability should use an {@link AltingBarrier}. *

* A process network may contain many barriers - each being associated with a different * subset of processes. These subsets may overlap and change at run-time. JCSP does not * currently provide a checked way of associating a process with a particular barrier. * That could be done, but would carry a syntactic and run-time overhead currently not * thought worthwhile. Associating a barrier with its correct set of processes is * a design issue and it is left to the designer to ensure correct useage. *

* Note: this notion of barrier corresponds to the * BARRIER * synchronisation primitive added to the * KRoC * occam-pi language system. * *

Deterministic Barriers

* If the set of processes associated with a barrier remains fixed, barrier synchronisation * introduces no non-determinism. So, a parallel system made up of processes, * barriers (with fixed barrier sets) and 1-1 channels (with no ALTing on the channels and * an exclusive read/write access discipline for all communicated objects) is deterministic * - its semantics are independent of scheduling. *

* For fixed barrier sets, {@link #Barrier(int) construct} each barrier initialised * to the number of processes to be associated with it and share it out amongst those processes. *

* For example, here is a fixed set of 10 processes synchronising on a shared barrier: *

* Here is the JCSP code for this network: *
 * import org.jcsp.lang.*;
 * 
 * public class BarrierExample1 {
 * 
 *   public static void main (String[] args) {
 * 
 *     final int nPlayers = 10;
 * 
 *     final Barrier barrier = new Barrier (nPlayers);
 * 
 *     final Player[] players = new Player[nPlayers];
 *     for (int i = 0; i < players.length; i++) {
 *       players[i] = new Player (i, nPlayers, barrier);
 *     }
 * 
 *     new Parallel (players).run ();
 * 
 *   }
 * 
 * }
 * 
* To synchronise on a barrier, a process just needs to invoke its {@link #sync sync} * method. For example: *
 * import org.jcsp.lang.*;
 * 
 * public class Player implements CSProcess {
 * 
 *   private final int id, nPlayers;
 *   private final Barrier barrier;
 * 
 *   public Player (int id, int nPlayers, Barrier barrier) {
 *     this.id = id;
 *     this.nPlayers = nPlayers;
 *     this.barrier = barrier;
 *   }
 * 
 *   public void run () {
 *     final CSTimer tim = new CSTimer ();
 *     final long second = 1000;          // JCSP timer units are milliseconds
 *     int busy = id + 1;
 *     while (true) {
 *       tim.sleep (busy*second);         // application specific work
 *       System.out.println ("Player " + id + " at the barrier ...");
 *       barrier.sync ();
 *       System.out.println ("\t\t\t... Player " + id + " over the barrier");
 *       busy = (nPlayers + 1) - busy;    // just to make it more interesting
 *     }
 *   }
 * 
 * }
 * 
* The sleep period above represents some work carried out by each Player. * This work takes a different amount of time in each cycle and varies from player to player. * At the end of each piece of work, each player waits for all its colleagues before continuing * its next cycle. * *

Non-Deterministic Barriers

* A process may choose at any time to {@link #enroll enroll} or {@link #resign resign} from * any barrier it can see. It should not, of course, enroll on a barrier with which * it is already associated - nor resign from a barrier with which it isn't! Because * these operations are internal choices of individual processes and because they have an impact on * the synchronisation properties of their environment, the resulting system is non-deterministic. * *

* In the above example, Worker processes cycle between working and * resting states, making their own decisions about when to switch. * When working, they enroll in a barrier shared with a TimeKeeper process - * when resting, they resign from this barrier. * Whilst working and after they have enrolled, they execute a sequence of * work units triggered by synchronisations on the barrier. *

* The TimeKeeper synchronises on the barrier at a regular rate (once per second) * and, thus, coordinates the activities of all working Workers. * A work unit can only start at the beginning of one of the TimeKeeper's * time slots and each Worker can only perform one work unit per time slot. * Should any work unit overrun a time slot, subsequent units (for all Workers) * will have a late start. * However, the system is stable - so long as there is some slack in the system * (i.e. units do not generally overrun), the original schedule will be recovered. *

* Here is the code for the complete system. * The barrier is initialised to just 1, since only the TimeKeeper * is permanently associated with it. * The barrier is passed to all Workers as well as to the TimeKeeper: *

 * import org.jcsp.lang.*;
 * 
 * public class BarrierExample2 {
 * 
 *   public static void main (String[] args) {
 * 
 *     final int nWorkers = 10;
 *     final int rogue = 5;
 * 
 *     final int second = 1000;
 *     // JCSP timer units are milliseconds
 *     final int tick = 1*second;
 *     final int maxWork = tick;
 *     // raise this to allow workers to overrun
 * 
 *     final long seed = new CSTimer ().read ();
 * 
 *     final Barrier barrier = new Barrier (1);
 * 
 *     final TimeKeeper timeKeeper = new TimeKeeper (tick, barrier);
 * 
 *     final Worker[] workers = new Worker[nWorkers];
 *     for (int i = 0; i < workers.length; i++) {
 *       workers[i] = new Worker (i, i + seed, maxWork, i == rogue, barrier);
 *     }
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         timeKeeper,
 *         new Parallel (workers)
 *       }
 *     ).run ();
 *   }
 * }
 * 
* As well as the barrier, each Worker is given its id, a (unique) * seed for its random number generator, its maximum work unit time and whether it is * a rogue. A rogue worker deliberately overruns its last unit of work for each * working session to test out the stability of the system: *
 * import org.jcsp.lang.*;
 * import java.util.*;
 * 
 * public class Worker implements CSProcess {
 * 
 *   private final int id;
 *   private final long seed;
 *   private final int maxWork;
 *   private final boolean rogue;
 *   private final Barrier barrier;
 * 
 *   public Worker (int id, long seed, int maxWork,
 *                  boolean rogue, Barrier barrier) {
 *     this.id = id;
 *     this.seed = seed;
 *     this.maxWork = maxWork;
 *     this.rogue = rogue;
 *     this.barrier = barrier;
 *   }
 * 
 *   public void run () {
 * 
 *     final Random random = new Random (seed);
 *     // each process gets a different seed
 * 
 *     final CSTimer tim = new CSTimer ();
 *     final int second = 1000;
 *     // JCSP timer units are milliseconds
 * 
 *     final int minRest = 3*second;
 *     final int maxRest = (id + 10)*second;
 *     final int nWorkUnits = id + 1;
 * 
 *     final String starting = "\tWorker " + id
 *                             + " starting ...";
 *     final String  working = "\t\t\t  ... Worker " + id
 *                             + " working ...";
 *     final String  resting = "\t\t\t\t\t       ... Worker "
 *                             + id + " resting ...";
 * 
 *     while (true) {
 *       barrier.enroll ();
 *       System.out.println (starting);
 *       for (int i = 0; i < nWorkUnits; i++) {
 *         barrier.sync ();
 *         System.out.println (working);
 *         tim.sleep (random.nextInt (maxWork));
 *         //these lines represent one unit of work
 *       }
 *       if (rogue) tim.sleep (maxWork);
 *       // try to throw the timekeeper
 *       barrier.resign ();
 *       System.out.println (resting);
 *       tim.sleep (minRest + random.nextInt (maxRest));
 *     }
 *   }
 * 
 * }
 * 
* Note that the {@link #resign resign} method also performs a (non-blocking) synchronisation * on the barrier as well as the resignation. This is crucial since, if the resigner were * the last process associated with a barrier not to have invoked a {@link #sync sync}, * its resignation must complete the barrier (as though it had invoked a sync) * and release all the remaining associated processes. *

* The TimeKeeper is passed its tick interval and the Barrier. * It is pre-enrolled with the Barrier and remains permanently associated: *

 * import org.jcsp.lang.*;
 * 
 * public class TimeKeeper implements CSProcess {
 * 
 *   private final long interval;
 *   private final Barrier barrier;
 * 
 *   public TimeKeeper (long interval, Barrier barrier) {
 *     this.interval = interval;
 *     this.barrier = barrier;
 *   }
 * 
 *   public void run () {
 * 
 *     final CSTimer tim = new CSTimer ();
 *     long timeout = tim.read () + interval;
 * 
 *     while (true) {
 *       tim.after (timeout);
 *       barrier.sync ();
 *       System.out.println ("[" + (tim.read () - timeout) + "]");
 *       timeout += interval;
 *     }
 *   }
 * 
 * }
 * 
* The print statement from the TimeKeeper gives an upper bound on how far each * timeslot strays from its schedule. JCSP {@link CSTimer CSTimer}s are currently implemented * on top of standard Java APIs (Thread.sleep and Object.wait). * Depending on the underlying JVM, this should stay close to zero (milliseconds) - except * when the rogue Worker deliberately overruns a work unit. * Other events may also disturb the schedule - e.g. a Ctl-S/Ctl-Q from * the user to pause/resume output or some transient fit of activity from * the operating system. Some JVMs also return early from some timeouts - i.e. the timeslot * starts early, which gives rise to an occasional negative report from the TimeKeeper. *

* Bear also in mind that the TimeKeeper's print statement has to compete with * the print statements from all working Workers. All are scheduled to execute * at the start of each timeslot and may be arbitrarilly interleaved. * This may be confusing when interpreting the output from the system. *

* To clarify what's happening, we can arrange for the TimeKeeper's message * to be printed first for each timeslot, before any from the Workers. * To do this, we need to stall those Workers temporarilly until we know that * the TimeKeeper has reported. A simple way to do that is to double up on * the barrier synchronisation. For the Worker, modify its working loop: *

 *   for (int i = 0; i < nWorkUnits; i++) {
 *     barrier.sync ();                     // wait for everyone
 *     barrier.sync ();                     // wait for the Timekeeper to report
 *     System.out.println (working);
 *     tim.sleep (random.nextInt (maxWork));
 *   }
 * 
* For the TimeKeeper, modify its run loop: *
 *   while (true) {
 *     tim.after (timeout);
 *     barrier.sync ();                     // wait for everyone
 *     System.out.println ("[" + (tim.read () - timeout) + "]");
 *     barrier.sync ();                     // let the Workers get going
 *     timeout += interval;
 *   }
 * 
* *

Overheads

* Free use of additional synchronisations to gain special control (such as in the above) * depends on the overheads being not so great as to render that control pointless. *

* Going back to the original example, the entire barrier * synchronisation could be discarded by dropping the TimeKeeper and making each * Worker responsible for its own time schedule. * However, setting n timeouts (where each setting has O(n) overheads) * needs to be compared against setting 1 timeout (by the TimeKeeper) * together with a (n+1)-way barrier synchronisation. *

* For the current implementation, the {@link #enroll enroll} and {@link #resign resign} * operations - together with most of the {@link #sync sync}s - have unit time * costs. The final sync, which releases all the other (n) * processes blocked on the barrier, takes O(n) time. The unit time costs * for this implementation are comparable with those of a synchronized method * invocation followed by an Object.wait. *

* [Note: CSP synchronisation primitives can be implemented with much lighter * overheads. For example, * the KRoC * occam equivalent to this Barrier * (its EVENT) * has (sub-microsecond) unit time costs for all its operations, including * the final sync. Future work on JCSP may look towards this standard.] * * @see org.jcsp.lang.AltingBarrier * @see org.jcsp.lang.Bucket * @see org.jcsp.lang.Alternative * * @author P.H. Welch */ public class Barrier implements Serializable { /** * The number of processes currently enrolled on this barrier. */ private int nEnrolled = 0; /** * The number of processes currently enrolled on this barrier and who have not yet * synchronised in this cycle. */ private int countDown = 0; /** * The monitor lock used for synchronisation. */ private Object barrierLock = new Object (); /** * The even/odd flag used to detect spurious wakeups. */ private boolean evenOddCycle = true; // could be initialised to false ... /** * Construct a barrier initially associated with no processes. */ public Barrier() { } /** * Construct a barrier (initially) associated with nEnrolled processes. * It is the responsibility of the constructing process to pass this * (by constructor or set method) to each process that will be * synchronising on the barrier, before firing up those processes. *

* * @param nEnrolled the number of processes (initially) associated with this barrier. *

* * @throws IllegalArgumentException if nEnrolled < 0. */ public Barrier (final int nEnrolled) { if (nEnrolled < 0) { throw new IllegalArgumentException ( "*** Attempt to set a negative enrollment on a barrier\n" ); } this.nEnrolled = nEnrolled; countDown = nEnrolled; //System.out.println ("Barrier.constructor : " + nEnrolled + ", " + countDown); } /** * Reset this barrier to be associated with nEnrolled processes. * This must only be done at a time when no processes are active on the barrier. * It is the responsibility of the invoking process to pass this barrier * (by constructor or set method) to each process that will be * synchronising on the barrier, before firing up those processes. *

* * @param nEnrolled the number of processes reset to this barrier. *

* * @throws IllegalArgumentException if nEnrolled < 0. */ public void reset (final int nEnrolled) { if (nEnrolled < 0) { throw new IllegalArgumentException ( "*** Attempt to set a negative enrollment on a barrier\n" ); } synchronized (barrierLock) { this.nEnrolled = nEnrolled; countDown = nEnrolled; } //System.out.println ("Barrier.reset : " + nEnrolled + ", " + countDown); } /** * Synchronise the invoking process on this barrier. * Any process synchronising on this barrier will be blocked until all * processes associated with the barrier have synchronised (or resigned). */ public void sync () { synchronized (barrierLock) { countDown--; //System.out.println ("Barrier.sync : " + nEnrolled + ", " + countDown); if (countDown > 0) { try { boolean spuriousCycle = evenOddCycle; barrierLock.wait (); while (spuriousCycle == evenOddCycle) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.BarrierSync); } barrierLock.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from Barrier.sync ()\n" + e.toString () ); } } else { countDown = nEnrolled; evenOddCycle = !evenOddCycle; // to detect spurious wakeups :( //System.out.println ("Barrier.sync : " + nEnrolled + ", " + countDown); barrierLock.notifyAll (); } } } /** * A process may enroll only if it is resigned. * A re-enrolled process may resume offering to synchronise on this barrier * (until a subsequent {@link #resign resign}). * Other processes cannot complete the barrier (represented by this front-end) * without participation by the re-enrolled process. *

* Note: timing re-enrollment on a barrier usually needs some care. * If the barrier is being used for synchronising phases of execution between * a set of processes, it is crucial that re-enrollment occurs in * an appropriate (not arbitrary) phase. * If the trigger for re-enrollment comes from another enrolled process, * that process should be in such an appropriate phase. * The resigned process should re-enroll and, then, acknowledge the trigger. * The triggering process should wait for that acknowledgement. * If the decision to re-enroll is internal (e.g. following a timeout), * a buddy process, enrolled on the barrier, should be asked to provide * that trigger when in an appropriate phase. * The buddy process, perhaps specially built just for this purpose, polls * a service channel for that question when in that phase. *

*

* Warning: the rule in the first sentence above is * the responsibility of the designer -- it is not checked by * implementation. * If not honoured, things will go wrong. */ public void enroll () { synchronized (barrierLock) { nEnrolled++; countDown++; } //System.out.println ("Barrier.enroll : " + nEnrolled + ", " + countDown); } /** * A process may resign only if it is enrolled. * A resigned process may not offer to synchronise on this barrier * (until a subsequent {@link #enroll enroll}). * Other processes can complete the barrier (represented by this front-end) * without participation by the resigned process. *

* Unless all processes synchronising on this barrier terminate in * the same phase, it is usually appropriate for a terminating process * to resign first. Otherwise, its sibling processes will never be * able to complete another synchronisation. *

*

* Warning: the rules in the first two sentences above are * the responsibility of the designer -- they are not checked by * implementation. * If not honoured, things will go wrong. *

*

* * @throws BarrierError if not enrolled (but this is not always detected). * */ public void resign () { synchronized (barrierLock) { nEnrolled--; countDown--; //System.out.println ("Barrier.resign : " + nEnrolled + ", " + countDown); if (countDown == 0) { countDown = nEnrolled; evenOddCycle = !evenOddCycle; // to detect spurious wakeups :( //System.out.println ("Barrier.resign : " + nEnrolled + ", " + countDown); barrierLock.notifyAll (); } else if (countDown < 0) { throw new BarrierError ( "*** A process has resigned on a barrier without first enrolling\n" ); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelOutputIntImpl.java0000644000000000000000000000461111113671251021014 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class ChannelOutputIntImpl implements ChannelOutputInt { private ChannelInternalsInt channel; private int immunity; ChannelOutputIntImpl(ChannelInternalsInt _channel, int _immunity) { channel = _channel; immunity = _immunity; } public void write(int object) { channel.write(object); } public void poison(int strength) { if (strength > immunity) { channel.writerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Mutex.java0000644000000000000000000000520411113671251016027 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * A package-visible class that implements a straightforward mutex, for use by * One2AnyChannel and Any2AnyChannel * * @author N.C.C. Brown * */ class Mutex { private boolean claimed = false; public void claim() { synchronized (this) { while (claimed) { try { wait(); } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from Mutex.claim()\n" + e.toString () ); } } claimed = true; } } public void release() { synchronized (this) { claimed = false; notify(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelInputSymmetricImpl.java0000644000000000000000000000524011105701167023174 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; class AltingChannelInputSymmetricImpl extends AltingChannelInput implements MultiwaySynchronisation { private final AltingBarrier ab; private final ChannelInput in; private boolean syncDone = false; public AltingChannelInputSymmetricImpl ( AltingBarrier ab, ChannelInput in) { this.ab = ab; this.in = in; } boolean enable (Alternative alt) { syncDone = ab.enable (alt); return syncDone; } boolean disable () { syncDone = ab.disable (); return syncDone; } public Object read () { if (!syncDone) ab.sync (); syncDone = false; return in.read (); } public boolean pending () { syncDone = ab.poll (10); return syncDone; } public void poison(int strength) { in.poison(strength); } public void endRead() { in.endRead(); } public Object startRead() { if (!syncDone) ab.sync(); syncDone = false; return in.read(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/JCSP_InternalError.java0000644000000000000000000000427111105701167020336 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This is thrown by an inconsistency detected in the internal structures of JCSP. * *

Description

* Please report the circumstances to jcsp-team@kent.ac.uk - thanks! * * @author P.H. Welch */ //}}} public class JCSP_InternalError extends Error { public JCSP_InternalError (String s) { super ( s + "\n*** Please report the circumstances to jcsp-team@kent.ac.uk - thanks!" ); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionClientOpenMessage.java0000644000000000000000000000430111105701167022310 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * @author Quickstone Technologies Limited */ class ConnectionClientOpenMessage extends ConnectionClientMessage { ChannelOutput replyChannel; } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelInt.java0000644000000000000000000004121411105701167016752 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.ChannelDataStoreInt; /** * This class provides static factory methods for constructing * various different types of int channel objects. There are also methods * for constructing arrays of identical int channels. * * The current implementation constructs "safe" channels which have separate * delegate objects for their read and write ends. This stops a * ChannelInputInt from being cast into a ChannelOutputInt * object. The SafeChannelIntFactory class is used to construct the * channels. * * Non-safe channels can be constructed by using an instance of the * StandardChannelIntFactory class. The channels produced by this * factory have read and write ends implemented by the same object. This is * is more efficient (there are two extra objects and delegate method calls) * but could lead to errors if users make incorrect casts. * * @deprecated To create integer channels, use the methods in the Channel class. * * @author Quickstone Technologies Limited */ public class ChannelInt { /** * Private constructor to stop users from instantiating this class. */ private ChannelInt() { //this class should not be instantiated } /** * The factory to be used by this class. The class should implement * ChannelIntFactory, ChannelIntArrayFactory, BufferedChannelIntFactory and BufferedChannelIntArrayFactory. */ private static final StandardChannelIntFactory factory = new StandardChannelIntFactory(); /* Methods that are the same as the Factory Methods */ /** * Constructs and returns a One2OneChannelInt object. * * @return the channel object. * * @see org.jcsp.lang.ChannelIntFactory#createOne2One() */ public static One2OneChannelInt createOne2One() { return factory.createOne2One(); } /** * Constructs and returns an Any2OneChannelInt object. * * @return the channel object. * * @see org.jcsp.lang.ChannelIntFactory#createAny2One() */ public static Any2OneChannelInt createAny2One() { return factory.createAny2One(); } /** * Constructs and returns a One2AnyChannelInt object. * * @return the channel object. * * @see org.jcsp.lang.ChannelIntFactory#createOne2Any() */ public static One2AnyChannelInt createOne2Any() { return factory.createOne2Any(); } /** * Constructs and returns an Any2AnyChannelInt object. * * @return the channel object. * * @see org.jcsp.lang.ChannelIntFactory#createAny2Any() */ public static Any2AnyChannelInt createAny2Any() { return factory.createAny2Any(); } /** * Constructs and returns an array of One2OneChannelInt * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelIntArrayFactory#createOne2One(int) */ public static One2OneChannelInt[] createOne2One(int n) { return factory.createOne2One(n); } /** * Constructs and returns an array of Any2OneChannelInt * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelIntArrayFactory#createAny2One(int) */ public static Any2OneChannelInt[] any2oneArray(int n) { return factory.createAny2One(n); } /** * Constructs and returns an array of One2AnyChannelInt * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelIntArrayFactory#createOne2Any(int) */ public static One2AnyChannelInt[] createOne2Any(int n) { return factory.createOne2Any(n); } /** * Constructs and returns an array of Any2AnyChannelInt * objects. * * @param n the size of the array of channels. * @return the array of channels. * * @see org.jcsp.lang.ChannelIntArrayFactory#createAny2Any(int) */ public static Any2AnyChannelInt[] createAny2Any(int n) { return factory.createAny2Any(n); } /** * Constructs and returns a One2OneChannelInt object which * uses the specified ChannelDataStoreInt object as a buffer. * * @param buffer the ChannelDataStoreInt to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelIntFactory#createOne2One(ChannelDataStoreInt) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public static One2OneChannelInt createOne2One(ChannelDataStoreInt buffer) { return factory.createOne2One(buffer); } /** * Constructs and returns a Any2OneChannelInt object which * uses the specified ChannelDataStoreInt object as a buffer. * * @param buffer the ChannelDataStoreInt to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelIntFactory#createAny2One(ChannelDataStoreInt) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public static Any2OneChannelInt createAny2One(ChannelDataStoreInt buffer) { return factory.createAny2One(buffer); } /** * Constructs and returns a One2AnyChannelInt object which * uses the specified ChannelDataStoreInt object as a buffer. * * @param buffer the ChannelDataStoreInt to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelIntFactory#createOne2Any(ChannelDataStoreInt) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public static One2AnyChannelInt createOne2Any(ChannelDataStoreInt buffer) { return factory.createOne2Any(buffer); } /** * Constructs and returns a Any2AnyChannelInt object which * uses the specified ChannelDataStoreInt object as a buffer. * * @param buffer the ChannelDataStoreInt to use. * @return the buffered channel. * * @see org.jcsp.lang.BufferedChannelIntFactory#createAny2Any(ChannelDataStoreInt) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public static Any2AnyChannelInt createAny2Any(ChannelDataStoreInt buffer) { return factory.createAny2Any(buffer); } /** * Constructs and returns an array of One2OneChannelInt objects * which use the specified ChannelDataStoreInt object as a * buffer. * * @param buffer the ChannelDataStoreInt to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelIntArrayFactory#createOne2One(ChannelDataStoreInt, int) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public static One2OneChannelInt[] createOne2One(ChannelDataStoreInt buffer, int n) { return factory.createOne2One(buffer, n); } /** * Constructs and returns an array of Any2OneChannelInt objects * which use the specified ChannelDataStoreInt object as a * buffer. * * @param buffer the ChannelDataStoreInt to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelIntArrayFactory#createAny2One(ChannelDataStoreInt, int) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public static Any2OneChannelInt[] any2oneArray(ChannelDataStoreInt buffer, int n) { return factory.createAny2One(buffer, n); } /** * Constructs and returns an array of One2AnyChannelInt objects * which use the specified ChannelDataStoreInt object as a * buffer. * * @param buffer the ChannelDataStoreInt to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelIntArrayFactory#createOne2Any(ChannelDataStoreInt, int) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public static One2AnyChannelInt[] createOne2Any(ChannelDataStoreInt buffer, int n) { return factory.createOne2Any(buffer, n); } /** * Constructs and returns an array of Any2AnyChannelInt objects * which use the specified ChannelDataStoreInt object as a * buffer. * * @param buffer the ChannelDataStoreInt to use. * @param n the size of the array of channels. * @return the array of buffered channels. * * @see org.jcsp.lang.BufferedChannelIntArrayFactory#createAny2Any(ChannelDataStoreInt, int) * @see org.jcsp.util.ints.ChannelDataStoreInt */ public static Any2AnyChannelInt[] createAny2Any(ChannelDataStoreInt buffer, int n) { return factory.createAny2Any(buffer, n); } /** * Constructs and returns an array of input channel ends, each of which can be shared by multiple * concurrent readers. The returned array, r, is constructed such that * r[i] = c[i].in () for 0 <= i < c.length. * * @param c the array of channel to obtain input ends from. * @return the array of channel input ends. */ public static SharedChannelInputInt[] getInputArray(Any2AnyChannelInt[] c) { SharedChannelInputInt[] in = new SharedChannelInputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * Constructs and returns an array of input channel ends, each of which can be used as guards * in an Alternative. The returned array, r, is constructed such that * r[i] = c[i].in () for 0 <= i < c.length. * * @param c the array of channel to obtain input ends from. * @return the array of channel input ends. */ public static AltingChannelInputInt[] getInputArray(Any2OneChannelInt[] c) { AltingChannelInputInt[] in = new AltingChannelInputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * Constructs and returns an array of input channel ends, each of which can be shared by multiple * concurrent readers. The returned array, r, is constructed such that * r[i] = c[i].in () for 0 <= i < c.length. * * @param c the array of channel to obtain input ends from. * @return the array of channel input ends. */ public static SharedChannelInputInt[] getInputArray(One2AnyChannelInt[] c) { SharedChannelInputInt[] in = new SharedChannelInputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * Constructs and returns an array of input channel ends, each of which can be used as guards * in an Alternative. The returned array, r, is constructed such that * r[i] = c[i].in () for 0 <= i < c.length. * * @param c the array of channel to obtain input ends from. * @return the array of channel input ends. */ public static AltingChannelInputInt[] getInputArray(One2OneChannelInt[] c) { AltingChannelInputInt[] in = new AltingChannelInputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].in(); return in; } /** * Constructs and returns an array of output channel ends, each of which can be shared by multiple * concurrent writers. The returned array, r, is constructed such that * r[i] = c[i].out () for 0 <= i < c.length. * * @param c the array of channel to obtain output ends from. * @return the array of output input ends. */ public static SharedChannelOutputInt[] getOutputArray(Any2AnyChannelInt[] c) { SharedChannelOutputInt[] in = new SharedChannelOutputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * Constructs and returns an array of output channel ends, each of which can be shared by multiple * concurrent writers. The returned array, r, is constructed such that * r[i] = c[i].out () for 0 <= i < c.length. * * @param c the array of channel to obtain output ends from. * @return the array of output input ends. */ public static SharedChannelOutputInt[] getOutputArray(Any2OneChannelInt[] c) { SharedChannelOutputInt[] in = new SharedChannelOutputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * Constructs and returns an array of output channel ends, each of which can only be used by a * single writer. The returned array, r, is constructed such that * r[i] = c[i].out () for 0 <= i < c.length. * * @param c the array of channel to obtain output ends from. * @return the array of output input ends. */ public static ChannelOutputInt[] getOutputArray(One2AnyChannelInt[] c) { ChannelOutputInt[] in = new ChannelOutputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } /** * Constructs and returns an array of output channel ends, each of which can only be used by a * single writer. The returned array, r, is constructed such that * r[i] = c[i].out () for 0 <= i < c.length. * * @param c the array of channel to obtain output ends from. * @return the array of output input ends. */ public static ChannelOutputInt[] getOutputArray(One2OneChannelInt[] c) { ChannelOutputInt[] in = new ChannelOutputInt[c.length]; for (int i = 0; i < c.length; i++) in[i] = c[i].out(); return in; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelArrayFactory.java0000644000000000000000000000645511105701167020636 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a factory that can create arrays of channels. * * @author Quickstone Technologies Limited * * @deprecated These channel factories are deprecated in favour of the new one2one() methods in the Channel class. */ public interface ChannelArrayFactory { /** * Creates a populated array of n One2One channels. * * @param n the size of the array. * @return the created array of channels. */ public One2OneChannel[] createOne2One(int n); /** * Creates a populated array of n Any2One channels. * * @param n the size of the array. * @return the created array of channels. */ public Any2OneChannel[] createAny2One(int n); /** * Creates a populated array of n One2Any channels. * * @param n the size of the array. * @return the created array of channels. */ public One2AnyChannel[] createOne2Any(int n); /** * Creates a populated array of n Any2Any channels. * * @param n the size of the array. * @return the created array of channels. */ public Any2AnyChannel[] createAny2Any(int n); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableAltingChannelInput.java0000644000000000000000000000510411113671251022434 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for an input channel end that gives the reader the ability to reject instead * of accepting pending data. * * @author Quickstone Technologies Limited * * @deprecated This channel is superceded by the poison mechanisms, please see {@link PoisonException} */ public abstract class RejectableAltingChannelInput extends AltingChannelInput implements RejectableChannelInput { /** * Reject any data pending instead of reading it. The currently blocked writer will receive a * ChannelDataRejectedException. */ public abstract void reject(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableAny2OneChannelImpl.java0000644000000000000000000000417611113671251022336 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class PoisonableAny2OneChannelImpl extends Any2OneImpl { PoisonableAny2OneChannelImpl(int _immunity) { super(new PoisonableOne2OneChannelImpl(_immunity)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PriParallel.java0000644000000000000000000001324411105701167017140 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is an extension of the {@link Parallel} class that prioritises * the processes given to its control. *

Description

* PriParallel is an extension of the {@link Parallel} class that prioritises * the processes given to its control. * The ordering of the processes in * the array passed to the constructor (or added/inserted later) is significant, * with earlier processes having higher priority. The last process in the * array inherits the priority of the constructing process. That priority may * be set explicitly by {@link #setPriority setPriority}. *

* Implementation Note: these priorities are currently implemented * using the underlying threads priority mechanism. If there are more * priorities required than the maximum allowed for the threadgroup of * the spawning process, the higher requested priorities will be truncated * to that maximum. Also, the semantics of priority will be that implemented * by the JVM being used. * * @author P.D. Austin */ public class PriParallel extends Parallel { /** * Construct a new PriParallel object initially without any processes. * Processes may be added later using the inherited addProcess methods. * The order of their adding is significant, with ealier processes * having higher priority. */ public PriParallel() { super(null, true); } /** * Construct a new PriParallel object with the processes specified. * The ordering of the processes in the array is significant, with * ealier processes having higher priority. The last process in the * array inherits the priority of the constructing process. * * @param processes The processes to be executed in parallel */ public PriParallel(CSProcess[] processes) { super(processes, true); } /** * Insert another process to the pri-parallel object at the specifed * index. The point of insertion is significant because the ordering of * process components determines the priorities. The extended network * will be executed the next time run() is invoked. *

* @param process the process to be inserted * @param index the index at which to insert the process */ public void insertProcessAt(CSProcess process, int index) { super.insertProcessAt(process, index); } /** * This returns the current priority of this process. *

* @return the current priority of this process. */ public static int getPriority() { return Thread.currentThread().getPriority(); } /** * This changes the priority of this process. Note that JCSP only provides * this method for changing the priority of the invoking process. * Changing the process of another process is not considered wise. *

* Implementation Note: these priorities are currently implemented * using the underlying threads priority mechanism - hence run time * exceptions corresponding to the {@link java.lang.Thread}.getPriority() * may be thrown. *

* @throws java.lang.IllegalArgumentException if the priority is not * in the range supported by the underlying threads implementation. * @throws java.lang.SecurityException if the security manager of * the underlying threads implementation will not allow this modification. */ public static void setPriority(int newPriority) { Thread.currentThread().setPriority(newPriority); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedChannelFactory.java0000644000000000000000000000674011105701167021277 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ChannelDataStore; /** * Defines an interface for a factory that can create channels with user-definable buffering semantics. * * @author Quickstone Technologies Limited * * @deprecated These channel factories are deprecated in favour of the new one2one() methods in the Channel class. */ public interface BufferedChannelFactory { /** * Creates a new One2One channel with the given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public One2OneChannel createOne2One(ChannelDataStore buffer); /** * Creates a new Any2One channel with the given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public Any2OneChannel createAny2One(ChannelDataStore buffer); /** * Creates a new One2Any channel with the given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public One2AnyChannel createOne2Any(ChannelDataStore buffer); /** * Creates a new Any2Any channel with the given buffering behaviour. * * @param buffer the buffer implementation to use. * @return the created channel. */ public Any2AnyChannel createAny2Any(ChannelDataStore buffer); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Guard.java0000644000000000000000000001011111105701167015761 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is the super-class for all {@link Alternative} events selectable by a process. *

Description

* Guard defines an abstract interface to be implemented by events competing * for selection by a process executing an {@link Alternative}. Its methods have * only package visibility within org.jcsp.lang and are of no concern to * users of this package. Currently, JCSP supports channel inputs, accepts, * timeouts and skips as guards. *

* Note: for those familiar with the occam multiprocessing * language, classes implementing Guard correspond to process * guards for use within ALT constructs. * * @see org.jcsp.lang.CSTimer * @see org.jcsp.lang.Skip * @see org.jcsp.lang.AltingChannelInput * @see org.jcsp.lang.AltingChannelInputInt * @see org.jcsp.lang.Alternative * @author P.D. Austin * @author P.H. Welch */ public abstract class Guard { /** * Returns true if the event is ready. Otherwise, this enables the guard * for selection and returns false. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class that is controlling the selection * @return true if and only if the event is ready */ abstract boolean enable(Alternative alt); /** * Disables the guard for selection. Returns true if the event was ready. *

* Note: this method should only be called by the Alternative class * * @return true if and only if the event was ready */ abstract boolean disable(); /** * Schedules the process performing the given Alternative to run again. * This is intended for use by advanced users of the library who want to * create their own Guards that are not in the org.jcsp.lang package. * * @param alt The Alternative to schedule */ protected void schedule (Alternative alt) { alt.schedule(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedAny2OneChannelIntImpl.java0000644000000000000000000001115111105701167022430 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.*; /** * This implements an any-to-one integer channel with user-definable buffering, * safe for use by many writers and one reader. *

Description

* BufferedAny2OneChannelIntImpl implements an any-to-one integer channel with * user-definable buffering. It is safe for use by many writing processes * but only one reader. Writing processes compete with each other to use * the channel. Only the reader and one writer will * actually be using the channel at any one time. This is taken care of by * BufferedAny2OneChannelIntImpl -- user processes just read from or write to it. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ints.ChannelDataStoreInt ChannelDataStoreInt} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * *

Implementation Note and Caution

* Fair servicing of writers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * any-1 channels. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.BufferedOne2OneChannelIntImpl * @see org.jcsp.lang.BufferedOne2AnyChannelIntImpl * @see org.jcsp.lang.BufferedAny2AnyChannelIntImpl * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin * @author P.H. Welch */ class BufferedAny2OneChannelIntImpl extends Any2OneIntImpl { public BufferedAny2OneChannelIntImpl(ChannelDataStoreInt data) { super(new BufferedOne2OneChannelIntImpl(data)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneChannelIntImpl.java0000644000000000000000000002750111113402355020761 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.ChannelDataStoreInt; /** * This implements a one-to-one integer channel. *

Description

* One2OneChannelIntImpl implements a one-to-one integer channel. Multiple * readers or multiple writers are not allowed -- these are catered for * by {@link Any2OneChannelIntImpl}, * {@link One2AnyChannelIntImpl} or * {@link Any2AnyChannelIntImpl}. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

* The default semantics of the channel is that of CSP -- i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

* However, the static methods of {@link Channel} allow the creation of * a channel with a plug-in driver conforming to the * {@link org.jcsp.util.ints.ChannelDataStoreInt ChannelDataStoreInt} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util.ints package, but * careful users may write their own. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.Any2OneChannelIntImpl * @see org.jcsp.lang.One2AnyChannelIntImpl * @see org.jcsp.lang.Any2AnyChannelIntImpl * @see org.jcsp.util.ints.ChannelDataStoreInt * * @author P.D. Austin * @author P.H. Welch */ class One2OneChannelIntImpl implements ChannelInternalsInt, One2OneChannelInt { /** The monitor synchronising reader and writer on this channel */ private Object rwMonitor = new Object(); /** The (invisible-to-users) buffer used to store the data for the channel */ private int hold; /** The synchronisation flag */ private boolean empty = true; /** The Alternative class that controls the selection */ private Alternative alt; /** Flag to deal with a spurious wakeup during a write */ private boolean spuriousWakeUp = true; /*************Methods from One2OneChannelInt******************************/ /** * Returns the AltingChannelInputInt object to use for this * channel. As One2OneChannelIntImpl implements * AltingChannelInputInt itself, this method simply returns * a reference to the object that it is called on. * * @return the AltingChannelInputInt object to use for this * channel. */ public AltingChannelInputInt in() { return new AltingChannelInputIntImpl(this,0); } /** * Returns the ChannelOutputInt object to use for this * channel. As One2OneChannelIntImpl implements * ChannelOutputInt itself, this method simply returns * a reference to the object that it is called on. * * @return the ChannelOutputInt object to use for this * channel. */ public ChannelOutputInt out() { return new ChannelOutputIntImpl(this,0); } /**********************************************************************/ /** * Reads an int from the channel. * * @return the integer read from the channel. */ public int read () { synchronized (rwMonitor) { if (empty) { empty = false; try { rwMonitor.wait (); while (!empty) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelIntRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannelInt.read ()\n" + e.toString () ); } } else { empty = true; } spuriousWakeUp = false; rwMonitor.notify (); return hold; } } public int startRead() { synchronized (rwMonitor) { if (empty) { empty = false; try { rwMonitor.wait (); while (!empty) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from One2OneChannel.read ()\n" + e.toString ()); } } else { empty = true; } return hold; } } public void endRead() { synchronized (rwMonitor) { spuriousWakeUp = false; rwMonitor.notify (); } } /** * Writes an int to the channel. * * @param value the integer to write to the channel. */ public void write (int value) { synchronized (rwMonitor) { hold = value; if (empty) { empty = false; if (alt != null) { alt.schedule (); } } else { empty = true; rwMonitor.notify (); } try { rwMonitor.wait (); while (spuriousWakeUp) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelIntWrite); } rwMonitor.wait (); } spuriousWakeUp = true; } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannelInt.write (int)\n" + e.toString () ); } } } /** * turns on Alternative selection for the channel. Returns true if the * channel has data that can be read immediately. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class which will control the selection * @return true if the channel has data that can be read, else false */ public boolean readerEnable(Alternative alt) { synchronized (rwMonitor) { if (empty) { this.alt = alt; return false; } else return true; } } /** * turns off Alternative selection for the channel. Returns true if the * channel contained data that can be read. *

* Note: this method should only be called by the Alternative class * * @return true if the channel has data that can be read, else false */ public boolean readerDisable() { synchronized (rwMonitor) { alt = null; return!empty; } } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. *

* This method is provided for convenience. Its functionality can be provided * by Pri Alting the channel against a SKIP guard, although * at greater run-time and syntactic cost. For example, the following code * fragment: *

     *   if (c.pending ()) {
     *     int x = c.read ();
     *     ...  do something with x
     *   } else (
     *     ...  do something else
     *   }
     * 
* is equivalent to: *
     *   if (c_pending.priSelect () == 0) {
     *     int x = c.read ();
     *     ...  do something with x
     *   } else (
     *     ...  do something else
     * }
     * 
* where earlier would have had to have been declared: *
     * final Alternative c_pending =
     *   new Alternative (new Guard[] {c, new Skip ()});
     * 
* * @return state of the channel. */ public boolean readerPending() { synchronized (rwMonitor) { return !empty; } } /** * Creates an array of One2OneChannelInts. * * @param n the number of channels to create in the array * @return the array of One2OneChannelIntImpl */ public static One2OneChannelInt[] create(int n) { One2OneChannelInt[] channels = new One2OneChannelIntImpl[n]; for (int i = 0; i < n; i++) channels[i] = new One2OneChannelIntImpl(); return channels; } /** * Creates a One2OneChannelIntImpl using the specified ChannelDataStoreInt. * * @return the One2OneChannelIntImpl */ public static One2OneChannelInt create(ChannelDataStoreInt store) { return new BufferedOne2OneChannelIntImpl(store); } /** * Creates an array of One2OneChannelInts using the specified ChannelDataStoreInt. * * @param n the number of channels to create in the array * @return the array of One2OneChannelIntImpl */ public static One2OneChannelInt[] create(int n, ChannelDataStoreInt store) { One2OneChannelInt[] channels = new One2OneChannelIntImpl[n]; for (int i = 0; i < n; i++) channels[i] = new BufferedOne2OneChannelIntImpl(store); return channels; } // No poison on these channels: public void readerPoison(int strength) { } public void writerPoison(int strength) { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelOutputInt.java0000644000000000000000000000760311113671251021335 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This extends {@link Guard} and {@link ChannelOutputInt} * to enable a process * to choose between many integer output (and other) events. *

* A writing-end, obtained only from a {@link One2OneChannelSymmetricInt symmetric} * channel by invoking its out() method, will implement this interface. *

Description

* AltingChannelOutputInt extends {@link Guard} and {@link ChannelOutputInt} * to enable a process * to choose between many integer output (and other) events. The methods inherited from * Guard are of no concern to users of this package. *

*

Example

*
 * import org.jcsp.lang.*;
 * 
 * public class AltingOutputIntExample implements CSProcess {
 * 
 *   private final AltingChannelOutputInt out0, out1;
 *   
 *   public AltingOutputIntExample (final AltingChannelOutputInt out0,
 *                                  final AltingChannelOutputInt out1) {
 *     this.out0 = out0;
 *     this.out1 = out1;
 *   }
 * 
 *   public void run () {
 * 
 *     final Guard[] altChans = {out0, out1};
 *     final Alternative alt = new Alternative (altChans);
 * 
 *     while (true) {
 *       switch (alt.select ()) {
 *         case 0:
 *           out0.write (0);
 *           System.out.println ("out0 written");
 *         break;
 *         case 1:
 *           out1.write (1);
 *           System.out.println ("out1 written");
 *         break;
 *       }
 *     }
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.lang.Guard * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.One2OneChannelSymmetricInt * @see org.jcsp.lang.AltingChannelOutput * @author P.H. Welch */ //}}} public abstract class AltingChannelOutputInt extends Guard implements ChannelOutputInt { // nothing alse to add /** * Returns whether the receiver is committed to read from this channel. *

* Note: if this returns true, you must commit to write down this channel. * * @return state of the channel. */ public abstract boolean pending (); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingConnectionServer.java0000644000000000000000000001235611105701167021361 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * An interface to connection. This is used by servers which wish to * {@link Alternative ALT} over a connection. Note that you cannot have * more than one server serving an AltingConnectionServer. * * @see ConnectionServer * @see ConnectionClient * @see Connection * * @author Quickstone Technologies Limited */ public abstract class AltingConnectionServer extends Guard implements ConnectionServer { /** * The channel used to ALT over. */ private AltingChannelInput altingChannel; /** * Constructor. * * Note that this is only intended for use by JCSP, and should * not be called by user processes. Users should use one of the * subclasses. * * @param altingChannel The channel used to implement the Guard */ protected AltingConnectionServer(AltingChannelInput altingChannel) { this.altingChannel = altingChannel; } /** * Returns the channel used to implement the Guard. * * Note that this method is only intended for use by * JCSP, and should not be called by user processes. * * Concrete subclasses should override this method to * return null, to ensure that the alting channel is * kept private. * * @return The channel passed to the constructor. */ protected AltingChannelInput getAltingChannel() { return altingChannel; } /** * ConnectionServer implementations are likely to be * implemented over channels. Multiple channels from the client * to server may be used; one could be used for the initial * connection while another one could be used for data requests. * * This method allows sub-classes to specify which channel should * be the next one to be alted over. * * @param chan the channel to be ALTed over. */ protected void setAltingChannel(AltingChannelInput chan) { altingChannel = chan; } /** * Returns true if the event is ready. Otherwise, this enables the guard * for selection and returns false. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class that is controlling the selection * @return true if and only if the event is ready */ boolean enable(Alternative alt) { return altingChannel.enable(alt); } /** * Disables the guard for selection. Returns true if the event was ready. *

* Note: this method should only be called by the Alternative class * * @return true if and only if the event was ready */ boolean disable() { return altingChannel.disable(); } /** * Returns whether there is an open() pending on this connection.

* * Note: if there is, it won't go away until you accept it. But if * there isn't, there may be one by the time you check the result of * this method. * * @return true only if open() will complete without blocking. */ public boolean pending() { return altingChannel.pending(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionServer.java0000644000000000000000000001266111105701167020221 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** *

This interface should be implemented by classes that wish to * act as connection servers and to accept requests from * ConnectionClient objects.

* *

The server can call request() to allow a client * to establish a connection to the server and to obtain the client's * initial request. This should block until a client establishes a * connection.

* *

Once a request has been received, the server should reply to the client. * If the server wants to close the connection then the server should call * replyAndClose(Object) or alternatively * reply(Object, boolean) with the boolean set to * true. If the server wants to keep the connection open, then it * should call reply(Object) or alternatively * reply(Object, boolean) with the boolean set to * false. The reply(Object, boolean) method is * provided for convenience in closing connections programatically.

* * @author Quickstone Technologies Limited */ public interface ConnectionServer { /** * The factory for creating channels within servers. */ static StandardChannelFactory FACTORY = new StandardChannelFactory(); /** *

Receives a request from a client. This will block until the client * calls its request(Object) method. Implementations may * make this ALTable.

* *

After this method has returned, the server should call one of the * reply methods. Performing any external process synchronization * between these method calls could be potentially hazardous and could * lead to deadlock.

* * @return the Object sent by the client. */ public Object request() throws IllegalStateException; /** *

Sends some data back to the client after a request * has been received but keeps the connection open. After calling * this method, the server should call recieve() * to receive a further request.

* *

A call to this method is equivalent to a call to * reply(Object, boolean) with the boolean set to * false.

* * @param data the data to send to the client. */ public void reply(Object data) throws IllegalStateException; /** *

Sends some data back to the client after a request * has been received. The boolean close parameter * indicates whether the connection should be closed after this * reply has been sent.

* *

This method should not block.

* * @param data the data to send back to client. * @param close boolean that should be true * iff the connection should be dropped after the reply * has been sent. */ public void reply(Object data, boolean close); /** *

Sends some data back to the client and closes the connection.

* *

A call to this method is equivalent to a call to * reply(Object, boolean) with the boolean set to * true.

* * @param data the data to send back to client. */ public void replyAndClose(Object data) throws IllegalStateException; } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BlackHoleChannelInt.java0000644000000000000000000000660711105701167020526 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements {@link ChannelOutputInt} with black hole semantics. *

Description

* BlackHoleChannelInt is an implementation of {@link ChannelOutputInt} that yields * black hole semantics for a channel. Writers may always write but there can be * no readers. Any number of writers may share the same black hole. *

* Note: BlackHoleChannelInts are used for masking off unwanted outputs * from processes. They are useful when we want to reuse an existing process component * intact, but don't need some of its output channels (i.e. we don't want to redesign * and reimplement the component to remove the redundant channels). Normal channels cannot * be plugged in and left dangling as this may deadlock (parts of) the component being * reused. *

* * @see org.jcsp.lang.ChannelOutputInt * @see org.jcsp.lang.One2OneChannelInt * @see org.jcsp.lang.Any2OneChannelInt * @see org.jcsp.lang.One2AnyChannelInt * @see org.jcsp.lang.Any2AnyChannelInt * * @author P.H. Welch */ public class BlackHoleChannelInt implements ChannelOutputInt { /** * Write an integer to the channel and loose it. * * @param n the integer to write to the channel. */ public void write(int n) { } public void poison(int strength) { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneChannelImpl.java0000644000000000000000000002431011113402355020301 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements a one-to-one object channel. *

Description

* One2OneChannelImpl implements a one-to-one object channel. Multiple * readers or multiple writers are not allowed -- these are catered for * by {@link Any2OneChannelImpl}, * {@link One2AnyChannelImpl} or * {@link Any2AnyChannelImpl}. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

* The default semantics of the channel is that of CSP -- i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

* However, the static methods of {@link Channel} allow the construction of * a channel with a plug-in driver conforming to the * {@link org.jcsp.util.ChannelDataStore ChannelDataStore} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.Any2OneChannelImpl * @see org.jcsp.lang.One2AnyChannelImpl * @see org.jcsp.lang.Any2AnyChannelImpl * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin * @author P.H. Welch */ class One2OneChannelImpl implements One2OneChannel, ChannelInternals { /** The monitor synchronising reader and writer on this channel */ private Object rwMonitor = new Object (); /** The (invisible-to-users) buffer used to store the data for the channel */ private Object hold; /** The synchronisation flag */ private boolean empty = true; /** The Alternative class that controls the selection */ private Alternative alt; /** Flag to deal with a spurious wakeup during a write */ private boolean spuriousWakeUp = true; /*************Methods from One2OneChannel******************************/ /** * Returns the AltingChannelInput to use for this channel. * As One2OneChannelImpl implements * AltingChannelInput itself, this method simply returns * a reference to the object that it is called on. * * @return the AltingChannelInput object to use for this * channel. */ public AltingChannelInput in() { return new AltingChannelInputImpl(this,0); } /** * Returns the ChannelOutput object to use for this channel. * As One2OneChannelImpl implements * ChannelOutput itself, this method simply returns * a reference to the object that it is called on. * * @return the ChannelOutput object to use for this * channel. */ public ChannelOutput out() { return new ChannelOutputImpl(this,0); } /*************Methods from ChannelOutput*******************************/ /** * Writes an Object to the channel. * * @param value the object to write to the channel. */ public void write(Object value) { synchronized (rwMonitor) { hold = value; if (empty) { empty = false; if (alt != null) { alt.schedule(); } } else { empty = true; rwMonitor.notify(); } try { rwMonitor.wait(); while (spuriousWakeUp) { if (Spurious.logging) { SpuriousLog.record(SpuriousLog.One2OneChannelWrite); } rwMonitor.wait(); } spuriousWakeUp = true; } catch (InterruptedException e) { throw new ProcessInterruptedException( "*** Thrown from One2OneChannel.write (Object)\n" + e.toString()); } } } /** ***********Methods from AltingChannelInput************************* */ /** * Reads an Object from the channel. * * @return the object read from the channel. */ public Object read () { synchronized (rwMonitor) { if (empty) { empty = false; try { rwMonitor.wait (); while (!empty) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from One2OneChannel.read ()\n" + e.toString ()); } } else { empty = true; } spuriousWakeUp = false; rwMonitor.notify (); return hold; } } public Object startRead() { synchronized (rwMonitor) { if (empty) { empty = false; try { rwMonitor.wait (); while (!empty) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from One2OneChannel.read ()\n" + e.toString ()); } } else { empty = true; } return hold; } } public void endRead() { synchronized (rwMonitor) { spuriousWakeUp = false; rwMonitor.notify (); } } /** * turns on Alternative selection for the channel. Returns true if the * channel has data that can be read immediately. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class which will control the selection * @return true if the channel has data that can be read, else false */ public boolean readerEnable (Alternative alt) { synchronized (rwMonitor) { if (empty) { this.alt = alt; return false; } else { return true; } } } /** * turns off Alternative selection for the channel. Returns true if the * channel contained data that can be read. *

* Note: this method should only be called by the Alternative class * * @return true if the channel has data that can be read, else false */ public boolean readerDisable () { synchronized (rwMonitor) { alt = null; return !empty; } } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. *

* This method is provided for convenience. Its functionality can be provided * by Pri Alting the channel against a SKIP guard, although * at greater run-time and syntactic cost. For example, the following code * fragment: *

	   *   if (c.pending ()) {
	   *     Object x = c.read ();
	   *     ...  do something with x
	   *   } else (
	   *     ...  do something else
	   *   }
	   * 
* is equivalent to: *
	   *   if (c_pending.priSelect () == 0) {
	   *     Object x = c.read ();
	   *     ...  do something with x
	   *   } else (
	   *     ...  do something else
	   * }
	   * 
* where earlier would have had to have been declared: *
	   * final Alternative c_pending =
	   *   new Alternative (new Guard[] {c, new Skip ()});
	   * 
* * @return state of the channel. */ public boolean readerPending () { synchronized (rwMonitor) { return !empty; } } //No poison in these channels: public void writerPoison(int strength) { } public void readerPoison(int strength) { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneConnection.java0000644000000000000000000000471211105701167020216 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a connection that can be used by a single server and single client. * * @author Quickstone Technologies Limited */ public interface One2OneConnection { /** * Returns the client end of the connection. */ public AltingConnectionClient client(); /** * Returns the server end of the connection. */ public AltingConnectionServer server(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelIntFactory.java0000644000000000000000000000573711105701167020314 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a factory that can create channels carrying integers. * * @author Quickstone Technologies Limited * * @deprecated These channel factories are deprecated in favour of the new one2one() methods in the Channel class. */ public interface ChannelIntFactory { /** * Creates a new One2One channel. * * @return the created channel. */ public One2OneChannelInt createOne2One(); /** * Creates a new Any2One channel. * * @return the created channel. */ public Any2OneChannelInt createAny2One(); /** * Creates a new One2Any channel. * * @return the created channel. */ public One2AnyChannelInt createOne2Any(); /** * Creates a new Any2Any channel. * * @return the created channel. */ public Any2AnyChannelInt createAny2Any(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneCallChannel.java0000644000000000000000000010073411105701167020272 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * This is the super-class for any-to-one interface-specific CALL channels, * safe for use by many clients and one server. *

* Shortcut to the Constructor and Method Summaries. * *

Description

* Please see {@link One2OneCallChannel} for general information about CALL channels. * Documented here is information specific to this any-1 version. * *

Converting a Method Interface into a Variant CALL Channel

* Constructing a any-1 CALL channel for a specific interface * follows exactly the same pattern as in the 1-1 case. Of course, it must * extend Any2OneCallChannel rather than One2OneCallChannel. *

* For example, using the same Foo * interface as before, we derive: *

 * import org.jcsp.lang.*;
 * 
 * public class Any2OneFooChannel extends Any2OneCallChannel implements Foo {
 * 
 *   ...  same body as One2OneFooChannel
 * 
 * }
 * 
* *

Calling a CALL Channel

* All the client needs to see is the method interface * implemented by the CALL channel. So far as the client is concerned, therefore, * there is no difference between any of the varieties of CALL channel * - it just makes the call. * *

Accepting a CALL Channel

* The mechanics of accepting a CALL channel are the same for all varieties. * However, the server should declare which kind (or kinds) it allows * to be attached: *
 * import org.jcsp.lang.*;
 * 
 * class B implements CSProcess, Foo {
 * 
 *   private final ChannelAccept in;
 * 
 *   public B (final One2OneFooChannel in) {         // original constructor
 *     this.in = in;
 *   }
 * 
 *   public B (final Any2OneFooChannel in) {        // additional constructor
 *     this.in = in;
 *   }
 * 
 *   ...  rest as before
 * 
 * }
 * 
* When wrapping the above to hide its raw method interface, don't forget to include * the extra constructor(s): *
 * import org.jcsp.lang.*;
 * 
 * public class B2 implements CSProcess {            // no Foo interface
 * 
 *   private final B b;
 * 
 *   public B2 (final One2OneFooChannel in) {        // original constructor
 *     b = new B (in);
 *   }
 * 
 *   public B2 (final Any2OneFooChannel in) {       // additional constructor
 *     b = new B (in);
 *   }
 * 
 *   public void run () {
 *     b.run ();
 *   }
 * 
 * }
 * 
* *

ALTing on a CALL Channel

* The server may ALT on a any-1 CALL channel, just as it may ALT on * a 1-1 one. As before, it needs to make its intentions explicit. So, in * the above example, the first field declaration of B * needs to become: *
 *   private final AltingChannelAccept in;
 * 
* See below for an example of ALTing between CALL channels. * *

Building a CALL Channel Network

* Network building with CALL channels is the same as building with ordinary * channels. First construct the channels and, then, construct the processes * - plugging in the channels as required and running them in {@link Parallel}. *

* For example, the network consisting of one server and several clients: *

* where A is unchanged from its definition * in
One2OneCallChannel, * is implemented by: *
 *     Any2OneFooChannel c = new Any2OneFooChannel ();
 * 
 *     final A[] aClients = new A[n_aClients];
 *     for (int i = 0; i < aClients.length; i++) {
 *       aClients[i] = new A (c);
 *     }
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Parallel (aClients),
 *         new B2 (c)
 *       }
 *     ).run ();
 * 
* *

Example

* This is a CALL channel version of * the Wot-no-Chickens example: *

* The service CALL channel replaces the request/deliver channel pair * of the earlier example. Previously, the philosopher had to perform two actions to get a chicken - * a request.write followed by a deliver.read. Now, its interaction with the * canteen is a single CALL on service.takeChicken. *

* The supply CALL channel replaces the ordinary channel of the same name. * Previously, the chef still had to perform two actions to supply the chickens - * a supply.write followed by a second supply.write. This was to model * the extended period while the chef set down the chickens in the canteen. The first * communication synchronised the chef with the canteen, getting its exclusive attention. * The canteen then executed the set-down delay before accepting the second communication * and, hence, releasing the chef. Now, this interaction is a single CALL * on supply.freshChickens. *

* The other difference with the earlier example is that the college now employs many chefs. * This has two minor impacts. It needs to be able to support any-1 CALLs on its * supply channel (as well as on service). Secondly, with all those chefs, * it needs to be able to refuse further supplies of chicken if it has run of room. * *

The Canteen

* There are two other differences in design between the canteen server here and * the CALL channel servers documented above and in {@link One2OneCallChannel}. The first * is trivial - we have inlined the real server as an anonymous inner class of * the public Canteen wrapper. The second is more subtle, but also trivial. * Often, a CALL channel is constructed for a specific server interface and there is * no intention for it to be used for communicating with any other server. In which case, * it makes sense to tie that interface, together with its corresponding CALL channel, * into the server as inner declarations. *

* So, the Canteen first publishes its two specific interfaces and matching CALL channels. * The CALL channels follow * the defined pattern, * omitting the optional setting of selected * (since each interface contains only one method): *

 * import org.jcsp.lang.*;
 * 
 * class Canteen implements CSProcess {
 * 
 *   public static interface Service {
 *     public int takeChicken (String philId);
 *   }
 * 
 *   public static class One2OneServiceChannel
 *    extends One2OneCallChannel implements Service {
 *     public int takeChicken (String philId) {
 *       join ();
 *       int n = ((Service) server).takeChicken (philId);
 *       fork ();
 *       return n;
 *     }
 *   }
 * 
 *   public static class Any2OneServiceChannel
 *    extends Any2OneCallChannel implements Service {
 *     public int takeChicken (String philId) {
 *       join ();
 *       int n = ((Service) server).takeChicken (philId);
 *       fork ();
 *       return n;
 *     }
 *   }
 * 
 *   public static interface Supply {
 *     public int freshChickens (String chefId, int value);
 *   }
 * 
 *   public static class Any2OneSupplyChannel
 *    extends Any2OneCallChannel implements Supply {
 *     public int freshChickens (String chefId, int value) {
 *       join ();
 *       int n = ((Supply) server).freshChickens (chefId, value);
 *       fork ();
 *       return n;
 *     }
 *   }
 * 
* Note that we have defined both 1-1 and any-1 versions of the Service * CALL channel. This example makes use only of the any-1 variant - the other will * be used in a later exercise. *

* Next we set up the constructor and the local fields for saving its parameters: *

 *   private final AltingChannelAccept service;   // shared from all Philosphers
 *   private final AltingChannelAccept supply;    // shared from all Chefs
 *   private final int serviceTime;
 *   // how long a philosopher spends in the canteen
 *   private final int supplyTime;
 *   // how long a chef spends in the canteen
 *   private final int maxChickens;
 *   // maximum number of chickens in the canteen
 * 
 *   public Canteen (Any2OneServiceChannel service, Any2OneSupplyChannel supply,
 *                   int serviceTime, int supplyTime, int maxChickens) {
 *     this.service = service;
 *     this.supply = supply;
 *     this.serviceTime = serviceTime;
 *     this.supplyTime = supplyTime;
 *     this.maxChickens = maxChickens;
 *   }
 * 
* Now, we need to combine the exported interfaces into a single one so that the inner process * can be created (anonymously) by this wrapper's run method: *
 *   private interface inner extends CSProcess, Service, Supply {};
 * 
 *   public void run () {
 * 
 *     new inner () {
 * 
 *       private int nChickens = 0;
 *       private int nSupplied = 0;
 * 
 *       private final CSTimer tim = new CSTimer ();
 * 
* Impementations of the required CALL interfaces come next: *
 *       public int takeChicken (String philId) {
 *       // pre : nChickens > 0
 *         System.out.println ("   Canteen -> " + philId
 *                             + " : one chicken ordered ... "
 *                             + nChickens + " left ... ");
 *         tim.sleep (serviceTime);
 *         nChickens--;
 *         nSupplied++;
 *         System.out.println ("   Canteen -> " + philId
 *                             + " : one chicken coming down ... "
 *                             + nChickens + " left ... ["
 *                             + nSupplied + " supplied]");
 *         return 1;
 *       }
 * 
 *       public int freshChickens (String chefId, int value) {
 *       // pre : nChickens < maxChickens
 *         System.out.println ("   Canteen <- " + chefId
 *                             + " : ouch ... make room ... ");
 *         tim.sleep (supplyTime);
 *         nChickens += value;
 *         int sendBack = nChickens - maxChickens;
 *         if (sendBack > 0) {
 *           nChickens = maxChickens;
 *           System.out.println ("   Canteen <- " + chefId
 *                               + " : full up ... sending back "
 *                               + sendBack);
 *         } else {
 *           sendBack = 0;
 *         }
 *         System.out.println ("   Canteen <- " + chefId
 *                             + " : more chickens ... "
 *                             + nChickens + " now available ... ");
 *         return sendBack;
 *       }
 * 
* and the run method that conducts everything: *
 *       public void run () {
 * 
 *         final Alternative alt = new Alternative (new Guard[] {supply, service});
 *         final boolean[] precondition = {true, false};
 *         final int SUPPLY = 0;
 *         final int SERVICE = 1;
 * 
 *         System.out.println ("   Canteen : starting ... ");
 *         while (true) {
 *           precondition[SERVICE] = (nChickens > 0);
 *           precondition[SUPPLY] = (nChickens < maxChickens);
 *           switch (alt.fairSelect (precondition)) {
 *             case SUPPLY:
 *               supply.accept (this);      // new batch of chickens from a chef
 *             break;
 *             case SERVICE:
 *               service.accept (this);     // a philosopher wants a chicken
 *             break;
 *           }
 *         }
 * 
 *       }
 * 
* Finally, don't forget to run this inner process: *
 *     }.run ();
 * 
 *   }
 * 
 * }
 * 
* *

The Philosopher

* As in the original example, philosophers spend their time thinking, feeling hungry, * calling on the canteen and, once served, eating. Except, of course, for greedy * philosophers who never stop to think: *
 * import org.jcsp.lang.*;
 * 
 * class Phil implements CSProcess {
 * 
 *   private final String id;
 *   private final Canteen.Service service;
 *   private final int thinkTime;
 *   private final int eatTime;
 *   private final boolean greedy;
 * 
 *   public Phil (String id, Canteen.Service service,
 *                int thinkTime, int eatTime, boolean greedy) {
 *     this.id = id;
 *     this.service = service;
 *     this.thinkTime = thinkTime;
 *     this.eatTime = eatTime;
 *     this.greedy = greedy;
 *   }
 * 
 *   public void run () {
 *     final CSTimer tim = new CSTimer ();
 *     int nEaten = 0;
 *     while (true) {
 *       if (! greedy) {
 *         System.out.println ("   Phil " + id
 *                             + " : thinking ... ");
 *         tim.sleep (thinkTime);  // thinking
 *       }
 *       System.out.println ("   Phil " + id
 *                           + " : gotta eat ... ");
 *       int chicken = service.takeChicken (id);
 *       nEaten++;
 *       System.out.println ("   Phil " + id
 *                           + " : mmm ... that's good ["
 *                           + nEaten + " so far]");
 *       tim.sleep (eatTime);      // eating
 *     }
 *   }
 * 
 * }
 * 
* *

The Chef

* Chefs cook chickens in batches of batchSize, taking batchTime * milliseconds per batch. When a batch is ready, the chef supplies it to the canteen. * The chef has to wait until the canteen is prepared to take it and, then, helps * to set down the batch (before returning with any for which there was no space) * - all this happens during the CALL of supply.freshChickens: *
 * import org.jcsp.lang.*;
 * 
 * class Chef implements CSProcess {
 * 
 *   private final String id;
 *   private final int batchSize;
 *   private final int batchTime;
 *   private final Canteen.Supply supply;
 * 
 *   public Chef (String id, int batchSize, int batchTime, Canteen.Supply supply) {
 *     this.id = id;
 *     this.batchSize = batchSize;
 *     this.batchTime = batchTime;
 *     this.supply = supply;
 *   }
 * 
 *   public void run () {
 * 
 *     final CSTimer tim = new CSTimer ();
 * 
 *     int nReturned = 0;
 *     int nSupplied = 0;
 * 
 *     while (true) {
 *       System.out.println ("   Chef " + id + " : cooking ... "
 *                           + (batchSize - nReturned) + " chickens");
 *       tim.sleep (batchTime);
 *       System.out.println ("   Chef " + id + " : "
 *                           + batchSize + " chickens, ready-to-go ... ");
 *       nReturned = supply.freshChickens (id, batchSize);
 *       nSupplied += (batchSize - nReturned);
 *       System.out.println ("   Chef " + id + " : "
 *                           + nReturned + " returned ["
 *                           + nSupplied + " supplied]");
 *     }
 *   }
 * 
 * }
 * 
* *

The Clock

* The college is feeling generous and provides a clock. This just ticks away, * delivering time-stamps roughly every second (and maintaining real-time). * It is independent of the rest of the system. *
 * import org.jcsp.lang.*;
 * 
 * class Clock implements CSProcess {
 * 
 *   public void run () {
 * 
 *     final CSTimer tim = new CSTimer ();
 *     final long startTime = tim.read ();
 * 
 *     while (true) {
 *       int tick = (int) (((tim.read () - startTime) + 500)/1000);
 *       System.out.println ("[TICK] " + tick);
 *       tim.sleep (1000);
 *     }
 * 
 *   }
 * 
 * }
 * 
* *

The College

* Despite the greedy behaviour of philosopher 0 (Bill), nobody starves in * this college. Three chefs are provided with differing cooking speeds and batch sizes. * Pierre is the original lightning chef, cooking 4 chickens in 2 seconds flat. * Henri is more leisurely, taking 20 seconds to cook his batch of 10. * Sid has been sent down by the new owners of the college, who are into * mass catering. He produces 100 chickens every 150 seconds, which is a bit silly since * the canteen has only space for 50. Still, it enables Bill to get really sick! *

* For convenience, the college network diagram is reproduced here - this time including * the clock and naming some of the characters: *

* Here is the code: *
 * import org.jcsp.lang.*;
 * 
 * class College implements CSProcess {
 * 
 *   public void run () {
 * 
 *     final String[] philId = {"Bill", "Hilary", "Gennifer", "Paula", "Monica"};
 * 
 *     final int thinkTime = 3000;             // 3 seconds
 *     final int eatTime = 100;                // 100 milliseconds
 * 
 *     final int serviceTime = 0;              // 0 seconds
 *     final int supplyTime = 3000;            // 3 seconds
 *     final int maxChickens = 50;
 * 
 *     final Canteen.Any2OneServiceChannel service
 *       = new Canteen.Any2OneServiceChannel ();
 *     final Canteen.Any2OneSupplyChannel supply
 *       = new Canteen.Any2OneSupplyChannel ();
 * 
 *     final Phil[] phils = new Phil[philId.length];
 *     for (int i = 0; i < phils.length; i++) {
 *       phils[i] = new Phil (philId[i], service, thinkTime, eatTime, i == 0);
 *     }
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Clock (),
 *         new Canteen (service, supply, serviceTime, supplyTime, maxChickens),
 *         new Parallel (phils),
 *         new Chef ("Pierre", 4, 2000, supply),
 *         // chefId, batchSize, batchTime
 *         new Chef ("Henri", 10, 20000, supply),
 *         new Chef ("Sid", 100, 150000, supply)
 *       }
 *     ).run ();
 * 
 *   }
 * 
 *   public static void main (String argv[]) {
 *     new College ().run ();
 *   }
 * 
 * }
 * 
* *

A Note about System.out and Other Non-Blocking Monitors

* The college network diagram and code hides a key player that * quietly coordinates the reporting of all activity - System.out. * All the processes share this object as a common resource, making heavy and * concurrent demands on its println service. Why is this safe? *

* Consider a Java object whose public methods are all synchronized but * contain no invocations of wait or notify (a passive * non-blocking monitor). * Such an object is equivalent to a CSProcess serving one or more * any-1 CALL channels (whose interfaces reflect those synchronized * methods) and whose run consists of an endless loop that does nothing * except unconditionally accept any CALL. *

* So, a simple non-blocking monitor is always safe to share between concurrent JCSP * processes and, currently, carries less overheads than its active server * equivalent. See {@link org.jcsp.awt.DisplayList} for an example from the JCSP library. * Another example is {@link java.io.PrintStream java.io.PrintStream}, of which * System.out is an instance. Its print/println methods * are synchronized on itself (although this does not seem to be documented and * you have to look hard at the code to find out). So, to show the full story, the above * diagram possibly needs an overlay that adds a System.out * process servicing a any-1 println CALL channel, with all the other processes * as clients. This is left as an exercise. *

* Of course, it would be nice if such monitors were accessed via an interface, * so that client processes had neither direct visibilty of them nor concern about their * behaviour. A problem with the above college is that System.out - and * the concept of printing a line of text - is burnt into the code of all its * processes. If we wanted to change the output of the college from a scrolling text * display into some graphics animation, all those processes would have to be changed. *

* A better design would pass in channel (or CALL channel or non-blocking monitor) * interfaces to each of the college processes. These would merely report their identities * and states by writing to (or calling or invoking) those interfaces. To reproduce * the current display, all those interfaces would be instanced by a single any-1 * channel (or CALL channel or monitor) connected to a simple server that responds by * making System.out.println invocations appropriate to the information passed. * For other effects, connect in other servers. * Note that the college processes do not have to be connected to the same server - each * could be connected to a separate server and these servers connected into a graphics * animation network (incorporating, for example, processes from {@link org.jcsp.awt}). * The point is that the college processes would need no changing to drive whatever * was constructed. This is also left as an exercise. * *

Further Thoughts on the Canteen Design

* The decision to bind in the CALL channel (and associated inteface) definitions * as inner classes of Canteen does not fit comfortably with the above * observations. However, processes servicing Canteen.Any2OneServiceChannel * or Canteen.Any2OneSupplyChannel channels do not have to be instances of * Canteen - even though that would seem to be a little odd. * So, the College authorities still have freedom to install canteens with * behaviours quite different to that of Canteen. [Anything with the same * channel interface will fit! The interoperability of processes depends only on * the compatibility of their channel interfaces. Note that this reusability owes * nothing to the concept of inheritance - for example, the alternative canteens * pluggable into the college network need no special sub-classing relationships.] * So, if we really want to allow this flexibility, make it explicit by declaring * the CALL channels separately from any of their servers. *

* Another design choice is to burn in CALL channel instances as part of the servers * themselves. For example, the Canteen class could construct and export * its service and supply channels as public and final * fields (rather than import them via constructor parameters). In this case, * the College builder would need to declare and name the canteen * (instead of declaring and naming the channels): *

 * import org.jcsp.lang.*;
 * 
 * class College implements CSProcess {
 * 
 *   public void run () {
 * 
 *     ...  declare constants (nPhilosophers, thinkTime etc.)
 * 
 *     final Canteen canteen = new Canteen (serviceTime, supplyTime,
 *                                          maxChickens);
 * 
 *     final Phil[] phils = new Phil[nPhilosophers];
 *     for (int i = 0; i < phils.length; i++) {
 *       String philId = new Integer (i).toString ();
 *       phils[i] = new Phil (philId, canteen.service,
 *                            thinkTime, eatTime, i == 0);
 *     }
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Clock (),
 *         canteen,
 *         new Parallel (phils),
 *         new Chef ("Pierre", 4, 2000, canteen.supply),
 *         new Chef ("Henri", 10, 20000, canteen.supply),
 *         new Chef ("Sid", 100, 60000, canteen.supply)
 *       }
 *     ).run ();
 *   }
 *   ...  main
 * }
 * 
* Note that this particular burn in does not deny any flexibility to the college * in choosing any particular variety of canteen. In fact, the only thing of interest * to the college is that the canteen provides and services CALL channels whose interfaces * are what its philosophers and chefs expect (i.e. Service and Supply). * Note also that the college
network diagram has not changed. *

* Having gone this far, we may like to consider making the server self-starting * - so that its declaration not only introduces its service channels but also brings it * to life. For example, this could be done for the Canteen by adding the * following as the last line of its constructor: *

 *     new {@link ProcessManager} (this).start ();
 * 
* Of course, the canteen instance should then be removed from the {@link Parallel} * construction above. *

* [Warning: be careful if sub-classes are allowed (i.e. the Canteen class * was not declared final). In this case, the above incantation should be optional * so that each sub-class constructor can invoke a super-class constructor that omits it. * If we let the super-class fire up the process, it may start running before the sub-class * constructor finishes - i.e. before the process has been fully initialised. * It must be the sub-class constructor that self-starts the process (as the last thing * it does).] *

* [Note: a self-starting server exporting its own CALL (or ordinary) channels * for public concurrent use corresponds to the occam3 notion of a MODULE * implemented by a RESOURCE.] * * @see org.jcsp.lang.One2OneCallChannel * @see org.jcsp.lang.One2AnyCallChannel * @see org.jcsp.lang.Any2AnyCallChannel * @see org.jcsp.lang.Alternative * * @author P.H. Welch */ public abstract class Any2OneCallChannel extends AltingChannelAccept implements Serializable { /** * This is used to synchronise the calling and accepting process. */ final private Any2OneChannelImpl c = new Any2OneChannelImpl(); /** * This is used to synchronise the calling and accepting process. */ final private One2OneChannelImpl d = new One2OneChannelImpl(); /** * This holds a reference to a server process so that a client may * make the call. The reference is only valid between the {@link #join join} * and {@link #fork fork} elements of the standard * calling sequence. * As shown in that sequence, it will need casting up to the relevant interface * supported by the specific CALL channel derived from this class. */ protected CSProcess server; // made available to the caller /** * This may be set during the standard calling sequence to record * which method was invoked by a client. It is only safe to do this between * the {@link #join join} and {@link #fork fork} elements of * that sequence. Either all the CALL * channel methods should do this or none - in the latter case, its default * value remains as zero. Its value is returned to a server as the result * the server's invocation of {@link #accept accept}. */ protected int selected = 0; // set (optionally) by the caller /** * This is invoked by a server when it commits to accepting a CALL * from a client. The parameter supplied must be a reference to this server * - see the example from {@link One2OneCallChannel}. * It will not complete until a CALL has been made. If the derived CALL channel has set * the {@link #selected} field in the way defined by the standard * calling sequence, * the value returned by this method will indicate which method was called. * * @param server the server process receiving the CALL. */ public int accept(CSProcess server) { // invoked by the callee this.server = server; c.read(); // ready to ACCEPT the CALL d.read(); // wait until the CALL is complete return selected; } /** * This is invoked by a client during the standard calling * sequence. It will not complete until a server invokes * an {@link #accept accept} on this channel. In turn, that accept * will not complete until the client invokes a {@link #fork fork}, * after having made its CALL on the server. */ protected void join() { // indirectly invoked by the caller c.write(null); } /** * This is invoked by a client during the standard calling * sequence. A server must have invoked an {@link #accept accept} * for the client to have got this far in the sequence - see * the {@link #join join}. This call unblocks that accept, * releasing the server and client to resume separate lives. */ protected void fork() { // indirectly invoked by the caller d.write(null); } /** * This is one of the {@link Guard} methods needed by the {@link Alternative} class. */ boolean enable(Alternative alt) { // ignore this! return c.readerEnable(alt); } /** * This is one of the {@link Guard} methods needed by the {@link Alternative} class. */ boolean disable() { // ignore this! return c.readerDisable(); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SpuriousLog.java0000644000000000000000000003377111105701167017233 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This holds the log of spurious wakeups and early timeouts. *

Description

* The java.lang.Object.wait method sometimes returns spuriously * - i.e. without being notify'd by another thread or interrupted * or timed-out! This class is an optional (static) repository holding and reporting * counts of any such spurious wakeups. JCSP handles all spurious wakeups cleanly. *

* Some JVMs also timeout on calls of wait(timeout) early. This class * enables the specification of how early will be acceptable to JCSP. * ``Timeouts'' returned earlier than the set threshold are treated as * spurious wakeups (i.e. the process is put back to sleep). * Provision is also made for counting and reporting the accepted early timeouts. *

* To operate, this logging must first be switched on ({@link #start}). * * @author P.H. Welch */ //}}} public class SpuriousLog { /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int One2OneChannelIntRead = 0; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int One2OneChannelIntWrite = 1; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int One2OneChannelIntXRead = 2; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int One2OneChannelIntXWrite = 3; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int One2OneChannelRead = 4; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int One2OneChannelWrite = 5; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int One2OneChannelXRead = 6; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int One2OneChannelXWrite = 7; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int Any2OneChannelIntRead = 8; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int Any2OneChannelIntWrite = 9; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int Any2OneChannelIntXRead = 10; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int Any2OneChannelIntXWrite = 11; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int Any2OneChannelRead = 12; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int Any2OneChannelWrite = 13; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int Any2OneChannelXRead = 14; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int Any2OneChannelXWrite = 15; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int One2AnyChannelIntRead = 16; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int One2AnyChannelIntWrite = 17; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int One2AnyChannelIntXRead = 18; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int One2AnyChannelIntXWrite = 19; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int One2AnyChannelRead = 20; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int One2AnyChannelWrite = 21; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int One2AnyChannelXRead = 22; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int One2AnyChannelXWrite = 23; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int Any2AnyChannelIntRead = 24; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int Any2AnyChannelIntWrite = 25; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int Any2AnyChannelIntXRead = 26; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int Any2AnyChannelIntXWrite = 27; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int Any2AnyChannelRead = 28; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int Any2AnyChannelWrite = 29; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int Any2AnyChannelXRead = 30; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int Any2AnyChannelXWrite = 31; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int AlternativeSelect = 32; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int AlternativeSelectWithTimeout = 33; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. */ static public final int BarrierSync = 34; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int BucketFallInto = 35; /** * This indexes the counts of spurious wakeups * ({@link #getSpuriousWakeUpCounts()}), * indicating the class and operation that suffered. *

* Note: this field is not operative in the current JCSP release. * Spurious wakeups on AltingBarriers are handled correctly * -- just not recorded. *

*/ static public final int AltingBarrierCoordinateStartEnable = 36; /** * This indexes the counts of spurious wakeups * ({@link #report()}), * indicating the class and operation that suffered. */ static public final int StopRun = 37; static private final int nSpuriousWakeUpPlaces = 38; static private int[] count = new int[nSpuriousWakeUpPlaces]; static private int nSpuriousWakeUps = 0; static private int nEarlyTimeouts = 0; /** * Start logging of spurious wakeups. * This should be set before any concurrency is started. * It should only be set once. * There is no concurrency protection! */ static synchronized public void start () { Spurious.logging = true; } /** * Finish logging of spurious wakeups. * This should be set after any concurrency has finished. * There is no concurrency protection! */ static synchronized public void finish () { Spurious.logging = false; } /** * Returns the number of spurious wakeups so far. * * @return the number of spurious wakeups so far. */ static synchronized public int numberSpuriousWakeUps () { return nSpuriousWakeUps; } /** * Returns the counts of spurious wakeups so far. This array is indexed * by the public constants in this class. Only a clone is returned. * * @return the counts of spurious wakeups so far. */ static synchronized public int[] getSpuriousWakeUpCounts () { return (int[]) count.clone (); } /** * Increment spurious wakeup counts. * * @param x the operation that suffered the spurious wakeup. */ static synchronized void record (int x) { nSpuriousWakeUps++; count[x]++; } /** * This sets the allowed early timeout (in msecs). Some JVMs timeout * on calls of wait(timeout) early - this specifies how early * JCSP will tolerate. ``Timeouts'' returned earlier than the set * threshold are treated as spurious wakeups (i.e. the process * is put back to sleep). *

* This should be set before any concurrency is started. * It should only be set once. * There is no concurrency protection! * * @param earlyTimeout the allowed early timeout (in msecs). */ static synchronized public void setEarlyTimeout (long earlyTimeout) { if (earlyTimeout >= 0) { Spurious.earlyTimeout = earlyTimeout; } else { throw new IllegalArgumentException ( "Attempt to set a negative early timeout value\n" ); } } /** * This returns the allowed early timeout (in msecs). * * @return the allowed early timeout (in msecs). */ static synchronized public long getEarlyTimeout () { return Spurious.earlyTimeout; } /** * Returns the number of early timeouts accepted so far. * * @return the number of early timeouts accepted so far. */ static synchronized public int numberEarlyTimeouts () { return nEarlyTimeouts; } /** * Increment the count of early timeouts. */ static synchronized void incEarlyTimeouts () { nEarlyTimeouts++; } /** * This returns a report on the counts of spurious wakeups and early timeouts * so far. A breakdown of spurious wakeup counts is given only if there are some. * * @return the report. */ static synchronized public String report () { String result = "\n>>>>>> Spurious WakeUps: " + nSpuriousWakeUps; if (nSpuriousWakeUps > 0) { for (int i = 0; i < nSpuriousWakeUpPlaces; i++) { if ((i % 10) == 0) { result = result + "\n"; } result = result + " " + i + ":" + count[i]; } } result = result +"\n>>>>>> Early Timeouts: " + nEarlyTimeouts; return result; } private SpuriousLog () { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelAccept.java0000644000000000000000000000656211105701167017426 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for accepting CALL channels. *

Description

* ChannelAccept defines the interface for accepting CALL channels. * The interface contains only one method - {@link #accept accept}. * *

Example

* See the explanations and examples documented in the CALL channel super-classes * (listed below). * * @see org.jcsp.lang.One2OneCallChannel * @see org.jcsp.lang.Any2OneCallChannel * @see org.jcsp.lang.One2AnyCallChannel * @see org.jcsp.lang.Any2AnyCallChannel * * @author P.H. Welch */ public interface ChannelAccept { /** * This is invoked by a server when it commits to accepting a CALL * from a client. The parameter supplied must be a reference to this server * - see the example from {@link One2OneCallChannel}. * It will not complete until a CALL has been made. If the derived CALL channel has set * the selected field in the way defined by the standard * calling sequence, * the value returned by this method will indicate which method was called. * * @param server the server process receiving the CALL. */ public int accept(CSProcess server); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedOne2AnyChannel.java0000644000000000000000000001175111105701167021141 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.*; /** * This implements an any-to-any object channel with user-definable buffering, * safe for use by many writers and many readers. *

Description

* BufferedOne2AnyChannel implements a one-to-any object channel with * user-definable buffering. It is safe for use by any number of reading * processes but ony one writer. Reading processes compete with each other * to use the channel. Only one reader and the writer will actually be using * the channel at any one time. This is taken care of by * BufferedOne2AnyChannel -- user processes just read from or write to it. *

* Please note that this is a safely shared channel and not * a multicaster. Currently, multicasting has to be managed by * writing active processes (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example of broadcasting). *

* All reading processes and writing processes commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ChannelDataStore ChannelDataStore} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * *

Implementation Note and Caution

* Fair servicing of readers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * 1-any channels. * * @see org.jcsp.lang.BufferedOne2OneChannel * @see org.jcsp.lang.BufferedOne2AnyChannel * @see org.jcsp.lang.BufferedAny2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin * @author P.H. Welch */ class BufferedOne2AnyChannel extends One2AnyImpl { /** * Constructs a new BufferedOne2AnyChannel with the specified ChannelDataStore. * * @param data The ChannelDataStore used to store the data for the channel */ public BufferedOne2AnyChannel(ChannelDataStore data) { super(new BufferedOne2OneChannel(data)); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AbstractConnectionImpl.java0000644000000000000000000000515111105701167021334 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * @author Jo Aldous */ abstract class AbstractConnectionImpl { protected static final int CLIENT_STATE_CLOSED = 1; protected static final int CLIENT_STATE_OPEN = 2; protected static final int CLIENT_STATE_MADE_REQ = 3; protected static final int SERVER_STATE_CLOSED = 1; protected static final int SERVER_STATE_OPEN = 2; protected static final int SERVER_STATE_RECEIVED = 3; protected static final NonSingleRequestOpenMsg nonSingleRequestMsg = new NonSingleRequestOpenMsg(); static class NonSingleRequestOpenMsg { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Connection.java0000644000000000000000000002026311105701167017027 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This class provides static factory methods for constructing * different types of connection. The methods are equivalent to * the non-static methods of the StandardConnectionFactory * class. * * @author Quickstone Technologies Limited */ public class Connection { private static StandardConnectionFactory factory = new StandardConnectionFactory(); /** * Constructor for Connection. */ private Connection() { super(); } /** * @see org.jcsp.lang.ConnectionFactory#createOne2One() */ public static One2OneConnection createOne2One() { return factory.createOne2One(); } /** * @see org.jcsp.lang.ConnectionFactory#createAny2One() */ public static Any2OneConnection createAny2One() { return factory.createAny2One(); } /** * @see org.jcsp.lang.ConnectionFactory#createOne2Any() */ public static One2AnyConnection createOne2Any() { return factory.createOne2Any(); } /** * @see org.jcsp.lang.ConnectionFactory#createAny2Any() */ public static Any2AnyConnection createAny2Any() { return factory.createAny2Any(); } /** * @see org.jcsp.lang.ConnectionArrayFactory#createOne2One(int) */ public static One2OneConnection[] createOne2One(int n) { return factory.createOne2One(n); } /** * @see org.jcsp.lang.ConnectionArrayFactory#createAny2One(int) */ public static Any2OneConnection[] any2oneArray(int n) { return factory.createAny2One(n); } /** * @see org.jcsp.lang.ConnectionArrayFactory#createOne2Any(int) */ public static One2AnyConnection[] createOne2Any(int n) { return factory.createOne2Any(n); } /** * @see org.jcsp.lang.ConnectionArrayFactory#createAny2Any(int) */ public static Any2AnyConnection[] createAny2Any(int n) { return factory.createAny2Any(n); } /** * Returns an array of client connection ends suitable for use as guards in an Alternative * construct. * * @param c the connection array to get the client ends from. * @return the array of client ends. */ public static AltingConnectionClient[] getClientArray(One2AnyConnection[] c) { AltingConnectionClient r[] = new AltingConnectionClient[c.length]; for (int i = 0; i < c.length; i++) r[i] = c[i].client(); return r; } /** * Returns an array of client connection ends suitable for use as guards in an Alternative * construct. * * @param c the connection array to get the client ends from. * @return the array of client ends. */ public static AltingConnectionClient[] getClientArray(One2OneConnection[] c) { AltingConnectionClient r[] = new AltingConnectionClient[c.length]; for (int i = 0; i < c.length; i++) r[i] = c[i].client(); return r; } /** * Returns an array of client connection ends suitable for use by multiple concurrent * processes. * * @param c the connection array to get the client ends from. * @return the array of client ends. */ public static SharedConnectionClient[] getClientArray(Any2AnyConnection[] c) { SharedConnectionClient r[] = new SharedConnectionClient[c.length]; for (int i = 0; i < c.length; i++) r[i] = c[i].client(); return r; } /** * Returns an array of client connection ends suitable for use by multiple concurrent * processes. * * @param c the connection array to get the client ends from. * @return the array of client ends. */ public static SharedConnectionClient[] getClientArray(Any2OneConnection[] c) { SharedConnectionClient r[] = new SharedConnectionClient[c.length]; for (int i = 0; i < c.length; i++) r[i] = c[i].client(); return r; } /** * Returns an array of server connection ends suitable for use as guards in an Alternative * construct. * * @param c the connection array to get the server ends from. * @return the array of server ends. */ public static AltingConnectionServer[] getServerArray(Any2OneConnection[] c) { AltingConnectionServer r[] = new AltingConnectionServer[c.length]; for (int i = 0; i < c.length; i++) r[i] = c[i].server(); return r; } /** * Returns an array of server connection ends suitable for use as guards in an Alternative * construct. * * @param c the connection array to get the server ends from. * @return the array of server ends. */ public static AltingConnectionServer[] getServerArray(One2OneConnection[] c) { AltingConnectionServer r[] = new AltingConnectionServer[c.length]; for (int i = 0; i < c.length; i++) r[i] = c[i].server(); return r; } /** * Returns an array of server connection ends suitable for use by multiple concurrent * processes. * * @param c the connection array to get the server ends from. * @return the array of server ends. */ public static SharedConnectionServer[] getServerArray(Any2AnyConnection[] c) { SharedConnectionServer r[] = new SharedConnectionServer[c.length]; for (int i = 0; i < c.length; i++) r[i] = c[i].server(); return r; } /** * Returns an array of server connection ends suitable for use by multiple concurrent * processes. * * @param c the connection array to get the server ends from. * @return the array of server ends. */ public static SharedConnectionServer[] getServerArray(One2AnyConnection[] c) { SharedConnectionServer r[] = new SharedConnectionServer[c.length]; for (int i = 0; i < c.length; i++) r[i] = c[i].server(); return r; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneConnectionImpl.java0000644000000000000000000001046211105701167021037 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.Buffer; /** * This class is an implementation of One2OneConnection. * Each end is safe to be used by one thread at a time. * * @author Quickstone Technologies Limited */ class One2OneConnectionImpl extends AbstractConnectionImpl implements One2OneConnection { private AltingConnectionClient client; private AltingConnectionServer server; /** * Initializes all the attributes to necessary values. * Channels are created using the static factory in the * ChannelServer inteface. * * Constructor for One2OneConnectionImpl. */ public One2OneConnectionImpl() { super(); One2OneChannel chanToServer = ConnectionServer.FACTORY.createOne2One(new Buffer(1)); One2OneChannel chanFromServer = ConnectionServer.FACTORY.createOne2One(new Buffer(1)); //create the client and server objects client = new AltingConnectionClientImpl(chanFromServer.in(), chanToServer.out(), chanToServer.out(), chanFromServer.out()); server = new AltingConnectionServerImpl(chanToServer.in(), chanToServer.in()); } /** * Returns the AltingConnectionClient that can * be used by a single process at any instance. * * This method will always return the same * AltingConnectionClient object. * One2OneConnection is only intendended to have two ends. * * @return the AltingConnectionClient object. */ public AltingConnectionClient client() { return client; } /** * Returns the AltingConnectionServer that can * be used by a single process at any instance. * * This method will always return the same * AltingConnectionServer object. * One2OneConnection is only intendended to have two ends. * * @return the AltingConnectionServer object. */ public AltingConnectionServer server() { return server; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ConnectionClientMessage.java0000644000000000000000000000430611105701167021473 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * @author Quickstone Technologies Limited */ class ConnectionClientMessage implements Serializable { Object data; } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedChannelInputImpl.java0000644000000000000000000000477111113671251021276 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class SharedChannelInputImpl implements SharedChannelInput { private ChannelInternals channel; private int immunity; SharedChannelInputImpl(ChannelInternals _channel, int _immunity) { channel = _channel; immunity = _immunity; } public void endRead() { channel.endRead(); } public Object read() { return channel.read(); } public Object startRead() { return channel.startRead(); } public void poison(int strength) { if (strength > immunity) { channel.readerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingBarrierError.java0000644000000000000000000000564711105701167020500 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This is thrown for an illegal operation on an {@link AltingBarrier}. * *

Description

* Currently, there are the following causes: *
    *
  • * different threads trying to operate on the same front-end; *
  • * attempt to use as a {@link Guard} whilst resigned; *
  • * attempt to {@link AltingBarrier#sync sync} whilst resigned; *
  • * attempt to {@link AltingBarrier#resign resign} whilst resigned; *
  • * attempt to {@link AltingBarrier#enroll enroll} whilst enrolled; *
  • * attempt to {@link AltingBarrier#expand expand} whilst resigned; *
  • * attempt to {@link AltingBarrier#contract contract} whilst resigned; *
  • * attempt to {@link AltingBarrier#contract contract} with an array * of front-ends not supplied by {@link AltingBarrier#expand expand}; *
  • * attempt to {@link AltingBarrier#mark mark} whilst resigned (caused * by a process transfering a front-end in that state). *
* * @author P.H. Welch */ //}}} public class AltingBarrierError extends Error { public AltingBarrierError (String s) { super (s); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingChannelInputWrapper.java0000644000000000000000000001355611113671251022026 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This class wraps an ALTable channel so that only the reading part is * available to the caller. Writes are impossible unless you subclass * this (and use getChannel()) or keep a reference to the original * channel.

* * @deprecated There is no longer any need to use this class, after the 1.1 class reorganisation. * * Note that usually you do not need the absolute guarantee that this class * provides - you can usually just cast the channel to an AltingChannelInput, * which prevents you from accidentally writing to the channel. This * class mainly exists for use by some of the org.jcsp.net classes, where the * absolute guarantee that you cannot write to it is important. * * @see org.jcsp.lang.AltingChannelInput * * @author Quickstone Technologies Limited */ public class AltingChannelInputWrapper extends AltingChannelInput { /** * Creates a new AltingChannelInputWrapper which wraps the specified * channel. */ public AltingChannelInputWrapper(AltingChannelInput channel) { this.channel = channel; } /** * This constructor does not wrap a channel. * The underlying channel can be set by calling * setChannel(AltingChannelInput). * */ protected AltingChannelInputWrapper() { this.channel = null; } /** * The real channel which this object wraps. * * This used to be a final field but this caused problems * when sub-classes wanted to be serializable. Added a * protected mutator. */ private AltingChannelInput channel; /** * Get the real channel. * * @return The real channel. */ protected AltingChannelInput getChannel() { return channel; } /** * Sets the real channel to be used. * * @param chan the real channel to be used. */ protected void setChannel(AltingChannelInput chan) { this.channel = chan; } /** * Read an Object from the channel. * * @return the object read from the channel */ public Object read() { return channel.read(); } /** * Begins an extended rendezvous * * @see ChannelInput.startRead * @return The object read from the channel */ public Object startRead() { return channel.startRead(); } /** * Ends an extended rendezvous * * @see ChannelInput.endRead */ public void endRead() { channel.endRead(); } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. * * @return state of the channel. */ public boolean pending() { return channel.pending(); } /** * Returns true if the event is ready. Otherwise, this enables the guard * for selection and returns false. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class that is controlling the selection * @return true if and only if the event is ready */ boolean enable(Alternative alt) { return channel.enable(alt); } /** * Disables the guard for selection. Returns true if the event was ready. *

* Note: this method should only be called by the Alternative class * * @return true if and only if the event was ready */ boolean disable() { return channel.disable(); } public void poison(int strength) { channel.poison(strength); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyChannelImpl.java0000644000000000000000000001117311105701167020316 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This implements a one-to-any object channel, * safe for use by one writer and many readers. *

Description

* One2AnyChannel is an implementation of a channel which is safe * for use by many reading processes but only one writer. Reading processes * compete with each other to use the channel. Only one reader and the writer will * actually be using the channel at any one time. This is taken care of by * One2AnyChannel -- user processes just read from or write to it. *

* Please note that this is a safely shared channel and not * a broadcaster. Currently, broadcasting has to be managed by * writing active processes (see {@link org.jcsp.plugNplay.DynamicDelta} * for an example). *

* All reading processes and the writing process commit to the channel * (i.e. may not back off). This means that the reading processes * may not {@link Alternative ALT} on this channel. *

* The default semantics of the channel is that of CSP -- i.e. it is * zero-buffered and fully synchronised. A reading process must wait * for the matching writer and vice-versa. *

* A factory pattern is used to create channel instances. The create methods of {@link Channel} * allow creation of channels, arrays of channels and channels with varying semantics such as * buffering with a user-defined capacity or overwriting with various policies. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * *

Implementation Note and Caution

* Fair servicing of readers to this channel depends on the fair * servicing of requests to enter a synchronized block (or method) by * the underlying Java Virtual Machine (JVM). Java does not specify how threads * waiting to synchronize should be handled. Currently, Sun's standard JDKs queue * these requests - which is fair. However, there is at least one JVM * that puts such competing requests on a stack - which is legal but unfair * and can lead to infinite starvation. This is a problem for any Java system * relying on good behaviour from synchronized, not just for these * 1-any channels. * * @see org.jcsp.lang.One2OneChannel * @see org.jcsp.lang.Any2OneChannel * @see org.jcsp.lang.Any2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin and P.H. Welch */ class One2AnyChannelImpl extends One2AnyImpl { One2AnyChannelImpl() { super(new One2OneChannelImpl()); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/AltingBarrierBase.java0000644000000000000000000002335511105701167020255 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; class AltingBarrierBase { // package-only visible class /** * All front-ends are chained off here. Each process enrolled must have one, * and only one, of these. */ private AltingBarrier frontEnds = null; /** The number of processes enrolled. */ private int enrolled = 0; /** The number of processes not yet offered to sync on this barrier. */ private int countdown = 0; /* * This creates, and returns, more front-ends to be held by newly enrolling * processes. Initially, none exist - so this * (or {@link #expand()}) must be called at least once. *

* Note: except for the first time, this method should only be called by * an AltingBarrier synchronised on this AltingBarrierBase. *

* * @param n the number of front-ends to be created. *

* * @return the new front-ends. * */ AltingBarrier[] expand (int n) { AltingBarrier[] ab = new AltingBarrier[n]; for (int i = 0; i < n; i++) { frontEnds = new AltingBarrier (this, frontEnds); ab[i] = frontEnds; } enrolled += n; countdown += n; return ab; } /* * This creates, and returns, another front-end to be held by a newly enrolling * process. Initially, none exist - so this * (or {@link #expand(int)}) must be called at least once. *

* Note: except for the first time, this method should only be called by * an AltingBarrier synchronised on this AltingBarrierBase. *

* * @return the new front-ends. * */ AltingBarrier expand () { enrolled++; countdown++; frontEnds = new AltingBarrier (this, frontEnds); return frontEnds; } /** * This removes the given front-ends chained to this alting barrier. * It also nulls all of them - to prevent any attempted reuse! *

* Note: this method should only be called by an AltingBarrier synchronised * on this AltingBarrierBase. *

* * @param ab the front-ends being discarded from this barrier. * This array must be unaltered from one previously delivered by * an {@link #expand expand}. */ void contract (AltingBarrier[] ab) { // assume: (ab != null) && (ab.length > 0) AltingBarrier first = ab[0]; // counts the number of front-ends whose (hopefully terminated) processes // were still enrolled. int discard = 0; AltingBarrier fa = null; AltingBarrier fb = frontEnds; while ((fb != null) && (fb != first)) { fa = fb; fb = fb.next; } if (fb == null) { throw new AltingBarrierError ( "\n*** Could not find first front-end in AltingBarrier contract." ); } // Below, we will null elements of "ab" as we pass though the array. // However, the formal "deduce" and "invariant" comments that follow // relate to code that does not do this. This is safe since the logic // of the code does not depend on values of "ab", subsequent to their // anullment. ab[0].base = null; ab[0] = null; // deduce: (fb == ab[0]) && (fb != null) // deduce: (fa == null) || (fa.next == fb) // deduce: (fa == null) <==> (frontEnds == ab[0]) // deduce: (fa != null) <==> (fa.next == ab[0]) for (int i = 1; i < ab.length; i++) { // invariant: (fb == ab[i-1]) && (fb != null) if (fb.enrolled) discard++; fb = fb.next; if (fb == null) { throw new AltingBarrierError ( "\n*** Could not find second (or later) front-end in AltingBarrier contract." ); } if (fb != ab[i]) { throw new AltingBarrierError ( "\n*** Removal array in AltingBarrier contract not one delivered by expand." ); } // deduce: (fb == ab[i]) && (fb != null) ab[i].base = null; ab[i] = null; } // deduce: (fb == ab[(ab.length) - 1]) && (fb != null) if (fb.enrolled) discard++; // deduce: (fa == null) <==> (frontEnds == ab[0]) [NO CHANGE] // deduce: (fa != null) <==> (fa.next == ab[0]) [NO CHANGE] if (fa == null) { frontEnds = fb.next; } else { fa.next = fb.next; } enrolled -= discard; countdown -= discard; if (countdown == 0) { countdown = enrolled; if (enrolled > 0) { AltingBarrierCoordinate.startEnable (); AltingBarrierCoordinate.startDisable (enrolled); AltingBarrier fe = frontEnds; while (fe != null) { fe.schedule (); fe = fe.next; } } } else if (countdown < 0) { throw new JCSP_InternalError ( "Please report the circumstances to jcsp-team@kent.ac.uk - thanks!" ); } } /** * This removes the given front-end chained to this alting barrier. * It also nulls its reference to this base - to prevent any attempted reuse! *

* Note: this method should only be called by an AltingBarrier synchronised * on this AltingBarrierBase. *

* * @param ab the front-end being discarded from this barrier. * This array must be unaltered from one previously delivered by * an {@link #expand expand}. */ void contract (AltingBarrier ab) { // assume: (ab != null) AltingBarrier fa = null; AltingBarrier fb = frontEnds; while ((fb != null) && (fb != ab)) { fa = fb; fb = fb.next; } if (fb == null) { throw new AltingBarrierError ( "\n*** Could not find front-end in AltingBarrier contract." ); } // deduce: (fb == ab) && (fb != null) // deduce: (fa == null) || (fa.next == fb) // deduce: (fa == null) <==> (frontEnds == ab) // deduce: (fa != null) <==> (fa.next == ab) if (fa == null) { frontEnds = fb.next; } else { fa.next = fb.next; } ab.base = null; if (ab.enrolled) { enrolled--; countdown--; } if (countdown == 0) { countdown = enrolled; if (enrolled > 0) { AltingBarrierCoordinate.startEnable (); AltingBarrierCoordinate.startDisable (enrolled); AltingBarrier fe = frontEnds; while (fe != null) { fe.schedule (); fe = fe.next; } } } else if (countdown < 0) { throw new JCSP_InternalError ( "Please report the circumstances to jcsp-team@kent.ac.uk - thanks!" ); } } /** * Record the offer to synchronise. *

* Note: this method should only be called by an AltingBarrier synchronised * on this AltingBarrierBase. *

* * @return true if all the offers are in. */ boolean enable () { countdown--; if (countdown == 0) { countdown = enrolled; AltingBarrierCoordinate.startDisable (enrolled); AltingBarrier fe = frontEnds; while (fe != null) { fe.schedule (); fe = fe.next; } return true; } else { return false; } } /** * Withdraw the offer to synchronise. *

* Note: this method should only be called by an AltingBarrier synchronised * on this AltingBarrierBase. *

* * @return true all the offers are in. */ boolean disable () { if (countdown == enrolled) { return true; } else { countdown++; return false; } } /** * Record resignation. *

* Note: this method should only be called by an AltingBarrier synchronised * on this AltingBarrierBase. *

*/ void resign () { enrolled--; countdown--; if (countdown == 0) { countdown = enrolled; if (enrolled > 0) { AltingBarrierCoordinate.startEnable (); AltingBarrierCoordinate.startDisable (enrolled); AltingBarrier fe = frontEnds; while (fe != null) { fe.schedule (); fe = fe.next; } } } } /** * Record re-enrollment. *

* Note: this method should only be called by an AltingBarrier synchronised * on this AltingBarrierBase. */ void enroll () { enrolled++; countdown++; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ParThread.java0000644000000000000000000001127711105701167016607 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is the Thread class used by {@link Parallel} to run all but * one of its given processes. * *

Description

* A ParThread is a Thread used by {@link Parallel} to run * all but one of its given processes. *

* The CSProcess to be executed can be changed using the * setProcess method providing the ParThread is not active. * * @see org.jcsp.lang.CSProcess * @see org.jcsp.lang.ProcessManager * @see org.jcsp.lang.Parallel * * @author P.D. Austin * @author P.H. Welch */ //}}} class ParThread extends Thread { /** the process to be executed */ private CSProcess process; /** the barrier at the end of a PAR */ private Barrier barrier; private boolean running = true; /** parking barrier for this thread */ private Barrier park = new Barrier(2); /** * Construct a new ParThread. * * @param process the process to be executed * @param barrier the barrier for then end of the PAR */ public ParThread(CSProcess process, Barrier barrier) { setDaemon(true); this.process = process; this.barrier = barrier; setName(process.toString()); } /** * reset the ParThread. * * @param process the process to be executed * @param barrier the barrier for then end of the PAR */ public void reset(CSProcess process, Barrier barrier) { this.process = process; this.barrier = barrier; setName(process.toString()); } /** * Sets the ParThread to terminate next time it's unparked. * */ public void terminate() { running = false; park.sync(); } /** * Releases the ParThread to do some more work. */ public void release() { park.sync(); } /** * The main body of this process. * above. */ public void run() { try { Parallel.addToAllParThreads(this); while (running) { try { process.run(); } catch (Throwable e) { Parallel.uncaughtException("org.jcsp.lang.Parallel", e); } barrier.resign(); park.sync(); } } catch (Throwable t) { Parallel.uncaughtException("org.jcsp.lang.Parallel", t); } finally { Parallel.removeFromAllParThreads(this); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/SharedChannelInputInt.java0000644000000000000000000000473611113671251021130 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is the same as {@link ChannelInputInt} except that it is guaranteed * safe to pass on to more than one internal process for parallel reading. *

* A reading-end, obtained from a one-any or any-any * channel by invoking its in() method, will implement this interface. * * @author Quickstone Technologies Limited */ public interface SharedChannelInputInt extends ChannelInputInt { } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelOutputImpl.java0000644000000000000000000000457511113671251020352 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class ChannelOutputImpl implements ChannelOutput { private ChannelInternals channel; private int immunity; ChannelOutputImpl(ChannelInternals _channel, int _immunity) { channel = _channel; immunity = _immunity; } public void write(Object object) { channel.write(object); } public void poison(int strength) { if (strength > immunity) { channel.writerPoison(strength); } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/CrewServer.java0000644000000000000000000001254511105701167017023 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * @author P.H. Welch */ class CrewServer implements CSProcess { public static final int READER = 0; public static final int WRITER = 1; private final AltingChannelInputInt request; private final AltingChannelInputInt writerControl; private final AltingChannelInputInt readerRelease; ///TODO change this to use poisoning of the above channels, once poison is added private final AltingChannelInputInt poison; public CrewServer(final AltingChannelInputInt request, final AltingChannelInputInt writerControl, final AltingChannelInputInt readerRelease, final AltingChannelInputInt poison) { this.request = request; this.writerControl = writerControl; this.readerRelease = readerRelease; this.poison = poison; } public void run() { int nReaders = 0; final Alternative altMain = new Alternative(new Guard[] {readerRelease, request, poison}); final int MAIN_READER_RELEASE = 0; final int MAIN_REQUEST = 1; final int MAIN_POISON = 2; final Alternative altWriteComplete = new Alternative(new Guard[] {writerControl, poison}); final int WC_WRITER_CONTROL = 0; final int WC_POISON = 1; final Alternative altReadComplete = new Alternative(new Guard[] {readerRelease, poison}); final int RC_READER_RELEASE = 0; final int RC_POISON = 1; while (true) { // invariant : (nReaders is the number of current readers) and (there are no writers) switch (altMain.priSelect()) { case MAIN_READER_RELEASE: readerRelease.read(); nReaders--; break; case MAIN_REQUEST: switch (request.read()) { case READER: nReaders++; break; case WRITER: int n = nReaders; // tmp for (int i = 0; i < n; i++) { switch (altReadComplete.priSelect()) { case RC_READER_RELEASE: readerRelease.read(); nReaders--; // tmp break; case RC_POISON: poison.read(); // let the finalizer complete return; } } nReaders = 0; writerControl.read(); // let writer start writing switch (altWriteComplete.priSelect()) { case WC_WRITER_CONTROL: writerControl.read(); // let writer finish writing break; case WC_POISON: poison.read(); // let the finalizer complete return; } break; } break; case MAIN_POISON: poison.read(); // let the finalizer complete return; } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneChannel.java0000644000000000000000000001110511113671251017460 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for a one-to-one Object channel. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Channels may be {@link Channel#one2one() synchronising}, * {@link Channel#one2one(org.jcsp.util.ChannelDataStore) buffered}, * {@link Channel#one2one(int) poisonable} * or {@link Channel#one2one(org.jcsp.util.ChannelDataStore,int) both} * (i.e. buffered and poisonable). *

*

*

Description

* One2OneChannelImpl is an interface for a one-to-one object channel. Multiple * readers or multiple writers are not allowed – these are catered for * by {@link Any2OneChannel}, * {@link One2AnyChannel} or * {@link Any2AnyChannel}. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

*

* The default semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

*

* The static methods of {@link Channel} construct channels with * either the default semantics or with buffering to user-specified capacity * and a range of blocking/overwriting policies. * Various buffering plugins are given in the org.jcsp.util package, but * careful users may write their own. *

* The {@link Channel} methods also provide for the construction of * {@link Poisonable} channels and for arrays of channels. *

* * @see org.jcsp.lang.Channel * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.Any2OneChannel * @see org.jcsp.lang.One2AnyChannel * @see org.jcsp.lang.Any2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin * @author P.H. Welch */ public interface One2OneChannel { /** * Returns the input channel end. */ public AltingChannelInput in(); /** * Returns the output channel end. */ public ChannelOutput out(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelFactory.java0000644000000000000000000000570511105701167017634 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for a factory to create instances of channels. * * @author Quickstone Technologies Limited * * @deprecated These channel factories are deprecated in favour of the new one2one() methods in the Channel class. */ public interface ChannelFactory { /** * Creates a new One2One channel. * * @return the created channel. */ public One2OneChannel createOne2One(); /** * Creates a new Any2One channel. * * @return the created channel. */ public Any2OneChannel createAny2One(); /** * Creates a new One2Any channel. * * @return the created channel. */ public One2AnyChannel createOne2Any(); /** * Creates a new Any2Any channel. * * @return the created channel. */ public Any2AnyChannel createAny2Any(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2OneChannelSymmetric.java0000644000000000000000000000765611113671251021375 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This defines the interface for a symmetric one-to-one Object channel. * The symmetry relates to the use of its channel ends as {@link Guard guards} * in an {@link Alternative}: both ends may be so used. *

* The only methods provided are to obtain the ends of the channel, * through which all reading and writing operations are done. * Only an appropriate channel-end should be plugged into a process * – not the whole channel. * A process may use its external channels in one direction only * – either for writing or reading. *

*

Actual channels conforming to this interface are made using the relevant * static construction methods from {@link Channel}. * Only fully {@link Channel#one2oneSymmetric() synchronising} channels are currently supported. *

*

Description

* One2OneChannelImpl is an interface for a symmetric one-to-one Object channel. * Multiple readers or multiple writers are not allowed. *

* Both the reading and writing processes may {@link Alternative ALT} on this channel. *

*

* The semantics of the channel is that of CSP – i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

*

* These channels may be constructed by the {@link Channel#one2oneSymmetric()}. * Channel poisoning and buffering are not currently supported for these channels. *

* * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.One2OneChannel * * @author P.H. Welch * @author N.C.C. Brown */ public interface One2OneChannelSymmetric { /** * Returns the input channel end. */ public AltingChannelInput in (); /** * Returns the output channel end. */ public AltingChannelOutput out (); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Parallel.java0000644000000000000000000007360311105701167016472 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.util.*; /** * This process constructor taks an array of CSProcesses * and returns a CSProcess that is the parallel composition of * its process arguments. *

* Shortcut to the Constructor and Method Summaries. *

Description

* The Parallel constructor taks an array of CSProcesses * and returns a CSProcess that is the parallel composition of * its process arguments. A run of a Parallel process * terminates when, and only when, all its component processes terminate. *

* Note: for those familiar with the occam multiprocessing * language, the Parallel class gives the semantics of the * PAR construct. However, none of the parallel usage * checks mandated by occam can be made by the Java compiler, * so we need to exercise that care ourselves. * For instance, do not try to run the same process instance more than once * in parallel and, generally, watch out for accidentally shared objects! * Running different instances of the same process in parallel * is, of course, allowed. *

* CSProcesses can be added to a Parallel object either via * the {@link #Parallel(CSProcess[]) constructor} or the {@link #addProcess addProcess} methods. * If a call to addProcess is made while the run method is executing, * the extra process(es) will not be included in the network until the next time * run is invoked. *

* CSProcesses can be removed from a Parallel object * via the {@link #removeProcess removeProcess} or * {@link #removeAllProcesses removeAllProcesses} method. * If a call to removeProcess or removeAllProcesses * is made while the run method is executing, the process will * not be removed from the network until the next time run is * invoked. *

* Note: to add/remove a process to/from a network whilst it is running, * see the {@link ProcessManager} class. *

*

Example

* The following examples demonstrate high and low level use of Parallel. *

High Level

* This high-level example sets up a communicating network * of (in this case non-terminating) processes. Data-flow diagrams are a great help * for designing, understanding and maintaining such parallel systems: *

* Here is the JCSP code: *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * class ParaplexIntTest {
 * 
 *   public static void main (String[] args) {
 * 
 *     final One2OneChannelInt[] a = Channel.one2oneIntArray (3);
 *     final One2OneChannel b = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a[0].out ()),
 *         new SquaresInt (a[1].out ()),
 *         new FibonacciInt (a[2].out ()),
 *         new ParaplexInt (ChannelInt.getInputArray (a), b.out ()),
 *         new CSProcess () {
 *           public void run () {
 *             System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n");
 *             while (true) {
 *               int[] data = (int[]) b.in ().read ();
 *               for (int i = 0; i < data.length; i++) {
 *                 System.out.print ("\t\t" + data[i]);
 *               }
 *               System.out.println ();
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* This example tabulates columns of (respectively) natural numbers, perfect * squares and the Fibonacci sequence. At this level, we are only aware of * five communicating processes: three that generate the respective sequences * of integers, one that multiplexes a single item from each sequence into * a single packet and the in-lined process that receives this packet * and tabulates its contents. And, at this level, that is all we need to think * about. *

* However, clicking on any of the generator processes reveals sub-networks * (and, in the case of {@link org.jcsp.plugNplay.ints.SquaresInt} and * {@link org.jcsp.plugNplay.ints.FibonacciInt}, sub-sub-networks). * Altogether, the example contains 28 parallel processes -- 18 of them * high-level (and non-terminating) and 10 low-level * (and transient, but repeatedly re-invoked). One of the key benefits of CSP is that * its semantics are compositional -- i.e. we do not have to reason about * all those 28 processes at the same time to reason about how they behave * in this application. We can build up the complexity in layers. *

* Note: the above example is just to build fluency with the CSP/occam * concept of parallel composition and to show how easy it is. The network * decomposes into fine-grained stateless components that would be excellent * if we were refining this application down to a silicon (e.g. FPGA) implementation * -- but for software running on a uni-processor JVM, we would not suggest going * quite so far! *

* Note: the above layered network of communicating parallel processes is * completely deterministic. It will produce the same results regardless of * the scheduling characteristics of the underlying JVM and regardless of its * physical distribution on to separate processors (and their relative speeds). * This default determinism is one of the founding strengths of CSP concurrency * that reinforces confidence in the systems we build with it. *

* Non-determinism, of course, needs to be addressed for many applications * and is catered for in JCSP by its {@link Alternative} construct * (which corresponds to the CSP external choice operator and occam ALT), * by its any-1, 1-any and any-any channels * (e.g. {@link Any2OneChannel}) and by the overwriting semantics * that can be defined for its channels (e.g. {@link org.jcsp.util.OverWriteOldestBuffer}). * The fact that non-determinism has to be explicitly introduced reduces * the chance of overlooking race-hazards caused by that non-determinism. *

Low Level

* For a low-level application of Parallel, here is the implementation * of the {@link org.jcsp.plugNplay.ints.ParaplexInt} process used in the high-level example above: *
 * package org.jcsp.plugNplay.ints;
 * 
 * import org.jcsp.lang.*;
 * 
 * public final class ParaplexInt implements CSProcess {
 * 
 *   private final ChannelInputInt[] in;
 * 
 *   private final ChannelOutput out;
 * 
 *   public ParaplexInt (final ChannelInputInt[] in, final ChannelOutput out) {
 *     this.in = in;
 *     this.out = out;
 *   }
 * 
 *   public void run () {
 * 
 *     final ProcessReadInt[] inputProcess = new ProcessReadInt[in.length];
 *     for (int i = 0; i < in.length; i++) {
 *       inputProcess[i] = new ProcessReadInt (in[i]);
 *     }
 * 
 *     Parallel parInput = new Parallel (inputProcess);
 * 
 *     int[][] data = new int[2][in.length];               // double-buffer
 *     int index = 0;                                      // initial buffer index
 * 
 *     while (true) {
 *       parInput.run ();
 *       int[] buffer = data[index];                       // grab a buffer
 *       for (int i = 0; i < in.length; i++) {
 *         buffer[i] = inputProcess[i].value;
 *       }
 *       out.write (buffer);
 *       index = 1 - index;                                // switch buffers
 *     }
 * 
 *   }
 * 
 * }
 * 
* Note that the Parallel object (parInput) is constructed once and contains an array * of processes ({@link org.jcsp.plugNplay.ints.ProcessReadInt}), each of which performs only a single channel * input and, then, terminates. Each time it is run (parInput.run inside * the loop), all those sub-processes run concurrently -- the parallel run terminating * when, and only when, all those sub-processes have terminated. See the documentation * of {@link org.jcsp.plugNplay.ints.ParaplexInt} for the motivation for this low-level concurrency (and for * the double-buffering). *

*

Implementation Note

* The Parallel object creates new {@link java.lang.Thread}s to run the first * (n - 1) of its processes, running the last one in its own thread of control. * After each run of the Parallel {@link CSProcess}, all those threads * are parked for reuse in the next run. Thus in the above low-level * application, the overhead for Java thread creation for the internal concurrency * is only incurred on its first cycle. All these implementation Threads * are daemons and, so, will terminate if everything else terminates. *

* If a Parallel process has finished its run() and is not going * to be used again, its parked threads may be unparked and terminated by invoking * its {@link #releaseAllThreads releaseAllThreads} method. This will release * the memory used by those threads. * * @see org.jcsp.lang.CSProcess * @see org.jcsp.lang.ProcessManager * @see org.jcsp.lang.Sequence * * @author P.D. Austin * @author P.H. Welch */ public class Parallel implements CSProcess { /** * Monitor for internal synchronisation. */ private final Object sync = new Object(); /** The processes to be executed in Parallel */ private CSProcess[] processes; /** The number of processes in this Parallel */ private int nProcesses = 0; /** A pool of ParThreads */ private ParThread[] parThreads; /** The number of threads created so far by this Parallel */ private int nThreads = 0; // invariant : (0 <= nProcesses <= processes.length) // invariant : (0 <= nThreads <= parThreads.length) /** Used to synchronise the termination of processes in each run of Parallel */ private Barrier barrier = new Barrier(); private boolean priority; private boolean processesChanged; /** * The threads created by all Parallel and {@link ProcessManager} objects. */ private static final Set allParThreads = Collections.synchronizedSet(new HashSet()); /** * Indicates that the destroy() method has already been called. */ private static boolean destroyCalled = false; /** * Adds the thread object to the allParThreads collection. This should be called by any infrastructure threads when they start. * * @param newThread the thread to be added to the collection. */ static void addToAllParThreads(final Thread newThread) throws InterruptedException { synchronized (allParThreads) { if (destroyCalled) throw new InterruptedException("Parallel.destroy() has been called"); allParThreads.add(newThread); } } /** * Removes the thread object from the allParThreads collection. */ static void removeFromAllParThreads(final Thread oldThread) { synchronized (allParThreads) { allParThreads.remove(oldThread); } } /** * Stops all threads created by all Parallel and {@link ProcessManager} objects. No new threads can be * created until the resetDestroy method gets called. */ public static void destroy() { synchronized (allParThreads) { if (!destroyCalled) { System.out.println("*** org.jcsp.lang.Parallel: stopping " + allParThreads.size() + " threads"); for (Iterator i = allParThreads.iterator(); i.hasNext(); ) { final Thread t = (Thread)i.next(); try { t.interrupt(); } catch (SecurityException e) { System.out.println("*** org.jcsp.lang.Parallel: couldn't stop thread " + t + " - security exception"); } } destroyCalled = true; } } } /** * Cancels a call to destroy allowing the JCSP system to be reused. This is provided to that destroy * can be called from an Applet's termination method, but the Applet can be restarted later. */ public static void resetDestroy() { synchronized (allParThreads) { destroyCalled = false; } } /** * Construct a new Parallel object initially without any processes. */ public Parallel() { this(null, false); } /** * Construct a new Parallel object initially without any processes. * If the priority parameter has the value true, priorities higher in * the process list will be given a higher priority. * * @param priority indicates that different priorities should be given to processes. */ Parallel(boolean priority) // package visibilty { this(null, priority); } /** * Construct a new Parallel object with the processes specified. * * @param processes The processes to be executed in parallel */ public Parallel(CSProcess[] processes) { this(processes, false); } /** * Construct a new Parallel object with the processes specified. * * @param processes The processes to be executed in parallel */ public Parallel (CSProcess[][] processes) { if (processes != null) { int count = 0; for (int i = 0; i < processes.length; i++) { if (processes[i] != null) count += processes[i].length; } nProcesses = count; this.processes = new CSProcess[nProcesses]; count = 0; for (int i = 0; i < processes.length; i++) { if (processes[i] != null) { int n = processes[i].length; System.arraycopy (processes[i], 0, this.processes, count, n); count += n; } } parThreads = new ParThread[nProcesses]; } else { nProcesses = 0; this.processes = new CSProcess[0]; parThreads = new ParThread[0]; } processesChanged = true; this.priority = false; } /** * Construct a new Parallel object with the processes specified. * If the priority parameter has the value true, priorities higher in * the process list will be given a higher priority. * * @param processes the processes to be executed in parallel * @param priority indicates that different priorities should be given to processes. */ Parallel(CSProcess[] processes, boolean priority) // package visibilty { if (processes != null) { nProcesses = processes.length; this.processes = new CSProcess[nProcesses]; System.arraycopy(processes, 0, this.processes, 0, nProcesses); parThreads = new ParThread[nProcesses]; } else { nProcesses = 0; this.processes = new CSProcess[0]; parThreads = new ParThread[0]; } processesChanged = true; this.priority = priority; } /** * Add the process to the Parallel object. The extended network * will be executed the next time run() is invoked. * * @param process the CSProcess to be added */ public void addProcess(CSProcess process) { synchronized (sync) { if (process != null) { final int targetProcesses = nProcesses + 1; if (targetProcesses > processes.length) { final CSProcess[] tmp = processes; processes = new CSProcess[2 * targetProcesses]; System.arraycopy(tmp, 0, processes, 0, nProcesses); } processes[nProcesses] = process; nProcesses = targetProcesses; processesChanged = true; } } } /** * Add the array of processes to the Parallel object. * The extended network will be executed the next time * run() is invoked. * * @param newProcesses the CSProcesses to be added */ public void addProcess(CSProcess[] newProcesses) { synchronized (sync) { if (processes != null) { final int extra = newProcesses.length; final int targetProcesses = nProcesses + extra; if (targetProcesses > processes.length) { final CSProcess[] tmp = processes; processes = new CSProcess[2 * targetProcesses]; System.arraycopy(tmp, 0, processes, 0, nProcesses); } System.arraycopy(newProcesses, 0, processes, nProcesses, extra); nProcesses = targetProcesses; processesChanged = true; } } } /** * Insert another process to the pri-parallel object at the specifed * index. The point of insertion is significant because the ordering of * process components determines the priorities. The extended network * will be executed the next time run() is invoked. *

* @param process the process to be inserted * @param index the index at which to insert the process */ public void insertProcessAt(CSProcess process, int index) { synchronized (sync) { if (index >= nProcesses + 1) throw new ArrayIndexOutOfBoundsException(index + " > " + (nProcesses + 1)); if (process != null) { final int targetProcesses = nProcesses + 1; if (targetProcesses > processes.length) { final CSProcess[] tmp = processes; processes = new CSProcess[2 * targetProcesses]; System.arraycopy(tmp, 0, processes, 0, index); System.arraycopy(tmp, index, processes, index + 1, nProcesses - index); } else { if (index < nProcesses) System.arraycopy(processes, index, processes, index + 1, nProcesses - index); } processes[index] = process; nProcesses = targetProcesses; processesChanged = true; } } } /** * Remove the process from the Parallel object. The cut-down network * will not be executed until the next time run() is invoked. * * @param process the CSProcess to be removed */ public void removeProcess(CSProcess process) { synchronized (sync) { for (int i = 0; i < nProcesses; i++) { if (processes[i] == process) { if (i < nProcesses - 1) System.arraycopy(processes, i + 1, processes, i, nProcesses - (i + 1)); nProcesses--; processes[nProcesses] = null; processesChanged = true; return; } } } } /** * Remove all processes from the Parallel object. The cut-down network * will not be executed until the next time run() is invoked. */ public void removeAllProcesses() { synchronized (sync) { for (int i = 0; i < nProcesses; i++) { processes[i] = null; } nProcesses = 0; processesChanged = true; } } /** * System finalizer. When this object falls out of scope it will release all of the threads that it * has allocated. */ protected void finalize() throws Throwable { releaseAllThreads(); } /** * Release all threads saved by the Parallel object for future runs - * the threads all terminate and release their associated workspaces. * This should only be executed when the Parallel object is not running. * If this Parallel object is run again, the necessary threads will be * recreated. */ public void releaseAllThreads() { synchronized (sync) { for (int i = 0; i < nThreads; i++) { parThreads[i].terminate(); parThreads[i] = null; } nThreads = 0; processesChanged = true; } } /** * @return the number of processes currently registered. */ public int getNumberProcesses() { int n; synchronized (sync) { n = nProcesses; } return n; } /** * Run the parallel composition of the processes registered with this * Parallel object. It terminates when, and only when, all its component * processes terminate. *

*

Implementation note: In its first run, only * (numProcesses - 1) Threads are created to run the processes -- * the last process is executed in the invoking Thread. * Sunsequent runs reuse these Threads (so the overhead * of thread creation happens only once).

*/ public void run() { boolean emptyRun = true; CSProcess myProcess = null; synchronized (sync) { if (nProcesses > 0) { emptyRun = false; int currentPriority = 0; int maxPriority = 0; if (priority) { Thread thread = Thread.currentThread(); currentPriority = thread.getPriority(); maxPriority = Math.min( currentPriority + nProcesses - 1, Math.min(Thread.MAX_PRIORITY, thread.getThreadGroup().getMaxPriority() ) ); } barrier.reset(nProcesses); myProcess = processes[nProcesses - 1]; if (processesChanged) { if (nThreads < nProcesses - 1) { if (parThreads.length < nProcesses - 1) { final ParThread[] tmp = parThreads; parThreads = new ParThread[processes.length]; System.arraycopy(tmp, 0, parThreads, 0, nThreads); } for (int i = 0; i < nThreads; i++) { parThreads[i].reset(processes[i], barrier); if (priority) { parThreads[i].setPriority(Math.max( currentPriority, maxPriority - i)); } parThreads[i].release(); } for (int i = nThreads; i < nProcesses - 1; i++) { parThreads[i] = new ParThread(processes[i], barrier); if (priority) { parThreads[i].setPriority(Math.max( currentPriority, maxPriority - i)); } parThreads[i].start(); } nThreads = nProcesses - 1; } else { for (int i = 0; i < nProcesses - 1; i++) { parThreads[i].reset(processes[i], barrier); if (priority) { parThreads[i].setPriority(Math.max( currentPriority, maxPriority - i)); } parThreads[i].release(); } } processesChanged = false; } else { for (int i = 0; i < nProcesses - 1; i++) { if (priority) { parThreads[i].setPriority(Math.max(currentPriority, maxPriority - i)); } parThreads[i].release(); } } } } // end synchronized block if (! emptyRun) { try { myProcess.run(); } catch (ProcessInterruptedException e) { // If this was raised then we must propogate the interrupt signal to other processes // PHW: Why? This seems unnecessary ... and, in any case, isn't done if sibling // processes (in their parThreads) are interrupted! synchronized (sync) { // PHW: why synchronize? for (int i = 0; i < nThreads; i++) { try { parThreads[i].interrupt(); } catch (Throwable t) { System.out.println( "*** org.jcsp.lang.Parallel: couldn't stop thread " + t + " - security exception"); } } } } catch (Throwable e) { uncaughtException("org.jcsp.lang.Parallel", e); } barrier.sync(); } } /** * TRUE iff uncaught exceptions are to be displayed. */ private static boolean displayExceptions = true; /** * TRUE iff uncaught errors are to the displayed. */ private static boolean displayErrors = true; /** * Enables or disables the display of Exceptions uncaught by a CSProcess running within a Parallel or under a * ProcessManager object. */ public static void setUncaughtExceptionDisplay(final boolean enable) { displayExceptions = enable; } /** * Enables or disables the display or Errors uncaught by a CSProcess running within a Parallel or under a * ProcessManager object. */ public static void setUncaughtErrorDisplay(final boolean enable) { displayErrors = enable; } static void uncaughtException(final String caller, final Throwable t) { if (((t instanceof Error) && displayErrors) || ((t instanceof Exception) && displayExceptions)) { synchronized (System.err) { System.err.println("\n*** " + caller + ": A process threw the following exception :"); t.printStackTrace(); System.err.println(); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableChannelOutputImpl.java0000644000000000000000000000426711113671251022331 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; class RejectableChannelOutputImpl extends ChannelOutputImpl implements RejectableChannelOutput { public RejectableChannelOutputImpl(ChannelInternals _channel, int _immunity) { super(_channel, _immunity); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableOne2OneChannelImpl.java0000644000000000000000000003036411113402355022323 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import java.io.Serializable; /** * This implements a one-to-one object channel. *

Description

* One2OneChannelImpl implements a one-to-one object channel. Multiple * readers or multiple writers are not allowed -- these are catered for * by {@link Any2OneChannelImpl}, * {@link One2AnyChannelImpl} or * {@link Any2AnyChannelImpl}. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

* The default semantics of the channel is that of CSP -- i.e. it is * zero-buffered and fully synchronised. The reading process must wait * for a matching writer and vice-versa. *

* However, the static methods of {@link Channel} allow the creation of * a channel with a plug-in driver conforming to the * {@link org.jcsp.util.ChannelDataStore ChannelDataStore} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.Any2OneChannelImpl * @see org.jcsp.lang.One2AnyChannelImpl * @see org.jcsp.lang.Any2AnyChannelImpl * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin * @author P.H. Welch */ class PoisonableOne2OneChannelImpl implements One2OneChannel, Serializable, ChannelInternals { /** The monitor synchronising reader and writer on this channel */ private Object rwMonitor = new Object (); /** The (invisible-to-users) buffer used to store the data for the channel */ private Object hold; /** The synchronisation flag */ private boolean empty = true; /** * This flag indicates that the last transfer went OK. The purpose is to not * throw a PoisonException to the writer side when the last transfer went * OK, but the reader side injected poison before the writer side finished * processing of the last write transfer. */ private boolean done = false; /** * 0 means unpoisoned */ private int poisonStrength = 0; /** * Immunity is passed to the channel-ends, and is not used directly by the channel algorithms */ private int immunity; /** The Alternative class that controls the selection */ private Alternative alt; /** Flag to deal with a spurious wakeup during a write */ private boolean spuriousWakeUp = true; private boolean isPoisoned() { return poisonStrength > 0; } PoisonableOne2OneChannelImpl(int _immunity) { immunity = _immunity; } /*************Methods from One2OneChannel******************************/ /** * Returns the AltingChannelInput to use for this channel. * As One2OneChannelImpl implements * AltingChannelInput itself, this method simply returns * a reference to the object that it is called on. * * @return the AltingChannelInput object to use for this * channel. */ public AltingChannelInput in() { return new AltingChannelInputImpl(this,immunity); } /** * Returns the ChannelOutput object to use for this channel. * As One2OneChannelImpl implements * ChannelOutput itself, this method simply returns * a reference to the object that it is called on. * * @return the ChannelOutput object to use for this * channel. */ public ChannelOutput out() { return new ChannelOutputImpl(this,immunity); } /*************Methods from ChannelOutput*******************************/ /** * Writes an Object to the channel. * * @param value the object to write to the channel. */ public void write(Object value) { synchronized (rwMonitor) { if (isPoisoned()) { throw new PoisonException(poisonStrength); } hold = value; if (empty) { empty = false; if (alt != null) { alt.schedule(); } } else { empty = true; rwMonitor.notify(); } try { rwMonitor.wait(); while (spuriousWakeUp && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record(SpuriousLog.One2OneChannelWrite); } rwMonitor.wait(); } spuriousWakeUp = true; } catch (InterruptedException e) { throw new ProcessInterruptedException( "*** Thrown from One2OneChannel.write (Object)\n" + e.toString()); } if (done) { done = false; } else if (isPoisoned()) { hold = null; throw new PoisonException(poisonStrength); } else { done = true; } } } /** ***********Methods from AltingChannelInput************************* */ /** * Reads an Object from the channel. * * @return the object read from the channel. */ public Object read () { synchronized (rwMonitor) { if (isPoisoned()) { throw new PoisonException(poisonStrength); } if (empty) { empty = false; try { rwMonitor.wait (); while (!empty && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from One2OneChannel.read ()\n" + e.toString ()); } } else { empty = true; } spuriousWakeUp = false; if (isPoisoned()) { throw new PoisonException(poisonStrength); } else { done = true; rwMonitor.notify(); return hold; } } } public Object startRead() { synchronized (rwMonitor) { if (isPoisoned()) { throw new PoisonException(poisonStrength); } if (empty) { empty = false; try { rwMonitor.wait (); while (!empty && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ("*** Thrown from One2OneChannel.read ()\n" + e.toString ()); } } else { empty = true; } if (isPoisoned()) { throw new PoisonException(poisonStrength); } return hold; } } public void endRead() { synchronized (rwMonitor) { spuriousWakeUp = false; rwMonitor.notify (); } } /** * turns on Alternative selection for the channel. Returns true if the * channel has data that can be read immediately. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class which will control the selection * @return true if the channel has data that can be read, else false */ public boolean readerEnable (Alternative alt) { synchronized (rwMonitor) { if (isPoisoned()) { return true; } if (empty) { this.alt = alt; return false; } else { return true; } } } /** * turns off Alternative selection for the channel. Returns true if the * channel contained data that can be read. *

* Note: this method should only be called by the Alternative class * * @return true if the channel has data that can be read, else false */ public boolean readerDisable () { synchronized (rwMonitor) { alt = null; return !empty || isPoisoned(); } } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. *

* This method is provided for convenience. Its functionality can be provided * by Pri Alting the channel against a SKIP guard, although * at greater run-time and syntactic cost. For example, the following code * fragment: *

	   *   if (c.pending ()) {
	   *     Object x = c.read ();
	   *     ...  do something with x
	   *   } else (
	   *     ...  do something else
	   *   }
	   * 
* is equivalent to: *
	   *   if (c_pending.priSelect () == 0) {
	   *     Object x = c.read ();
	   *     ...  do something with x
	   *   } else (
	   *     ...  do something else
	   * }
	   * 
* where earlier would have had to have been declared: *
	   * final Alternative c_pending =
	   *   new Alternative (new Guard[] {c, new Skip ()});
	   * 
* * @return state of the channel. */ public boolean readerPending () { synchronized (rwMonitor) { return !empty || isPoisoned(); } } public void writerPoison(int strength) { if (strength > 0) { synchronized (rwMonitor) { this.poisonStrength = strength; rwMonitor.notifyAll(); if (null != alt) { alt.schedule(); } } } } public void readerPoison(int strength) { if (strength > 0) { synchronized (rwMonitor) { this.poisonStrength = strength; rwMonitor.notifyAll(); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Spurious.java0000644000000000000000000000675611105701167016574 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.lang; //{{{ javadoc /** * This holds the static flag (indicating whether spurious wakeups should be logged) * and early timeout allowance (for {@link Alternative}s with {@link CSTimer} guards). * *

Description

* These fields are held in this separate class to minimise class loading when * spurious wakeups are not logged - the default condition. * * @see org.jcsp.lang.SpuriousLog * * @author P.H. Welch */ //}}} class Spurious { // package-only visible /** * If logging is required, this flag should be set before any concurrency * is started. It should only be set once using {@link SpuriousLog#start()}. * There is no concurrency protection! */ static public boolean logging = false; /** * This is the allowed early timeout (in msecs). Some JVMs timeout on calls * of wait (timeout) early - this specifies how early JCSP will tolerate. *

* We need this to distinguish between a JVM-early timeout (that should * be accepted) and a spurious wakeup (that should not). The value to * which this field should be set is machine dependant. For JVMs that do not * return early timeouts, it should be set to zero. For many, it should be * left at the default value (4). If {@link Spurious#logging} is enabled, * counts of spurious wakeups versus accepted early timeouts on select * operations on {@link Alternative}s can be obtained; this field should be * set to minimise the former. *

* This field should be set before any concurrency is started. * It should only be set once using {@link SpuriousLog#setEarlyTimeout(long)}. * There is no concurrency protection! */ static public long earlyTimeout = 9; } jcsp-1.1-rc4.orig/src/org/jcsp/lang/Any2OneConnectionImpl.java0000644000000000000000000001024511105701167021044 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.*; /** * This class is an implementation of Any2OneConnection. * Each end is safe to be used by one thread at a time. * * @author Quickstone Technologies Limited */ class Any2OneConnectionImpl implements Any2OneConnection { private AltingConnectionServer server; private One2OneChannel chanToServer; private One2OneChannel chanFromServer; private Any2OneChannel chanSynch; /** * Initializes all the attributes to necessary values. * Channels are created using the static factory in the * ChannelServer inteface. * * Constructor for One2OneConnectionImpl. */ public Any2OneConnectionImpl() { super(); chanToServer = ConnectionServer.FACTORY.createOne2One(new Buffer(1)); chanFromServer = ConnectionServer.FACTORY.createOne2One(new Buffer(1)); chanSynch = ConnectionServer.FACTORY.createAny2One(new Buffer(1)); //create the server object - client object created when accessed server = new AltingConnectionServerImpl(chanToServer.in(), chanToServer.in()); } /** * Returns the AltingConnectionClient that can * be used by a single process at any instance. * * @return the AltingConnectionClient object. */ public SharedAltingConnectionClient client() { return new SharedAltingConnectionClient(chanFromServer.in(), chanSynch.in(), chanToServer.out(), chanToServer.out(), chanSynch.out(), chanFromServer.out(), this); } /** * Returns the AltingConnectionServer that can * be used by a single process at any instance. * * @return the AltingConnectionServer object. */ public AltingConnectionServer server() { return server; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonException.java0000644000000000000000000000601411113671251020053 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This exception is thrown when a process tries to use a channel that * has been poisoned. * * @see org.jcsp.lang.Poisonable */ public class PoisonException extends ChannelDataRejectedException { private int strength; /** * JCSP users should not have to construct these. * * @param strength the strength of this exception * (which will normally be the strength of the poison in the channel). */ protected PoisonException (int strength) { //super("PoisonException, strength: " + strength); this.strength = strength; } /** * Once this exception has been caught, the catching process should * poison all its channels with the strength held by the exception * (which will normally be the strength of the poison in the channel * that caused the exception to be thrown). * See the example handler at the end of * this section * of the documentation of {@link Alternative}. */ public int getStrength() { return strength; } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/RejectableChannelInput.java0000644000000000000000000000523511105701167021303 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines an interface for an input channel end that gives the reader the ability to reject instead * of accepting pending data. * * @author Quickstone Technologies Limited * * @deprecated This channel is superceded by the poison mechanisms, please see {@link PoisonException}. It remains only because it is used by some of the networking features. */ public interface RejectableChannelInput extends ChannelInput { /** * Reject any data pending instead of reading it. The currently blocked writer will receive a * ChannelDataRejectedException. */ public void reject(); } jcsp-1.1-rc4.orig/src/org/jcsp/lang/ChannelInputWrapper.java0000644000000000000000000000671611113671251020667 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * Defines a wrapper to go around a channel input end. This wrapper allows a channel end to be given * away without any risk of the user of that end casting it to a channel output because they cannot * gain access to the actual channel end. * * @deprecated There is no longer any need to use this class, after the 1.1 class reorganisation. * * @author Quickstone Technologies Limited */ public class ChannelInputWrapper implements ChannelInput { /** * The actual channel end. */ private ChannelInput in; /** * Constructs a new wrapper around the given channel end. * * @param in the existing channel end. */ public ChannelInputWrapper(ChannelInput in) { this.in = in; } /** * Reads a value from the channel. * * @see org.jcsp.lang.ChannelInput * @return the value read. */ public Object read() { return in.read(); } /** * Begins an extended rendezvous * * @see ChannelInput.startRead * @return The object read from the channel */ public Object startRead() { return in.startRead(); } /** * Ends an extended rendezvous * * @see ChannelInput.endRead */ public void endRead() { in.endRead(); } public void poison(int strength) { in.poison(strength); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/PoisonableBufferedOne2OneChannelInt.java0000644000000000000000000002711511113671251023622 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.ints.ChannelDataStoreInt; class PoisonableBufferedOne2OneChannelInt implements One2OneChannelInt, ChannelInternalsInt { /** The ChannelDataStore used to store the data for the channel */ private final ChannelDataStoreInt data; private final Object rwMonitor = new Object(); private Alternative alt; //Only passed to channel-ends, not used directly: private int immunity; private int poisonStrength = 0; /** * Constructs a new BufferedOne2OneChannel with the specified ChannelDataStore. * * @param data the ChannelDataStore used to store the data for the channel */ public PoisonableBufferedOne2OneChannelInt(ChannelDataStoreInt data, int _immunity) { if (data == null) throw new IllegalArgumentException ("Null ChannelDataStore given to channel constructor ...\n"); this.data = (ChannelDataStoreInt) data.clone(); immunity = _immunity; } private boolean isPoisoned() { return poisonStrength > 0; } /** * Reads an Object from the channel. * * @return the object read from the channel. */ public int read () { synchronized (rwMonitor) { if (data.getState () == ChannelDataStoreInt.EMPTY) { //Reader only sees poison if buffer is empty: if (isPoisoned()) { throw new PoisonException(poisonStrength); } try { rwMonitor.wait (); while (data.getState () == ChannelDataStoreInt.EMPTY && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.read (int)\n" + e.toString () ); } if (isPoisoned()) { throw new PoisonException(poisonStrength); } } rwMonitor.notify (); return data.get (); } } public int startRead() { synchronized (rwMonitor) { if (data.getState () == ChannelDataStoreInt.EMPTY) { // Reader only sees poison if buffer is empty: if (isPoisoned()) { throw new PoisonException(poisonStrength); } try { rwMonitor.wait (); while (data.getState () == ChannelDataStoreInt.EMPTY && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.read (int)\n" + e.toString () ); } // Reader only sees poison if buffer is empty: if (isPoisoned()) { throw new PoisonException(poisonStrength); } } return data.startGet(); } } public void endRead() { synchronized(rwMonitor) { data.endGet(); rwMonitor.notify (); } } /** * Writes an Object to the channel. * * @param value the object to write to the channel. */ public void write (int value) { synchronized (rwMonitor) { //Writer always sees poison: if (isPoisoned()) { throw new PoisonException(poisonStrength); } data.put (value); if (alt != null) { alt.schedule (); } else { rwMonitor.notify (); } if (data.getState () == ChannelDataStoreInt.FULL) { try { rwMonitor.wait (); while (data.getState () == ChannelDataStoreInt.FULL && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXWrite); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.write (Object)\n" + e.toString () ); } if (isPoisoned()) { throw new PoisonException(poisonStrength); } } } } /** * turns on Alternative selection for the channel. Returns true if the * channel has data that can be read immediately. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class which will control the selection * @return true if the channel has data that can be read, else false */ public boolean readerEnable (Alternative alt) { synchronized (rwMonitor) { if (isPoisoned()) { //If it's poisoned, it will be ready whether because of the poison, or because //the buffer has data in it return true; } else if (data.getState () == ChannelDataStoreInt.EMPTY) { this.alt = alt; return false; } else { return true; } } } /** * turns off Alternative selection for the channel. Returns true if the * channel contained data that can be read. *

* Note: this method should only be called by the Alternative class * * @return true if the channel has data that can be read, else false */ public boolean readerDisable () { synchronized (rwMonitor) { alt = null; return data.getState () != ChannelDataStoreInt.EMPTY || isPoisoned(); } } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. *

* This method is provided for convenience. Its functionality can be provided * by Pri Alting the channel against a SKIP guard, although * at greater run-time and syntactic cost. For example, the following code * fragment: *

     *   if (c.pending ()) {
     *     Object x = c.read ();
     *     ...  do something with x
     *   } else (
     *     ...  do something else
     *   }
     * 
* is equivalent to: *
     *   if (c_pending.priSelect () == 0) {
     *     Object x = c.read ();
     *     ...  do something with x
     *   } else (
     *     ...  do something else
     * }
     * 
* where earlier would have had to have been declared: *
     * final Alternative c_pending =
     *   new Alternative (new Guard[] {c, new Skip ()});
     * 
* * @return state of the channel. */ public boolean readerPending () { synchronized (rwMonitor) { return (data.getState () != ChannelDataStoreInt.EMPTY) || isPoisoned(); } } /** * Returns the AltingChannelInput to use for this channel. * As BufferedOne2OneChannel implements * AltingChannelInput itself, this method simply returns * a reference to the object that it is called on. * * @return the AltingChannelInput object to use for this * channel. */ public AltingChannelInputInt in() { return new AltingChannelInputIntImpl(this,immunity); } /** * Returns the ChannelOutput object to use for this channel. * As BufferedOne2OneChannel implements * ChannelOutput itself, this method simply returns * a reference to the object that it is called on. * * @return the ChannelOutput object to use for this * channel. */ public ChannelOutputInt out() { return new ChannelOutputIntImpl(this,immunity); } public void writerPoison(int strength) { if (strength > 0) { synchronized (rwMonitor) { this.poisonStrength = strength; //Poison by writer does *NOT* clear the buffer rwMonitor.notifyAll(); if (null != alt) { alt.schedule(); } } } } public void readerPoison(int strength) { if (strength > 0) { synchronized (rwMonitor) { this.poisonStrength = strength; //Poison by reader clears the buffer: data.removeAll(); rwMonitor.notifyAll(); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/One2AnyConnectionImpl.java0000644000000000000000000001062211105701167021043 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.Buffer; /** * This class is an implementation of One2AnyConnection. * Each end is safe to be used by one thread at a time. * * @author Quickstone Technologies Limited */ class One2AnyConnectionImpl implements One2AnyConnection { private AltingConnectionClient client; private One2OneChannel chanToServer; private One2OneChannel chanFromServer; private Any2OneChannel chanSynch; /** * Initializes all the attributes to necessary values. * Channels are created using the static factory in the * ChannelServer interface. * * Constructor for One2OneConnectionImpl. */ public One2AnyConnectionImpl() { super(); chanToServer = ConnectionServer.FACTORY.createOne2One(new Buffer(1)); chanFromServer = ConnectionServer.FACTORY.createOne2One(new Buffer(1)); chanSynch = ConnectionServer.FACTORY.createAny2One(new Buffer(1)); //create the client and server objects client = new AltingConnectionClientImpl(chanFromServer.in(), chanToServer.out(), chanToServer.out(), chanFromServer.out()); } /** * Returns the AltingConnectionClient that can * be used by a single process at any instance. * * Each call to this method will return the same object reference. * * @return the AltingConnectionClient object. */ public AltingConnectionClient client() { return client; } /** * Returns a SharedConnectionServer object for this * connection. This method can be called multiple times to return a new * SharedConnectionServer object each time. Any object * created can only be used by one process at a time but the set of * objects constructed can be used concurrently. * * @return a new SharedConnectionServer object. */ public SharedConnectionServer server() { return new SharedConnectionServerImpl(chanToServer.in(), chanToServer.in(), chanSynch.in(), chanSynch.out(), this); } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/BufferedOne2OneChannel.java0000644000000000000000000002427111105701167021134 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; import org.jcsp.util.*; /** * This implements a one-to-one object channel with user-definable buffering. *

Description

* BufferedOne2OneChannel implements a one-to-one object channel with * user-definable buffering. Multiple readers or multiple writers are * not allowed -- these are catered for by {@link BufferedAny2OneChannel}, * {@link BufferedOne2AnyChannel} or {@link BufferedAny2AnyChannel}. *

* The reading process may {@link Alternative ALT} on this channel. * The writing process is committed (i.e. it may not back off). *

* The constructor requires the user to provide * the channel with a plug-in driver conforming to the * {@link org.jcsp.util.ChannelDataStore ChannelDataStore} * interface. This allows a variety of different channel semantics to be * introduced -- including buffered channels of user-defined capacity * (including infinite), overwriting channels (with various overwriting * policies) etc.. * Standard examples are given in the org.jcsp.util package, but * careful users may write their own. * * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.BufferedAny2OneChannel * @see org.jcsp.lang.BufferedOne2AnyChannel * @see org.jcsp.lang.BufferedAny2AnyChannel * @see org.jcsp.util.ChannelDataStore * * @author P.D. Austin * @author P.H. Welch */ class BufferedOne2OneChannel implements One2OneChannel, ChannelInternals { /** The ChannelDataStore used to store the data for the channel */ private final ChannelDataStore data; private final Object rwMonitor = new Object(); private Alternative alt; /** * Constructs a new BufferedOne2OneChannel with the specified ChannelDataStore. * * @param data the ChannelDataStore used to store the data for the channel */ public BufferedOne2OneChannel(ChannelDataStore data) { if (data == null) throw new IllegalArgumentException ("Null ChannelDataStore given to channel constructor ...\n"); this.data = (ChannelDataStore) data.clone(); } /** * Reads an Object from the channel. * * @return the object read from the channel. */ public Object read () { synchronized (rwMonitor) { if (data.getState () == ChannelDataStore.EMPTY) { try { rwMonitor.wait (); while (data.getState () == ChannelDataStore.EMPTY) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.read (int)\n" + e.toString () ); } } rwMonitor.notify (); return data.get (); } } public Object startRead() { synchronized (rwMonitor) { if (data.getState () == ChannelDataStore.EMPTY) { try { rwMonitor.wait (); while (data.getState () == ChannelDataStore.EMPTY) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXRead); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.read (int)\n" + e.toString () ); } } return data.startGet(); } } public void endRead() { synchronized(rwMonitor) { data.endGet(); rwMonitor.notify (); } } /** * Writes an Object to the channel. * * @param value the object to write to the channel. */ public void write (Object value) { synchronized (rwMonitor) { data.put (value); if (alt != null) { alt.schedule (); } else { rwMonitor.notify (); } if (data.getState () == ChannelDataStore.FULL) { try { rwMonitor.wait (); while (data.getState () == ChannelDataStore.FULL) { if (Spurious.logging) { SpuriousLog.record (SpuriousLog.One2OneChannelXWrite); } rwMonitor.wait (); } } catch (InterruptedException e) { throw new ProcessInterruptedException ( "*** Thrown from One2OneChannel.write (Object)\n" + e.toString () ); } } } } /** * turns on Alternative selection for the channel. Returns true if the * channel has data that can be read immediately. *

* Note: this method should only be called by the Alternative class * * @param alt the Alternative class which will control the selection * @return true if the channel has data that can be read, else false */ public boolean readerEnable (Alternative alt) { synchronized (rwMonitor) { if (data.getState () == ChannelDataStore.EMPTY) { this.alt = alt; return false; } else { return true; } } } /** * turns off Alternative selection for the channel. Returns true if the * channel contained data that can be read. *

* Note: this method should only be called by the Alternative class * * @return true if the channel has data that can be read, else false */ public boolean readerDisable () { synchronized (rwMonitor) { alt = null; return data.getState () != ChannelDataStore.EMPTY; } } /** * Returns whether there is data pending on this channel. *

* Note: if there is, it won't go away until you read it. But if there * isn't, there may be some by the time you check the result of this method. *

* This method is provided for convenience. Its functionality can be provided * by Pri Alting the channel against a SKIP guard, although * at greater run-time and syntactic cost. For example, the following code * fragment: *

     *   if (c.pending ()) {
     *     Object x = c.read ();
     *     ...  do something with x
     *   } else (
     *     ...  do something else
     *   }
     * 
* is equivalent to: *
     *   if (c_pending.priSelect () == 0) {
     *     Object x = c.read ();
     *     ...  do something with x
     *   } else (
     *     ...  do something else
     * }
     * 
* where earlier would have had to have been declared: *
     * final Alternative c_pending =
     *   new Alternative (new Guard[] {c, new Skip ()});
     * 
* * @return state of the channel. */ public boolean readerPending () { synchronized (rwMonitor) { return (data.getState () != ChannelDataStore.EMPTY); } } /** * Returns the AltingChannelInput to use for this channel. * As BufferedOne2OneChannel implements * AltingChannelInput itself, this method simply returns * a reference to the object that it is called on. * * @return the AltingChannelInput object to use for this * channel. */ public AltingChannelInput in() { return new AltingChannelInputImpl(this,0); } /** * Returns the ChannelOutput object to use for this channel. * As BufferedOne2OneChannel implements * ChannelOutput itself, this method simply returns * a reference to the object that it is called on. * * @return the ChannelOutput object to use for this * channel. */ public ChannelOutput out() { return new ChannelOutputImpl(this,0); } // No poison in these channels: public void writerPoison(int strength) { } public void readerPoison(int strength) { } } jcsp-1.1-rc4.orig/src/org/jcsp/lang/CSProcess.java0000644000000000000000000003672511105701167016606 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.lang; /** * This is the JCSP interface for a process - an active component that encapsulates * the data structures on which it operates. *

Description

* A CSP * process is a component that encapsulates data structures * and algorithms for manipulating that data. Both its data and algorithms * are private. The outside world can neither see that data nor execute those * algorithms. Each process is alive, executing its own algorithms on its own * data. Processes interact solely via CSP synchronising primitives, such as * channels, events or other well-defined modes of access * to shared passive objects. *

* In this JCSP * binding of the CSP model into Java, a process is an instance * of a class implementing this CSProcess interface. * Its actions are defined by the run method. *

* Running processes interact solely via CSP channels, events * or carefully synchronised access to shared objects -- not by calling each * other's methods. These passive objects form the CSP interface to a process. * They are not present in the Java interface and must be configured into * each process via public constructors and/or mutators when it is not running * (i.e. before and in between runs). It is safe to extract information from * the process via accessor methods, but only after (or in between) runs. *

* For other general information, see the JCSP * overview. *

Process Oriented Design

* A process-oriented design consists of layered networks of processes. * A network is simply a parallel composition of processes connected * through a set of passive synchronisation objects (wires) and is * itself a process. Each process fulfills a contract with its environment * that specifies not only what functions it performs, but how it is prepared * to synchronise with that environment to obtain information and deliver results. * Note that a process does not interact directly with other processes, only * with the wires to which it is connected. This is a very familiar form of * component interface -- certainly to hardware engineers -- and is one that * allows considerable flexibility and reuse. *

Implementation Pattern

* The structure of a JCSP process should follow the outline: *
 * import org.jcsp.lang.*;
 * ...  other imports
 *  
 * class ProcessExample implements CSProcess {
 *  
 *   ...  private/protected shared synchronisation objects (channels etc.)
 *   ...  private/protected state information
 *  
 *   ...  public constructors
 *   ...  public configuration/inspection methods (when not running)
 *  
 *   ...  private/protected support methods (part of a run)
 *   ...  public run method (the process starts here)
 *  
 * }
 * 
* The pattern of use for these methods is simple and well-disciplined. * The public constructors and configuration methods must install the shared * synchronisation objects into their private/protected fields. * They may also initialise other private/protected state information. * The public configuration/inspection methods (simple sets and * gets) may be invoked only when this process is not running * and are the responsibility of a single process only -- usually * the process that constructed it. That process is also responsible for * invoking the public run method that kicks this one into life * (usually, via a {@link Parallel} or {@link ProcessManager} intermediary). * The private support methods are triggered only by the run * method and express the live behaviour of this process. *

* A process instance may have several lives but these must, of course, * be consecutive. Different instances of the same process class may, * also of course, be alive concurrently. Reconfiguration of a process * via its configuration/inspection methods may only take place between * lives. Dynamic reconfiguration of a live process may take place -- * but only with the active cooperation of the process (for example, * through channel communication). *

Motivation

* Like any object, a process should encapsulate a coherent set of data and * algorithms for managing that data. The discipline outlined in the above * implementation pattern has the following broad aims: *
    *
  • * maintain the encapsulation of information (which is something that * is easilly lost in free-wheeling OO-design as object references are * passed around); *
  • * enable a precise (CSP) specification of the way a process interacts * with its environment (represented in the above pattern by the shared * synchronisation objects); *
  • * express the behaviour of the process from its own point of view * (which is something not available to general OO-design whenever * a method of one object is invoked from the method of another); *
  • * eliminate the occurrence of race hazards upon the parallel composition * of processes; *
  • * enable formal certification of the absence of deadlock, livelock and * process starvation in a parallel system (through design-time analysis * or the checked adherence to higher-level CSP design rules for which * proven safety guarantees are known). *
* These properties mean that processes make excellent building blocks for * complex systems -- their semantics compose cleanly and predictably as they * are plugged together. *

* This is not to say that the semantics of processes connected in parallel are * simply the sum of the semantics of each individual process -- just that * those semantics should contain no surprises. * Value can added just through the nature of the parallel composition * itself. For example, connect simple stateless processes into a channel * feedback-loop, give them some external wires and we get a component * that contains state. *

Discussion

* The public methods of an arbitrary object are at the mercy of any * other object that has a reference to it. Further, invocations of those * methods may be part of any thread of control. Object designers, * implementors and users need to have this under well-documented control. * This control is not easy to achieve without any rules. *

* The process design pattern defines some powerful simplifications that bring * us that control. Backed up with the theory of CSP, it also addresses and * offers solutions to some fundamental issues in concurrency and multi-threading. *

* In unconstrained OO, threads and objects are orthogonal notions -- * sometimes dangerously competitive. Threads have no internal structure and can * cross object boundaries in spaghetti-like trails that relate objects together in * a way that has little correspondence to the original OO design. * A process combines these ideas into a single concept, gives it structure * and maintains strong encapsulation by guarding the distribution and use * of references with some strict (and checkable) design rules. * A process may be wired up in parallel with other processes to form a network -- * which is itself a process. So, a process may have sub-processes that have * sub-sub-processes ad infinitum. This is the way the world works ... *

* The simplicity of the process design pattern is that each process can be * considered individually as an independant serial program, interacting * with external I/O devices (the synchronisation objects -- channels etc.). * At the other end of those devices may lie other processes, but that is of * no concern to the consideration of this process. All our past skills and * intuition about serial programming can safely be applied. The new skills * needed to design and use parallel process networks sit alongside those * earlier skills and no cross-interference takes place. *

Examples

* Numerous examples are scattered throughout the documentation of this library. * Good starting ponts are in the {@link Parallel} and {@link Alternative} classes. * Here is another very simple one: *
 * import org.jcsp.lang.*;
 * 
 * // LaunchControl is a process to control the launch of a space rocket.
 * 
 * // It is configured with a countdown time in seconds -- this must be above
 * // a minimum threshold, MIN_COUNTDOWN, else the launch is immediately aborted.
 * 
 * // There are two control lines, abort and hold, that respectively abort
 * // or hold the launch if signalled.  The hold is released by a second
 * // signal on the same line.
 * 
 * // During countdown, the count is reported by outputting on the countdown
 * // channel.
 * 
 * // If not aborted, LaunchControl fires the rocket (by outputting on its fire
 * // channel) when the countdown reaches zero.  An ABORTED launch is also
 * // reported on this fire channel.
 * 
 * // After a successful or aborted launch, LaunchControl terminates.
 * // The status attribute records whether the launch was FIRED or ABORTED
 * // and may then be inspected.
 * 
 * public class LaunchControl implements CSProcess {
 * 
 *   public static final int MIN_COUNTDOWN = 10;
 * 
 *   public static final int FIRED = 0;
 *   public static final int HOLDING = 1;
 *   public static final int COUNTING = 2;
 *   public static final int ABORTED = 3;
 *   public static final int UNDEDFINED = 4;
 * 
 *   private final int start;
 *   private final AltingChannelInputInt abort;
 *   private final AltingChannelInputInt hold;
 *   private final ChannelOutputInt countdown;
 *   private final ChannelOutputInt fire;
 * 
 *   private int status = UNDEDFINED;
 * 
 *   public LaunchControl (final int start,
 *                         final AltingChannelInputInt abort,
 *                         final AltingChannelInputInt hold,
 *                         final ChannelOutputInt countdown,
 *                         final ChannelOutputInt fire) {
 *     this.start = start;
 *     this.abort = abort;
 *     this.hold = hold;
 *     this.countdown = countdown;
 *     this.fire = fire;
 *   }
 * 
 *   public int getStatus () {                   // inspection method
 *     return status;                            // (can only be used in between runs)
 *   }
 * 
 *   public void run () {
 * 
 *     final CSTimer tim = new CSTimer ();        // JCSP timers have
 *     final long oneSecond = 1000;               // millisecond granularity
 * 
 *     long timeout = tim.read () + oneSecond;    // compute first timeout
 * 
 *     final Alternative alt =
 *       new Alternative (new Guard[] {abort, hold, tim});
 *     final int ABORT = 0;
 *     final int HOLD = 1;
 *     final int TICK = 2;
 * 
 *     int count = start;
 *     boolean counting = (start >= MIN_COUNTDOWN); // abort if bad start
 * 
 *     while ((count > 0) && counting) {
 *       countdown.write (count);                   // public address system
 *       tim.setAlarm (timeout);                    // set next timeout
 *       switch (alt.priSelect ()) {
 *         case ABORT:                              // abort signalled
 *           abort.read ();                         // clear the signal
 *           counting = false;
 *         break;
 *         case HOLD:                               // hold signalled
 *           long timeLeft = timeout - tim.read (); // time till next tick
 *           hold.read ();                          // clear the signal
 *           fire.write (HOLDING);                  // signal rocket
 *           hold.read ();                          // wait for the release
 *           timeout = tim.read () + timeLeft;      // recompute next timeout
 *           fire.write (COUNTING);                 // signal rocket
 *         break;
 *         case TICK:                               // timeout expired
 *           count--;
 *           timeout += oneSecond;                  // compute next timeout
 *         break;
 *       }
 *     }
 * 
 *     status = (counting) ? FIRED : ABORTED;       // set status attribute
 *     fire.write (status);                         // signal rocket (go/nogo)
 *     if (counting) countdown.write (0);           // complete countdown
 *   }
 * }
 * 
* * @see org.jcsp.lang.Parallel * @see org.jcsp.lang.PriParallel * @see org.jcsp.lang.Alternative * @see org.jcsp.lang.ChannelInput * @see org.jcsp.lang.ChannelOutput * @see org.jcsp.lang.One2OneChannel * @see org.jcsp.lang.Any2OneChannel * @see org.jcsp.lang.One2AnyChannel * @see org.jcsp.lang.Any2AnyChannel * @see org.jcsp.lang.ChannelInputInt * @see org.jcsp.lang.ChannelOutputInt * @see org.jcsp.lang.One2OneChannelInt * @see org.jcsp.lang.Any2OneChannelInt * @see org.jcsp.lang.One2AnyChannelInt * @see org.jcsp.lang.Any2AnyChannelInt * @see org.jcsp.lang.ProcessManager * @author P.D. Austin * @author P.H. Welch */ public interface CSProcess { /** * This defines the actions of the process. */ public void run(); } jcsp-1.1-rc4.orig/src/org/jcsp/win32/0000755000000000000000000000000011410045045014076 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/win32/svcclasses.cpp0000644000000000000000000001267110522104430016757 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2006 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@ukc.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// #include "svcclasses.h" #include #include CServiceManager::CServiceManager(TCHAR *machine) { schSCManager = OpenSCManager(machine, NULL, SC_MANAGER_ALL_ACCESS); } CServiceManager::~CServiceManager(void) { if (schSCManager) CloseServiceHandle(schSCManager); } int CServiceManager::ok(void) { return (schSCManager != NULL); } CService::CService(CServiceManager *mgr, TCHAR *name) { schService = OpenService(schSCManager = mgr->schSCManager, name, SERVICE_ALL_ACCESS); } CService::~CService(void) { if (schService) CloseServiceHandle(schService); } int CService::ok(void) { return (schService != NULL); } void CService::install(TCHAR *name, TCHAR *disp, TCHAR *path) { if (schService) CloseServiceHandle(schService); schService = CreateService( schSCManager, // SCManager database name, // name of service disp, // name to display SERVICE_ALL_ACCESS, // desired access SERVICE_WIN32_OWN_PROCESS, // service type SERVICE_AUTO_START, // start type SERVICE_ERROR_NORMAL, // error control type path, // service's binary NULL, // no load ordering group NULL, // no tag identifier NULL, // dependencies NULL, // LocalSystem account NULL); // no password } int CService::destroy(void) { return DeleteService(schService); } int CService::getState(void) { SERVICE_STATUS sta; if (!QueryServiceStatus(schService, &sta)) return 0; return sta.dwCurrentState; } int CService::isStarted(void) { return (getState() == SERVICE_RUNNING); } int CService::isStopped(void) { return (getState() == SERVICE_STOPPED); } void CService::start(void) { ChangeServiceConfig( schService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); StartService(schService, 0, NULL); } void CService::stop(void) { SERVICE_STATUS sta; ControlService(schService, SERVICE_CONTROL_STOP, &sta); } static SERVICE_STATUS sta; static SERVICE_STATUS_HANDLE hsta; static CMyService *service = NULL; static TCHAR *service_name = NULL; static void setstate(int s) { if ((s == SERVICE_RUNNING) || (s == SERVICE_STOPPED)) { sta.dwCheckPoint = 0; } else { sta.dwCheckPoint++; } sta.dwCurrentState = s; SetServiceStatus(hsta, &sta); } static void WINAPI ctrlproc(DWORD ctrl) { if (ctrl == SERVICE_CONTROL_STOP) { setstate(SERVICE_STOP_PENDING); service->stop(); } else { setstate(sta.dwCurrentState); } } static void WINAPI startproc(int argc, TCHAR **argv) { hsta = RegisterServiceCtrlHandler(service_name, ctrlproc); sta.dwServiceType = SERVICE_WIN32_OWN_PROCESS; sta.dwServiceSpecificExitCode = 0; sta.dwControlsAccepted = SERVICE_ACCEPT_STOP; sta.dwWin32ExitCode = 0; sta.dwWaitHint = 3000; sta.dwCheckPoint = 0; setstate(SERVICE_RUNNING); service->start(argc, argv); setstate(SERVICE_STOPPED); } static SERVICE_TABLE_ENTRY dispatch[2] = { { NULL, (LPSERVICE_MAIN_FUNCTION)startproc }, { NULL, NULL } }; void ntservice_schedule (TCHAR *name, CMyService *svc) { service_name = dispatch[0].lpServiceName = strdup(name); service = svc; StartServiceCtrlDispatcher (dispatch); } jcsp-1.1-rc4.orig/src/org/jcsp/win32/LoadDLL.java0000644000000000000000000000534411105701167016167 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.win32; import java.io.*; /** * Common file to ensure that the DLL gets loaded. All files in the Win32 package that declare native * methods from this DLL should make a call to LoadDLL.go () from their static initializers. * * @author Quickstone Technologies Limited */ class LoadDLL { /** * Indicates whether the library has already been loaded. */ private static boolean loaded = false; /** * Loads the library if it hasn't already been loaded. */ static synchronized void go() { if (loaded)return; File f = new File("./org.win32.dll"); System.load(f.getAbsolutePath()); loaded = true; } } jcsp-1.1-rc4.orig/src/org/jcsp/win32/NTService.c0000644000000000000000000001227610522104430016111 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2006 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@ukc.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// #include #include #include "NTService.h" #include #ifdef _UNICODE #define GetStringTChars GetStringChars #define ReleaseStringTChars ReleaseStringChars #else /* ifdef _UNICODE */ #define GetStringTChars GetStringUTFChars #define ReleaseStringTChars ReleaseStringUTFChars #endif /* ifdef _UNICODE */ static SERVICE_STATUS sta; static SERVICE_STATUS_HANDLE hsta; static TCHAR *serviceName = NULL; static HANDLE hStartSemaphore, hStopSemaphore, hAckSemaphore; static void setstate(int s) { if ((s == SERVICE_RUNNING) || (s == SERVICE_STOPPED)) { sta.dwCheckPoint = 0; } else { sta.dwCheckPoint++; } sta.dwCurrentState = s; SetServiceStatus(hsta, &sta); } static void WINAPI ctrlproc(DWORD ctrl) { if (ctrl == SERVICE_CONTROL_STOP) { setstate(SERVICE_STOP_PENDING); ReleaseSemaphore (hStopSemaphore, 1, NULL); } else { setstate(sta.dwCurrentState); } } static void WINAPI startproc(int argc, TCHAR **argv) { hsta = RegisterServiceCtrlHandler(serviceName, ctrlproc); sta.dwServiceType = SERVICE_WIN32_OWN_PROCESS; sta.dwServiceSpecificExitCode = 0; sta.dwControlsAccepted = SERVICE_ACCEPT_STOP; sta.dwWin32ExitCode = 0; sta.dwWaitHint = 3000; sta.dwCheckPoint = 0; setstate(SERVICE_RUNNING); ReleaseSemaphore (hStartSemaphore, 1, NULL); WaitForSingleObject (hAckSemaphore, INFINITE); setstate(SERVICE_STOPPED); } static SERVICE_TABLE_ENTRY dispatch[2] = { { NULL, (LPSERVICE_MAIN_FUNCTION)startproc }, { NULL, NULL } }; JNIEXPORT jint JNICALL Java_com_quickstone_win32_NTService_startDispatcher (JNIEnv *env, jobject obj) { jclass cls; jfieldID fid; jstring jstr; const TCHAR *str; if (serviceName) { // This method has already been called (it shouldn't have been). return -1; } // Lookup the service name cls = (*env)->GetObjectClass (env, obj); fid = (*env)->GetFieldID (env, cls, "serviceName", "Ljava/lang/String;"); jstr = (*env)->GetObjectField (env, obj, fid); str = (*env)->GetStringTChars (env, jstr, 0); // Store the service name in a global buffer serviceName = strdup(str); dispatch[0].lpServiceName = serviceName; // Release the service name buffer (*env)->ReleaseStringTChars (env, jstr, str); // Try and start if (StartServiceCtrlDispatcher (dispatch)) return 0; // Return OK return GetLastError (); } JNIEXPORT void JNICALL Java_com_quickstone_win32_NTService_waitForStart (JNIEnv *env, jobject obj) { WaitForSingleObject (hStartSemaphore, INFINITE); } JNIEXPORT void JNICALL Java_com_quickstone_win32_NTService_waitForStop (JNIEnv *env, jobject obj) { WaitForSingleObject (hStopSemaphore, INFINITE); } JNIEXPORT void JNICALL Java_com_quickstone_win32_NTService_acknowledgeStop (JNIEnv *env, jobject obj) { ReleaseSemaphore (hAckSemaphore, 1, NULL); } JNIEXPORT void JNICALL Java_com_quickstone_win32_NTService_prepareSemaphores (JNIEnv *env, jobject obj) { hStartSemaphore = CreateSemaphore (NULL, 0, 1, NULL); hStopSemaphore = CreateSemaphore (NULL, 0, 1, NULL); hAckSemaphore = CreateSemaphore (NULL, 0, 1, NULL); } jcsp-1.1-rc4.orig/src/org/jcsp/win32/Installing NT Services.txt0000644000000000000000000000246610522104430021016 0ustar Installing NT Services ======================== If you have the resource kit (or windows XP) installed it is recommended that you use the SC command to install the service. In the absence of this, there is an executable file called SVCCTRL which can install and/or remove NT services. The org.win32.dll file should be copied to the WINNT\System32 folder for the Java service wrapper to work. To install the CNS service type: svcctrl install "JCSP.NET:TCPIPCNSServer" "java org.jcsp.net.tcpip.TCPIPCNSServerNT" If present, configuration parameters will be read from the file "JCSPNetCNSService.xml" in the WINNT\System32 folder. A template for this file can be found in "src\com\quickstone\jcsp\net\tcpip". To install the spawning service type: svcctrl install "JCSP.NET:SpawnerService" "java.org.jcsp.net.remote.SpawnerServiceNT" If present, configuration parameters will be read from the file "JCSPNetSpawnerService.xml" in the WINNT\System32 folder. A template for this file can be found in "src\com\quickstone\jcsp\net\remote". To remove these type: svcctrl remove "JCSP.NET:TCPIPCNSServer" svcctrl remove "JCSP.NET:SpawnerService" Note that the system CLASSPATH variable must be set appropriately for these services to start. Error code 1053 is typical of a fault in the classpath.jcsp-1.1-rc4.orig/src/org/jcsp/win32/svcctrl.cpp0000644000000000000000000000565310522104430016270 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2006 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@ukc.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// #include "svcclasses.h" #include #include #include void _tmain (int argc, TCHAR **argv) { CServiceManager mgr(NULL); if (!mgr.ok()) { _ftprintf(stderr, TEXT ("Couldn't open service manager\n")); return; } if ((argc > 1) && (!_tcsicmp(argv[1], TEXT ("install")))) { if (argc != 4) { _ftprintf (stderr, TEXT ("%s install name path\n"), argv[0]); return; } CService svc(&mgr, argv[2]); svc.install(argv[2], argv[2], argv[3]); svc.start (); if (!svc.ok()) { _ftprintf(stderr, TEXT ("Couldn't install service\n")); return; } } else if ((argc > 1) && (!_tcsicmp(argv[1], TEXT ("remove")))) { if (argc != 3) { _ftprintf (stderr, TEXT ("%s remove name\n"), argv[0]); return; } CService svc(&mgr, argv[2]); svc.destroy(); } else { _ftprintf(stderr, TEXT (" %s install\nor %s remove\n"), argv[0], argv[0]); return; } } jcsp-1.1-rc4.orig/src/org/jcsp/win32/svcclasses.h0000644000000000000000000000566310522104430016427 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2006 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@ukc.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// #ifndef __inc_svcclasses_h #define __inc_svcclasses_h #ifndef __cplusplus #error "This file contains C++ classes" #endif /* ifndef __cplusplus */ #include #include class CServiceManager { private: SC_HANDLE schSCManager; friend class CService; public: CServiceManager(TCHAR *machine); ~CServiceManager(void); int ok(void); }; class CService { private: SC_HANDLE schService, schSCManager; public: CService(CServiceManager *mgr, TCHAR *name); ~CService(void); int ok(void); void install(TCHAR *name, TCHAR *disp, TCHAR *path); int destroy(void); int getState(void); int isStarted(void); int isStopped(void); void start(void); void stop(void); }; class CMyService { public: virtual void start (int argc, TCHAR **argv) = 0; virtual void stop (void) = 0; }; void ntservice_schedule (TCHAR *name, CMyService *svc); #endif /* ifndef __inc_svcclasses_h */ jcsp-1.1-rc4.orig/src/org/jcsp/win32/NTService.h0000644000000000000000000000245310520670125016121 0ustar /* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class com_quickstone_win32_NTService */ #ifndef _Included_com_quickstone_win32_NTService #define _Included_com_quickstone_win32_NTService #ifdef __cplusplus extern "C" { #endif /* * Class: com_quickstone_win32_NTService * Method: startDispatcher * Signature: ()I */ JNIEXPORT jint JNICALL Java_com_quickstone_win32_NTService_startDispatcher (JNIEnv *, jobject); /* * Class: com_quickstone_win32_NTService * Method: waitForStart * Signature: ()V */ JNIEXPORT void JNICALL Java_com_quickstone_win32_NTService_waitForStart (JNIEnv *, jobject); /* * Class: com_quickstone_win32_NTService * Method: waitForStop * Signature: ()V */ JNIEXPORT void JNICALL Java_com_quickstone_win32_NTService_waitForStop (JNIEnv *, jobject); /* * Class: com_quickstone_win32_NTService * Method: acknowledgeStop * Signature: ()V */ JNIEXPORT void JNICALL Java_com_quickstone_win32_NTService_acknowledgeStop (JNIEnv *, jobject); /* * Class: com_quickstone_win32_NTService * Method: prepareSemaphores * Signature: ()V */ JNIEXPORT void JNICALL Java_com_quickstone_win32_NTService_prepareSemaphores (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif jcsp-1.1-rc4.orig/src/org/jcsp/win32/NTService.java0000644000000000000000000001573111105701167016617 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.win32; /** *

Abstract class for declaring an NT service. A Java implementation of a service must declare the * startService and stopService methods. startService must run the * actual service and must block until the service is ready to terminate. For example it may sit in a loop * servicing requests. stopService will be called when startService is expected * to stop blocking and return. The stopService method should return promptly. Any time * consuming shutdown code should be done asynchronously (for example in the startService * thread) before startService returns.

* *

For example:

* *
 * public class MyService extends NTService {
 *   boolean running = true;
 *   protected void startService () {
 *     while (running) {
 *       System.beep ();
 *       Thread.sleep (1000);
 *     }
 *   }
 *   protected void stopService () {
 *     running = false;
 *   }
 *   private MyService () {
 *     super ("MyService");
 *   }
 *   public static void main (String[] args) {
 *     new MyService ().run ();
 *   }
 * }
 * 
* * @author Quickstone Technologies Limited */ public abstract class NTService { /** * The name of the service as registered with the NT dispatcher. This really ought to be unique. */ private final String serviceName; /** * Registers a callback function from the DLL with the NT dispatcher and starts the service. */ private native int startDispatcher(); /** * Blocks inside the DLL until the NT service dispatcher is ready to start the service. This is because * the threads allocated by the NT service dispatcher cannot directly call a Java method because there * is no valid JNI environment for them. */ private native void waitForStart(); /** * Blocks inside the DLL until the NT service dispatcher is ready to stop the service. This is because * the threads allocated by the NT service dispatcher cannot directly call a Java method because there * is no valid JNI environment for them. */ private native void waitForStop(); /** * Notifies the NT service dispatcher that the stop has completed and the service has terminated. It is * quite possible that the JVM could terminate abruptly (ie do an equivilant of a System.exit) * once this method has been called. */ private native void acknowledgeStop(); /** * This must be called prior to any of the other methods to initialize the semaphores maintained internally * by the DLL. */ private native void prepareSemaphores(); /** * This will be called when the service is started and must block until the service * completes. */ protected abstract void startService(); /** * This will be called when the service is stopped and the startService method must * terminate. */ protected abstract void stopService(); /** * Will call the user's startService method when the dispatcher requires it. */ private class StarterThread extends Thread { public StarterThread() { setDaemon(true); start(); } public void run() { waitForStart(); startService(); } } /** * Will call the user's stopService method when the dispatcher requires it. */ private class StopperThread extends Thread { public StopperThread() { setDaemon(true); start(); } public void run() { waitForStop(); stopService(); acknowledgeStop(); } } /** * Ensures that the DLL is loaded. */ static { LoadDLL.go(); } /** * Creates a new NT service wrapper with the given name. This name ought to match the name that is * registered with the NT service manager but probably will work if it doesn't. What is more important * is that the name is system unique. */ protected NTService(String serviceName) { this.serviceName = serviceName; } /** * Runs the service, registering it with the NT service dispatcher. If there is a problem this will * terminate the JVM with the Windows error code. If all is okay, this will never return. All subsequent * processing is done by the allocated StarterThread and StopperThread objects * and threads internal to the DLL. */ protected final void run() { prepareSemaphores(); new StarterThread(); new StopperThread(); int ec = startDispatcher(); if (ec != 0) System.exit(ec); } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/0000755000000000000000000000000011410045053013726 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/awt/WindowEventHandler.java0000644000000000000000000001344211105701167020352 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import org.jcsp.lang.*; import java.awt.event.*; /** * @author P.D. Austin and P.H. Welch */ class WindowEventHandler implements WindowListener { /** * The Channel action event notifications are sent down. */ protected ChannelOutput event; /** * constructs a new WindowEventHandler with the specified output Channel. * * @param event The Channel to send the event notification down */ public WindowEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when the Component the event handler is listening to has the window * opened. Notifies the event process that a WindowEvent has * occurred by sending the WindowEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void windowOpened(WindowEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has the window * start to close. Notifies the event process that a WindowEvent has * occurred by sending the WindowEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void windowClosing(WindowEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has the window * closed. Notifies the event process that a WindowEvent has * occurred by sending the WindowEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void windowClosed(WindowEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has the window * iconified. Notifies the event process that a WindowEvent has * occurred by sending the WindowEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void windowIconified(WindowEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has the window * deiconified. Notifies the event process that a WindowEvent has * occurred by sending the WindowEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void windowDeiconified(WindowEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has the window * activated. Notifies the event process that a WindowEvent has * occurred by sending the WindowEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void windowActivated(WindowEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has the window * deactivated. Notifies the event process that a WindowEvent has * occurred by sending the WindowEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void windowDeactivated(WindowEvent e) { event.write(e); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/MouseEventHandler.java0000644000000000000000000000724111105701167020173 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import org.jcsp.lang.*; import java.awt.event.*; /** * @author P.D. Austin and P.H. Welch */ class MouseEventHandler implements MouseListener { /** * The channel down which action event notifications are sent. */ private ChannelOutput event; /** * constructs a new MouseEventHandler with the specified output channel * * @param event the Channel to which to send the event notification */ public MouseEventHandler(ChannelOutput event) { this.event = event; } /** * Assumes the event channel is being serviced (eg by an overwriting channel). * * @param e The parameters associated with this event */ public void mouseClicked(MouseEvent e) { event.write(e); } /** * Assumes the event channel is being serviced (eg by an overwriting channel). * * @param e The parameters associated with this event */ public void mousePressed(MouseEvent e) { event.write(e); } /** * Assumes the event channel is being serviced (eg by an overwriting channel). * * @param e The parameters associated with this event */ public void mouseReleased(MouseEvent e) { event.write(e); } /** * Assumes the event channel is being serviced (eg by an overwriting channel). * * @param e The parameters associated with this event */ public void mouseEntered(MouseEvent e) { event.write(e); } /** * Assumes the event channel is being serviced (eg by an overwriting channel). * * @param e The parameters associated with this event */ public void mouseExited(MouseEvent e) { event.write(e); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveLabel.java0000644000000000000000000003765411105701167016771 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Label java.awt.Label} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveLabel is a process extension of java.awt.Label * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure channel is settable from a constructor. * Event channels can be added to notify the occurrence of any type of Event * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveLabel myLabel = new ActiveLabel ("Look at Me");
 *   myContainer.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringChange the label on the ActiveLabel to the value of the String
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the label is made active
  2. *
  3. If this is the Boolean.FALSE object, * the label is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveLabel.ConfigureInvoke the user-defined Configure.configure method on the label.
Output Channels
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveLabelExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveLabel Example");
 * 
 *     final int nLabels = 8;
 *     final int countdown = 10;
 * 
 *     final One2OneChannel[] configureLabel = Channel.one2oneArray (nLabels);
 * 
 *     final ActiveLabel[] label = new ActiveLabel[nLabels];
 *     for (int i = 0; i < label.length; i++) {
 *       label[i] = new ActiveLabel (configureLabel[i].in (), "==>  " + countdown + "  <==");
 *       label[i].setAlignment (Label.CENTER);
 *     }
 * 
 *     final One2OneChannel configureButton = Channel.one2one ();
 *     final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveButton button = new ActiveButton (configureButton.in (), event.out (), "Start");
 * 
 *     root.setSize (300, 200);
 *     root.setLayout (new GridLayout (3, 3));
 *     for (int i = 0; i < nLabels + 1; i++) {
 *       if (i < 4) {
 *         root.add (label[i]);
 *       } else if (i == 4) {
 *         root.add (button);
 *       } else if (i > 4) {
 *         root.add (label[i - 1]);
 *       }
 *     }
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Parallel (label),
 *         button,
 *         new CSProcess () {
 *           public void run () {
 *             final long second = 1000;
 *             CSTimer tim = new CSTimer ();
 *             Alternative alt = new Alternative (new Guard[] {event.in (), tim});
 *             event.in ().read ();              // wait for the start signal
 *             configureButton.out ().write ("Restart");
 *             int count = countdown;
 *             long timeout = tim.read () + second;
 *             while (count > 0) {
 *               tim.setAlarm (timeout);
 *               switch (alt.priSelect ()) {
 *                 case 0:                 // reset signal
 *                   event.in ().read ();        // clear the reset
 *                   timeout = tim.read () + second;
 *                   count = countdown;
 *                 break;
 *                 case 1:                 // timeout signal
 *                   timeout += second;
 *                   count--;
 *                 break;
 *               }
 *               final String newLabel = "==>  " + count + "  <==";
 *               for (int i = 0; i < nLabels; i++) {
 *                 configureLabel[i].out ().write (newLabel);
 *               }
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see java.awt.Label * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveLabel extends Label implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveLabel with no label or configuration channel. */ public ActiveLabel() { this(""); } /** * Constructs a new ActiveLabel with no configuration channel. * * @param s the initial string displayed on the label. */ public ActiveLabel(String s) { this(null, s); } /** * Constructs a new ActiveLabel with no initial label. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public ActiveLabel(ChannelInput configure) { this(configure, ""); } /** * Constructs a new ActiveLabel. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param s the initial string displayed on the label. */ public ActiveLabel(ChannelInput configure, String s) { super(s); this.configure = configure; } /** * Sets the configuration channel for this ActiveLabel. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param label the Label being configured. */ public void configure(final Label label); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) setText((String) message); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveList.java0000644000000000000000000005062611105701167016657 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.List java.awt.List} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveList is a process extension of java.awt.List * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * When an item in the ActiveList is * double-clicked, its label is written down the event channel. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myListEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 *   final One2OneChannel myListItemEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveList myList = new ActiveList (null, myListEvent.out ());
 *   myList.addItemEventChannel (myListItemEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureString * Empty strings are ignored. If the string is "-*", all items in * the list are removed. Otherwise, if the first character is '-', * the item corresponding to the tail of the string is removed from the list. * Otherwise, the string is added to the end of the list. *
Integer * Sets the selected item in this ActiveList list to be the item * at the specified position. *
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the list is made active
  2. *
  3. If this is the Boolean.FALSE object, * the list is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveList.ConfigureInvoke the user-defined Configure.configure method on the list.
Output Channels
eventString * When an item in the ActiveList is double-clicked, * its label is written down this channel. *
itemEventItemEventSee the {@link #addItemEventChannel * addItemEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveListExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveList Example");
 * 
 *     final One2OneChannel configure = Channel.one2one ();
 * 
 *     final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10));
 *     final One2OneChannel itemEvent = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveList list = new ActiveList (configure.in (), event.out (), 0, true);
 *     list.addItemEventChannel (itemEvent.out ());
 * 
 *     final String[] menu = {"Hello World", "Rocket Science", "CSP",
 *                           "Monitors", "Ignore Me", "Goodbye World"};
 * 
 *     for (int i = 0; i < menu.length; i++) {
 *       list.add (menu[i]);
 *     }
 * 
 *     root.setSize (300, 105);
 *     root.add (list);
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {           // respond to the event channel
 *         list,
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) event.in ().read ();
 *               System.out.println ("                         Action ==> `" + s + "'");
 *               running = (s != menu[menu.length - 1]);
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         },
 *         new CSProcess () {        // respond to the itemEvent channel
 *           public void run () {
 *             while (true) {
 *               final ItemEvent e = (ItemEvent) itemEvent.in ().read ();
 *               final Integer item = (Integer) e.getItem ();
 *               if (e.getStateChange () == ItemEvent.SELECTED) {
 *                 System.out.println ("Selected item " + item);
 *               } else {
 *                 System.out.println ("Unselected item " + item);
 *               }
 *             }
 *           }
 *         },
 *         new CSProcess () {        // dynamically reconfigure the list
 *           public void run () {
 *             CSTimer tim = new CSTimer ();
 *             long timeout = tim.read ();
 *             while (true) {
 *               timeout += 10000;
 *               tim.after (timeout);
 *               System.out.println ("*** Removing last three items ...");
 *               for (int i = 3; i < menu.length; i++) {
 *                 configure.out ().write ("-" + menu[i]);
 *               }
 *               timeout += 10000;
 *               tim.after (timeout);
 *               System.out.println ("*** Restoring last three items ...");
 *               for (int i = 3; i < menu.length; i++) {
 *                 configure.out ().write (menu[i]);
 *               }
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see java.awt.List * @see java.awt.event.ItemEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveList extends List implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs an ActiveList with no visible lines, no configuration * or event channels and only one item selectable. */ public ActiveList() { this(null, null, 0, false); } /** * Constructs an ActiveList with the specified number of visible * lines, but with no configuration or event channels * and only one item selectable. * * @param rows the number of visible lines. */ public ActiveList(int rows) { this(null, null, rows, false); } /** * Constructs an ActiveList with the specified number of visible * lines and a multiple selection option, but with no configuration * or event channels. * * @param rows the number of visible lines. * @param multipleMode the multiple selection option. */ public ActiveList(int rows, boolean multipleMode) { this(null, null, rows, multipleMode); } /** * Constructs an ActiveList with configuration and event channels, * but no visible items and only one item selectable. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the String label from a list item will be output when * it is double-clicked -- can be null if no notification is required. */ public ActiveList(ChannelInput configure, ChannelOutput event) { this(configure, event, 0, false); } /** * Constructs an ActiveList with configuration and event channels, * the specified number of visible lines and only one item selectable. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the String label from a list item will be output when * it is double-clicked -- can be null if no notification is required. * @param rows the number of visible lines. */ public ActiveList(ChannelInput configure, ChannelOutput event, int rows) { this(configure, event, rows, false); } /** * Constructs an ActiveList with configuration and event channels, * the specified number of visible lines and a multiple selection option. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the String label from a list item will be output when * it is double-clicked -- can be null if no notification is required. * @param rows the number of visible lines. * @param multipleMode the multiple selection option. */ public ActiveList(ChannelInput configure, ChannelOutput event, int rows, boolean multipleMode) { super(rows, multipleMode); if (event != null) { ActionEventHandler handler = new ActionEventHandler(event); addActionListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveList. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * an ItemEvent has occurred. This should be used * instead of registering a ItemListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param itemEvent the channel down which to send ItemEvents. */ public void addItemEventChannel(ChannelOutput itemEvent) { if (itemEvent != null) { ItemEventHandler handler = new ItemEventHandler(itemEvent); addItemListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param list the List being configured. */ public void configure(final List list); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) { String s = (String) message; if (s.length() > 0) { if (s.equals("-*")) removeAll(); else if (s.charAt(0) == '-') remove(s.substring(1)); else add(s); } } else if (message instanceof Integer) select(((Integer) message).intValue()); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ComponentEventHandler.java0000644000000000000000000001052011105701167021037 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.event.*; import org.jcsp.lang.*; /** * @author P.D. Austin and P.H. Welch */ class ComponentEventHandler implements ComponentListener { /** * The Channel action event notifications are sent down. */ private ChannelOutput event; /** * constructs a new ComponentEventHandler with the specified event output * Channel. * * @param event The Channel to send the event notification down */ public ComponentEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when the component the event handler is listening to is resized. * Notifies the event process that an ComponentEvent has occurred by sending * the ComponentEvent Object. Some notifications will be lost so there are no * guarantees that all events generated will be processed. * * @param e The parameters associated with this event */ public void componentResized(ComponentEvent e) { event.write(e); } /** * Invoked when the component the event handler is listening to is moved. * Notifies the event process that an ComponentEvent has occurred by sending * the ComponentEvent Object. Some notifications will be lost so there are no * guarantees that all events generated will be processed. * * @param e The parameters associated with this event */ public void componentMoved(ComponentEvent e) { event.write(e); } /** * Invoked when the component the event handler is listening to is shown. * Notifies the event process that an ComponentEvent has occurred by sending * the ComponentEvent Object. Some notifications will be lost so there are no * guarantees that all events generated will be processed. * * @param e The parameters associated with this event */ public void componentShown(ComponentEvent e) { event.write(e); } /** * Invoked when the component the event handler is listening to is hidden. * Notifies the event process that an ComponentEvent has occurred by sending * the ComponentEvent Object. Some notifications will be lost so there are no * guarantees that all events generated will be processed. * * @param e The parameters associated with this event */ public void componentHidden(ComponentEvent e) { event.write(e); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveTextEnterField.java0000644000000000000000000004107511105701167020630 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.event.*; /** * A specialisation of {@link ActiveTextField} that writes text to * the event channel only when ENTER or ESCAPE is pressed. *

Process Diagram

*

*

*

Description

* ActiveTextEnterField is a process containing an {@link ActiveTextField ActiveTextField}, * configured with channels for event notification and configuration. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. *

* The difference between this class and ActiveTextField is that text * is only written to the event channel when ENTER or ESCAPE is pressed on * the text field (not on every keystroke). When this happens, the text field * is temporarilly disabled for (by default) half a second; this is to give * feedback to the user. The disable period can be changed by calling the * setDisableTime method before the process is run. *

* The internal ActiveTextField can be extracted with the getActiveTextField method. * Channels can then be added to notify the occurrence of any other type of Event * the ActiveFrame generates. This is done by calling its appropriate * addXXXEventChannel method * (before the process is run). As many channels can be added as are needed. *

* Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that the output channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. The simplest way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myTextFieldEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveTextEnterField myTextEnterField =
 *     new ActiveTextEnterField (null, myTextFieldEvent.out (), "Edit Me");
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringSet the text in this ActiveTextEnterField to the value of the String
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the text field is made active
  2. *
  3. If this is the Boolean.FALSE object, * the text field is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveTextField.ConfigureInvoke the user-defined Configure.configure method on the textField.
otherwiseAppend the toString form of the object to the text in this ActiveTextField.
Output Channels
eventStringThe text in the ActiveTextEnterField (whenever ENTER or ESCAPE is pressed)
componentEventComponentEventSee the * {@link #getActiveTextField getActiveTextField}.{@link ActiveTextField#addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the * {@link #getActiveTextField getActiveTextField}.{@link ActiveTextField#addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the * {@link #getActiveTextField getActiveTextField}.{@link ActiveTextField#addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the * {@link #getActiveTextField getActiveTextField}.{@link ActiveTextField#addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the * {@link #getActiveTextField getActiveTextField}.{@link ActiveTextField#addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * import java.awt.*;
 * 
 * public class ActiveTextEnterFieldExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame frame =
 *       new ActiveClosingFrame ("ActiveTextEnterField Example");
 * 
 *     final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final String[] string =
 *       {"Entia Non Sunt Multiplicanda Praeter Necessitatem",
 *        "Less is More ... More or Less",
 *        "Everything we do, we do it to you",
 *        "Race Hazards - What Rice Hozzers?",
 *        "Cogito Ergo Occam"};
 * 
 *     final String goodbye = "Goodbye World";
 * 
 *     final ActiveTextEnterField[] activeText =
 *       new ActiveTextEnterField[string.length];
 * 
 *     for (int i = 0; i < string.length; i++) {
 *       activeText[i] = new ActiveTextEnterField (null, event.out (), string[i]);
 *     }
 * 
 *     Panel panel = new Panel (new GridLayout (string.length, 1));
 *     for (int i = 0; i < string.length; i++) {
 *       panel.add (activeText[i].getActiveTextField ());
 *     }
 * 
 *     final Frame realFrame = frame.getActiveFrame ();
 *     realFrame.setBackground (Color.green);
 *     realFrame.add (panel);
 *     realFrame.pack ();
 *     realFrame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         frame,
 *         new Parallel (activeText),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               String s = (String) event.in ().read ();
 *               System.out.println (s);
 *               running = (! s.equals (goodbye));
 *             }
 *             realFrame.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveTextField * @see java.awt.TextField * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveTextEnterField implements CSProcess { private AltingChannelInput configure; private ChannelOutput event; private String s; private int columns; private long disableTime = 500; private ActiveTextField field; private One2OneChannel keyEvent = Channel.one2one(new OverWriteOldestBuffer(10)); private One2OneChannel textEvent = Channel.one2one(new OverWriteOldestBuffer(10)); private One2OneChannel configureA = Channel.one2one(); private One2OneChannel configureB = Channel.one2one(); /** * Constructs a new ActiveTextEnterField with configuration and event channels, * but no initial text. * * @param configure the AltingChannelInput for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the ENTER or ESCAPE key is pressed * -- can be null if no notification is required. */ public ActiveTextEnterField(AltingChannelInput configure, ChannelOutput event) { this(configure, event, "", 0); } /** * Constructs a new ActiveTextEnterField with configuration and event channels, * initial text and default width. * * @param configure the AltingChannelInput for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the ENTER or ESCAPE key is pressed * -- can be null if no notification is required. * @param s the initial text displayed in the field. */ public ActiveTextEnterField(AltingChannelInput configure, ChannelOutput event, String s) { this(configure, event, s, s.length()); } /** * Constructs a new ActiveTextEnterField with configuration and event channels, * initial text and width. * * @param configure the AltingChannelInput for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the ENTER or ESCAPE key is pressed * -- can be null if no notification is required. * @param s the initial text displayed in the field. * @param columns the width of the field. */ public ActiveTextEnterField(AltingChannelInput configure, ChannelOutput event, String s, int columns) { if (configure == null) this.configure = Channel.one2one().in(); // the Plex2 process must have non-null channels else this.configure = configure; this.event = event; this.s = s; this.columns = columns; this.field = new ActiveTextField(configureB.in(), textEvent.out(), s, columns); } /** * Sets the configuration channel for this ActiveTextEnterField. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(AltingChannelInput configure) { if (configure != null) this.configure = configure; // the Plex2 process must have non-null channels } /** * This is used to set the time during which the text field is disabled * after an ENTER or ESCAPE has been entered. *

* NOTE: This may only be called before this process is run. * * @param disableTime the disable time after an ENTER or ESCAPE. */ public void setDisableTime(final long disableTime) { this.disableTime = disableTime; } /** * This is used to get the ActiveTextField within this component * so that it can be configured (using {@link java.awt.TextField} or * {@link org.jcsp.awt.ActiveTextField} methods) or added to some container. * For example, event channels can be added by invoking * getActiveTextField().addXXXEventChannel(...). *

* NOTE: such configuration must be finished before this process is run. *

* NOTE: do not use this method to set a configure channel - use an appropriate * constructor or {@link #setConfigureChannel setConfigureChannel}. * * @return the ActiveTextField within this component. */ public ActiveTextField getActiveTextField() { return field; } /** * The main body of this process. */ public void run() { field.addKeyEventChannel(keyEvent.out()); new Parallel(new CSProcess[] { new Plex2(configure, configureA.in(), configureB.out()), field, new CSProcess() { public void run() { CSTimer tim = new CSTimer(); Guard[] guard = {keyEvent.in(), textEvent.in()}; Alternative alt = new Alternative(guard); String text = s; ChannelInput keyEventIn = keyEvent.in(); ChannelInput textEventIn = textEvent.in(); ChannelOutput configureAOut = configureA.out(); while (true) { switch (alt.priSelect()) { case 0: final KeyEvent key = (KeyEvent) keyEventIn.read(); switch (key.getKeyCode()) { case KeyEvent.VK_ENTER: case KeyEvent.VK_ESCAPE: switch (key.getID()) { case KeyEvent.KEY_PRESSED: if (event != null) event.write(text); configureAOut.write(Boolean.FALSE); tim.after(tim.read() + disableTime); configureAOut.write(Boolean.TRUE); break; } break; } break; case 1: text = (String) textEventIn.read(); break; } } } } }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/DisplayList.java0000644000000000000000000006556011105701167017054 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; /** * This implements the {@link Display} and {@link Paintable} interfaces and provides * a channel-like connection between user processes and an active graphics component. *

Description

* A DisplayList is a passive object providing graphics services on behalf * of a CSProcess. It provides an occam3-like CALL * channel between the application CSProcess and the active graphics component * (such as {@link ActiveCanvas ActiveCanvas}) * on which it wishes to draw. * *

* * The user process {@link #set set}s, {@link #extend extend}s or {@link #change change}s * a list of {@link GraphicsCommand GraphicsCommand}s maintained by the DisplayList. * Any such operation causes the Java Event thread to call back, via the active graphics * component, on its {@link #paint paint} or {@link #update update} methods and execute * those commands. *

* The user process sees the {@link Display Display} interface to the DisplayList * (in the same way as a writer process sees the OutputChannel interface to * a Channel). The ActiveCanvas process sees the {@link Paintable Paintable} * interface to the DisplayList (in the same way as a reader process sees * the InputChannel interface to a Channel). *

* Unlike a Channel, however, a DisplayList should never block * any of its attached processes indefinitely, regardless of the behaviour of its * partner at the other end. * The DisplayList imposes mutually exclusive access to its state and * there are no wait/notify operations -- so any delays should be transient. * User process sets/extends/changes and ActiveCanvas * paints/updates on the DisplayList, therefore, should always succeed. *

* Note: the cautionary note in the above paragraph is because Java * makes no guarantee that any invocation of a synchronized method * ever takes place. This is something with which any Java application has to live. *

* Any number of user processes may draw on the same component via a DisplayList * -- i.e. it is a any-one channel. * By reserving different sections of a DisplayList for control by different * processes, complex multiple animations can be simply managed. *

* Note: in this release, only the {@link #extend extend} and * {@link #change change} methods are safe for direct use by multiple * user processes on the same DisplayList. A process should only invoke * {@link #set set} at times when it knows others cannot be operating * on that DisplayList. This would normally be required by an application, * since a DisplayList reset invalidates the result * returned by a previous extend and the base index used in * a change -- i.e. concurrent processes doing these things will need * to be informed before they do them again! However, if the list really needs concurrent * setting without such an arrangement, this can be done within * a synchronized block on the DisplayList. *

* User applications will not normally be implementing new processes that are at the receiving * end of a DisplayList. Users will only be responsible for connecting a DisplayList * to a standard org.jcsp.awt drawing component. This can either be done statically (e.g. * through {@link ActiveCanvas#setPaintable setPaintable}) or dynamically (by sending * a {@link GraphicsProtocol.SetPaintable} object through * a {@link GraphicsProtocol} channel). * * @see org.jcsp.awt.GraphicsCommand * @see org.jcsp.awt.Display * @see org.jcsp.awt.Paintable * @see org.jcsp.awt.ActiveCanvas * * @author P.H. Welch */ public class DisplayList implements Paintable, Display { private Component component; private Dimension size; // *** private Image image; // *** private Graphics imageGraphics; // *** private final int INITIAL_MAX_COMMANDS = 10; private GraphicsCommand[] command = new GraphicsCommand[INITIAL_MAX_COMMANDS]; private int maxCommands = INITIAL_MAX_COMMANDS; private int nCommands = 0; private int updateIndex = 0; // invariant: 0 <= updateIndex <= nCommands <= maxCommands private boolean refresh = false; private boolean updated = true; private long minRefreshInterval = 10; // milliseconds /** * Sets the array of GraphicsCommands to be executed. The commands will * be executed in ascending order of index. * The repaint method of the registered component is called to trigger * the {@link #update update} callback on this object. * All commands will be executed. *

* * @param c the array of GraphicsCommands to be executed. */ public void set(final GraphicsCommand[] c) { if (c != null) { final int n = c.length; if (n > 0) { if (n <= maxCommands) { synchronized (this) { System.arraycopy(c, 0, command, 0, n); nCommands = n; updateIndex = 0; refresh = true; } } else { maxCommands = 2*n; final GraphicsCommand[] tmp = new GraphicsCommand[maxCommands]; System.arraycopy(c, 0, tmp, 0, n); synchronized (this) { command = tmp; nCommands = n; updateIndex = 0; refresh = true; } } } } component.repaint(minRefreshInterval); } /** * Sets the GraphicsCommand to be executed. * The repaint method of the registered component is called to trigger * the {@link #update update} callback on this object. *

* * @param c the GraphicsCommand to be executed. */ public void set(final GraphicsCommand c) { if (c != null) { synchronized (this) { command[0] = c; nCommands = 1; updateIndex = 0; refresh = true; } } component.repaint(minRefreshInterval); } /** * Extends the array of GraphicsCommands to be executed. * The repaint method of the registered component is called to trigger * the {@link #update update} callback on this object. * Only the new commands will be executed. *

* * @param c the extra GraphicsCommands to be executed. * @return the start index of the extension. */ public synchronized int extend(final GraphicsCommand[] c) { final int extensionStart = nCommands; if (c != null) { final int n = c.length; if (n > 0) { final int newNcommands = extensionStart + n; if (newNcommands <= maxCommands) { System.arraycopy(c, 0, command, extensionStart, n); if (updated) { updateIndex = extensionStart; updated = false; } nCommands = newNcommands; } else { maxCommands = 2*newNcommands; final GraphicsCommand[] tmp = new GraphicsCommand[maxCommands]; System.arraycopy(command, 0, tmp, 0, extensionStart); System.arraycopy(c, 0, tmp, extensionStart, n); command = tmp; if (updated) { updateIndex = extensionStart; updated = false; } nCommands = newNcommands; } } } component.repaint(minRefreshInterval); return extensionStart; } /** * Extends the array of GraphicsCommands to be executed by one command. * The repaint method of the registered component is called to trigger * the {@link #update update} callback on this object. * Only the new command will be executed. *

* * @param c the extra GraphicsCommand to be executed. * @return the start index of the extension. */ public synchronized int extend(final GraphicsCommand c) { final int extensionStart = nCommands; if (c != null) { final int newNcommands = extensionStart + 1; if (newNcommands <= maxCommands) { command[extensionStart] = c; if (updated) { updateIndex = extensionStart; updated = false; } nCommands = newNcommands; } else { maxCommands = 2*newNcommands; final GraphicsCommand[] tmp = new GraphicsCommand[maxCommands]; System.arraycopy(command, 0, tmp, 0, extensionStart); tmp[extensionStart] = c; command = tmp; if (updated) { updateIndex = extensionStart; updated = false; } nCommands = newNcommands; } } component.repaint(minRefreshInterval); return extensionStart; } /** * Changes the array of GraphicsCommands to be executed by replacing elements * i onwards with the new ones. There must be at least (i + c.length) * elements in the original array -- else this method will not change anything and will * return false. * The repaint method of the registered component is called to trigger * the {@link #update update} callback on this object. * All commands will be executed. *

* * @param c the new GraphicsCommands to be executed. * @param i the start index for the replacement. * @return true if and only if the changes are successfully made. */ public boolean change(final GraphicsCommand[] c, final int i) { if (c != null) { final int n = c.length; if (n > 0) { if ((i + n) <= nCommands) { synchronized (this) { System.arraycopy(c, 0, command, i, n); updateIndex = 0; refresh = true; } } else { return false; } } } component.repaint(minRefreshInterval); return true; } /** * Changes the array of GraphicsCommands to be executed by replacing element * i with the new one. There must be at least (i + 1) * elements in the original array -- else this method will not change anything and will * return false. * The repaint method of the registered component is called to trigger * the {@link #update update} callback on this object. * All commands will be executed. *

* * @param c the new GraphicsCommand to be executed. * @param i the index for the replacement. * @return true if and only if the change is successfully made. */ public boolean change(final GraphicsCommand c, final int i) { if (c != null) { if (i < nCommands) { synchronized (this) { command[i] = c; updateIndex = 0; refresh = true; } } else return false; } component.repaint(minRefreshInterval); return true; } /** * Returns a copy of the array of GraphicsCommands currently held. *

* * @return a copy of the array of GraphicsCommands currently held. */ public GraphicsCommand[] get() { final GraphicsCommand[] c = new GraphicsCommand[nCommands]; synchronized (this) { System.arraycopy(command, 0, c, 0, nCommands); } return c; } /** * Sets the repaint interval invoked by the {@link #set set}, * {@link #extend extend} and {@link #change change} commands. * The default is 10 milliseconds (the normal default for the * {@link java.awt.Component#repaint repaint} method from {@link java.awt.Component}). *

* * @param minRefreshInterval the display commands will be executed at most once * per minRefreshInterval milliseconds. */ public void setMinRefreshInterval(final long minRefreshInterval) { this.minRefreshInterval = minRefreshInterval; } private void execute(int start, Graphics g) { for (int i = start; i < nCommands; i++) { final GraphicsCommand c = command[i]; switch (c.tag) { case GraphicsCommand.NULL_TAG: // do nothing break; case GraphicsCommand.TRANSLATE: final GraphicsCommand.Translate t = (GraphicsCommand.Translate) c; g.translate(t.x, t.y); break; case GraphicsCommand.SET_COLOR: final GraphicsCommand.SetColor sc = (GraphicsCommand.SetColor) c; g.setColor(sc.c); break; case GraphicsCommand.SET_PAINT_MODE_TAG: g.setPaintMode(); break; case GraphicsCommand.SET_XOR_MODE: final GraphicsCommand.SetXORMode sx = (GraphicsCommand.SetXORMode) c; g.setXORMode(sx.c); break; case GraphicsCommand.SET_FONT: final GraphicsCommand.SetFont sf = (GraphicsCommand.SetFont) c; g.setFont(sf.f); break; case GraphicsCommand.CLIP_RECT: final GraphicsCommand.ClipRect clr = (GraphicsCommand.ClipRect) c; g.clipRect(clr.x, clr.y, clr.width, clr.height); break; case GraphicsCommand.SET_CLIP: final GraphicsCommand.SetClip scl = (GraphicsCommand.SetClip) c; switch (scl.cliptag) { case 0: g.setClip(scl.x, scl.y, scl.width, scl.height); break; case 1: g.setClip(scl.s); break; } break; case GraphicsCommand.COPY_AREA: final GraphicsCommand.CopyArea ca = (GraphicsCommand.CopyArea) c; g.copyArea(ca.x, ca.y, ca.width, ca.height, ca.dx, ca.dy); break; case GraphicsCommand.DRAW_LINE: final GraphicsCommand.DrawLine dl = (GraphicsCommand.DrawLine) c; g.drawLine(dl.x1, dl.y1, dl.x2, dl.y2); break; case GraphicsCommand.FILL_RECT: final GraphicsCommand.FillRect fr = (GraphicsCommand.FillRect) c; g.fillRect(fr.x, fr.y, fr.width, fr.height); break; case GraphicsCommand.DRAW_RECT: final GraphicsCommand.DrawRect dr = (GraphicsCommand.DrawRect) c; g.drawRect(dr.x, dr.y, dr.width, dr.height); break; case GraphicsCommand.CLEAR_RECT: final GraphicsCommand.ClearRect cr = (GraphicsCommand.ClearRect) c; g.clearRect(cr.x, cr.y, cr.width, cr.height); break; case GraphicsCommand.DRAW_ROUND_RECT: final GraphicsCommand.DrawRoundRect drr = (GraphicsCommand.DrawRoundRect) c; g.drawRoundRect(drr.x, drr.y, drr.width, drr.height, drr.arcWidth, drr.arcHeight); break; case GraphicsCommand.FILL_ROUND_RECT: final GraphicsCommand.FillRoundRect frr = (GraphicsCommand.FillRoundRect) c; g.fillRoundRect(frr.x, frr.y, frr.width, frr.height, frr.arcWidth, frr.arcHeight); break; case GraphicsCommand.DRAW_3D_RECT: final GraphicsCommand.Draw3DRect d3r = (GraphicsCommand.Draw3DRect) c; g.draw3DRect(d3r.x, d3r.y, d3r.width, d3r.height, d3r.raised); break; case GraphicsCommand.FILL_3D_RECT: final GraphicsCommand.Fill3DRect f3r = (GraphicsCommand.Fill3DRect) c; g.fill3DRect(f3r.x, f3r.y, f3r.width, f3r.height, f3r.raised); break; case GraphicsCommand.DRAW_OVAL: final GraphicsCommand.DrawOval dov = (GraphicsCommand.DrawOval) c; g.drawOval(dov.x, dov.y, dov.width, dov.height); break; case GraphicsCommand.FILL_OVAL: final GraphicsCommand.FillOval fov = (GraphicsCommand.FillOval) c; g.fillOval(fov.x, fov.y, fov.width, fov.height); break; case GraphicsCommand.DRAW_ARC: final GraphicsCommand.DrawArc da = (GraphicsCommand.DrawArc) c; g.drawArc(da.x, da.y, da.width, da.height, da.startAngle, da.arcAngle); break; case GraphicsCommand.FILL_ARC: final GraphicsCommand.FillArc fa = (GraphicsCommand.FillArc) c; g.fillArc(fa.x, fa.y, fa.width, fa.height, fa.startAngle, fa.arcAngle); break; case GraphicsCommand.DRAW_POLYLINE: final GraphicsCommand.DrawPolyline dpl = (GraphicsCommand.DrawPolyline) c; g.drawPolyline(dpl.xPoints, dpl.yPoints, dpl.nPoints); break; case GraphicsCommand.DRAW_POLYGON: final GraphicsCommand.DrawPolygon dpg = (GraphicsCommand.DrawPolygon) c; switch (dpg.polytag) { case 0: g.drawPolygon(dpg.xPoints, dpg.yPoints, dpg.nPoints); break; case 1: g.drawPolygon(dpg.p); break; } break; case GraphicsCommand.FILL_POLYGON: final GraphicsCommand.FillPolygon fpg = (GraphicsCommand.FillPolygon) c; switch (fpg.polytag) { case 0: g.fillPolygon(fpg.xPoints, fpg.yPoints, fpg.nPoints); break; case 1: g.fillPolygon(fpg.p); break; } break; case GraphicsCommand.DRAW_STRING: final GraphicsCommand.DrawString ds = (GraphicsCommand.DrawString) c; g.drawString(ds.string, ds.x, ds.y); break; case GraphicsCommand.DRAW_CHARS: final GraphicsCommand.DrawChars dc = (GraphicsCommand.DrawChars) c; g.drawChars(dc.data, dc.offset, dc.length, dc.x, dc.y); break; case GraphicsCommand.DRAW_BYTES: final GraphicsCommand.DrawBytes db = (GraphicsCommand.DrawBytes) c; g.drawBytes(db.data, db.offset, db.length, db.x, db.y); break; case GraphicsCommand.DRAW_IMAGE: final GraphicsCommand.DrawImage di = (GraphicsCommand.DrawImage) c; switch (di.drawtag) { case 0: g.drawImage(di.image, di.x, di.y, component); break; case 1: g.drawImage(di.image, di.x, di.y, di.width, di.height, component); break; case 2: g.drawImage(di.image, di.x, di.y, di.bgcolor, component); break; case 3: g.drawImage(di.image, di.x, di.y, di.width, di.height, di.bgcolor, component); break; case 4: g.drawImage(di.image, di.dx1, di.dy1, di.dx2, di.dy2, di.sx1, di.sy1, di.sx2, di.sy2, component); break; case 5: g.drawImage(di.image, di.dx1, di.dy1, di.dx2, di.dy2, di.sx1, di.sy1, di.sx2, di.sy2, di.bgcolor, component); break; } break; case GraphicsCommand.GENERAL: final GraphicsCommand.General general = (GraphicsCommand.General) c; general.g.doGraphic(g, component); break; } } } /** * Register the Component that will delegate its paint and * update methods here. Only the JCSP Active component should * perform this registration (in response to being passed this Paintable). *

* * @param c the Component that will do the delegating. */ public synchronized void register(final Component c) { component = c; } /** * This is the call-back delegated here by the registered Component. * It will normally be the JVM event thread that is making this call. *

* * @param g the graphics context for the painting. */ public synchronized void paint(final Graphics g) { final Dimension newSize = component.getSize(); if (image == null) { size = newSize; image = component.createImage(size.width, size.height); imageGraphics = image.getGraphics(); } else if ((newSize.width != size.width) || (newSize.height != size.height)) { size = newSize; image = component.createImage(size.width, size.height); imageGraphics = image.getGraphics(); } execute(0, imageGraphics); g.drawImage(image, 0, 0, component); refresh = false; } /** * This is the call-back delegated here by the registered Component. * It will normally be the JVM event thread that is making this call. *

* * @param g the graphics context for the painting. */ public synchronized void update(final Graphics g) { if (refresh) { final Dimension newSize = component.getSize(); if (image == null) { size = newSize; image = component.createImage(size.width, size.height); imageGraphics = image.getGraphics(); } else if ((newSize.width != size.width) || (newSize.height != size.height)) { size = newSize; image = component.createImage(size.width, size.height); imageGraphics = image.getGraphics(); } execute(0, imageGraphics); g.drawImage(image, 0, 0, component); refresh = false; updated = true; } else { final Dimension newSize = component.getSize(); if (image == null) { size = newSize; image = component.createImage(size.width, size.height); imageGraphics = image.getGraphics(); } else if ((newSize.width != size.width) || (newSize.height != size.height)) { size = newSize; image = component.createImage(size.width, size.height); imageGraphics = image.getGraphics(); } execute(updateIndex, imageGraphics); g.drawImage(image, 0, 0, component); updated = true; } } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/TextEventHandler.java0000644000000000000000000000566711105701167020041 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; /** * @author P.D. Austin and P.H. Welch */ class TextEventHandler implements TextListener { /** * The Channel TextEvent notifications are sent down. */ private ChannelOutput event; /** * constructs a new TextEventHandler with the specified event Channel. * * @param event The Channel TextEvent notifications are sent down. */ public TextEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when an Text change occurs on the component the event handler is * listening to. Notifies the event process that an TextEvent has * occurred. Some notifications will be lost so there are no guarantees * that all events generated will be processed. * * @param e The parameters associated with this event */ public void textValueChanged(TextEvent e) { event.write(((TextComponent)e.getSource()).getText()); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/KeyEventHandler.java0000644000000000000000000000751011105701167017632 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import org.jcsp.lang.*; import java.awt.event.*; /** * @author P.D. Austin and P.H. Welch */ class KeyEventHandler implements KeyListener { /** * The Channel action event notifications are sent down. */ private ChannelOutput event; /** * constructs a new KeyEventHandler with the specified output Channel. * * @param event The Channel to send the event notification down */ public KeyEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when the Component the event handler is listening to has a key * pressed and then released. Notifies the event process that a KeyEvent has * occurred by sending the KeyEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void keyTyped(KeyEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has a key * pressed. Notifies the event process that a KeyEvent has * occurred by sending the KeyEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void keyPressed(KeyEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has a key * released. Notifies the event process that a KeyEvent has * occurred by sending the KeyEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void keyReleased(KeyEvent e) { event.write(e); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/Paintable.java0000644000000000000000000001054511105701167016503 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.Graphics; import java.awt.Component; /** * Active components may delegate their paint and update * methods to objects implementing this interface. *

Description

* Objects implementing Paintable may be passed to an Active * component (such as {@link ActiveCanvas}). The Active component will * then {@link #register register} with the Paintable object * and delegate to it its paint and update methods. *

* The Paintable object may either be passed statically * (via the component's {@link ActiveCanvas#setPaintable setPaintable} * method, before the component starts running) or dynamically * (via the component's * {@link ActiveCanvas#setGraphicsChannels toGraphics/fromGraphics} * channels). *

* Note: these operations are currently supported only for * {@link ActiveCanvas ActiveCanvas} components. *

* A CSProcess may choose to implement Paintable itself and take * responsibility for its own painting/updating. However, this would break the JCSP * design pattern that the thread(s) of control within a running process have exclusive * access to the process state (since painting/updating is actually done by the * Java event thread). It is, therefore, better to delegate this task to * a different (and passive) object such as a {@link DisplayList}. * * @see org.jcsp.awt.ActiveCanvas * @see org.jcsp.awt.DisplayList * * @author P.H. Welch */ public interface Paintable { /** * Register the Component that will delegate its paint and * update methods here. * * @param c the Component that will do the delegating. */ public void register(final Component c); /** * This is the call-back delegated here by the registered Component. * It will normally be the JVM event thread that is making this call. * * @param g the graphics context for the painting. */ public void paint(final Graphics g); /** * This is the call-back delegated here by the registered Component. * It will normally be the JVM event thread that is making this call. * * @param g the graphics context for the painting. */ public void update(final Graphics g); }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveScrollPane.java0000644000000000000000000003740111105701167020002 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.ScrollPane java.awt.ScrollPane} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveScrollPane is a process extension of java.awt.ScrollPane * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure channel is settable from a constructor. * Event channels can be added to notify the occurrence of any type of Event * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveScrollPane myScrollPane = new ActiveScrollPane ();
 *   myScrollPane.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureActiveScrollPane.ConfigureInvoke the user-defined Configure.configure method on the scrollPane.
Output Channels
containerEventContainerEventSee the {@link #addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.util.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveScrollPaneExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveScrollPane Example");
 * 
 *     final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveScrollPane scrollPane = new ActiveScrollPane ();
 *     scrollPane.addMouseEventChannel (mouseEvent.out ());
 * 
 *     root.add (scrollPane);
 *     root.setSize (400, 400);
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         scrollPane,
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final MouseEvent event = (MouseEvent) mouseEvent.in ().read ();
 *               switch (event.getID ()) {
 *                 case MouseEvent.MOUSE_ENTERED:
 *                   System.out.println ("MOUSE_ENTERED");
 *                 break;
 *                 case MouseEvent.MOUSE_EXITED:
 *                   System.out.println ("MOUSE_EXITED");
 *                 break;
 *                 case MouseEvent.MOUSE_PRESSED:
 *                   System.out.println ("MOUSE_PRESSED");
 *                 break;
 *                 case MouseEvent.MOUSE_RELEASED:
 *                   System.out.println ("MOUSE_RELEASED");
 *                 break;
 *                 case MouseEvent.MOUSE_CLICKED:
 *                   if (event.getClickCount() > 1) {
 *                     System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!");
 *                     running = false;
 *                   } else {
 *                     System.out.println ("MOUSE_CLICKED ... *double* click to quit!");
 *                   }
 *                 break;
 *               }
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.ScrollPane * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveScrollPane extends ScrollPane implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveScrollPane with a display policy of * java.awt.ScrollPane.SCROLLBARS_AS_NEEDED and without a configure * channel. */ public ActiveScrollPane() { this(SCROLLBARS_AS_NEEDED, null); } /** * Constructs a new ActiveScrollPane without a configure * channel. * * @param scrollbarDisplayPolicy - policy for when scrollbars should be shown * (java.awt.ScrollPane.SCROLLBARS_AS_NEEDED, SCROLLBARS_ALWAYS, * SCROLLBARS_NEVER). */ public ActiveScrollPane(int scrollbarDisplayPolicy) { this(scrollbarDisplayPolicy, null); } /** * Constructs a new ActiveScrollPane. * * @param scrollbarDisplayPolicy - policy for when scrollbars should be shown * (java.awt.ScrollPane.SCROLLBARS_AS_NEEDED, SCROLLBARS_ALWAYS, * SCROLLBARS_NEVER). * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public ActiveScrollPane(int scrollbarDisplayPolicy, ChannelInput configure) { super(scrollbarDisplayPolicy); this.configure = configure; } /** * Sets the configuration channel for this ActiveScrollPane. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ContainerEvent has occurred. This should be used * instead of registering a ContainerListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param containerEvent the channel down which to send ContainerEvents. */ public void addContainerEventChannel(ChannelOutput containerEvent) { if (containerEvent != null) { ContainerEventHandler handler = new ContainerEventHandler(containerEvent); addContainerListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param scrollPane the ScrollPane being configured. */ public void configure(final ScrollPane scrollPane); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveMenu.java0000644000000000000000000003331411105701167016643 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Menu java.awt.Menu} * with a channel interface. *

Process Diagram

*

*

*

Description

* ActiveMenu is a process extension of java.awt.Menu * with channels for run-time configuration and event notification. The event channel * should be connected to an application-specific server process (instead * of registering a passive object as a Listener to this component). *

* The configure and event channels are * settable from a constructor. * The event channel delivers the command string associated with this * ActiveMenu whenever it is selected. * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service the event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that a (non-null) event channel from this process is * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMenuEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveMenu myMenu =
 *     new ActiveMenu (null, myMenuEvent.out (), "Look at this");
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringChange the label on the ActiveMenu to the value of the String
java.awt.MenuShortcutSets the MenuShortcut for the ActiveMenu
Integer * Inserts a separator at the specified position. *
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the menu is made active
  2. *
  3. If this is the Boolean.FALSE object, * the menu is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveMenu.ConfigureInvoke the user-defined Configure.configure method on the activeMenu.
Output Channels
eventStringThe command for the ActiveMenu (when the menu is selected)
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveMenuExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame activeClosingFrame =
 *       new ActiveClosingFrame ("ActiveCheckboxMenuItem Example");
 * 
 *     final ActiveFrame frame = activeClosingFrame.getActiveFrame ();
 * 
 *     final MenuBar menuBar = new MenuBar ();
 *     frame.setMenuBar (menuBar);
 * 
 *     final Menu fileMenu = new Menu ("File");
 *     menuBar.add (fileMenu);
 * 
 *     final String[] fileOptions = {"Hello World", "Rocket Science", "CSP",
 *                                   "Monitors", "Ignore Me", "Goodbye World"};
 * 
 *     final Any2OneChannel event[] = Channel.any2oneArray (2, new OverWriteOldestBuffer (10));
 * 
 *     final ActiveMenuItem[] fileMenuItem =
 *       new ActiveMenuItem[fileOptions.length];
 *     for (int i = 0; i < fileOptions.length; i++) {
 *       fileMenuItem[i] = new ActiveMenuItem (null, event[0].out (), fileOptions[i]);
 *       fileMenu.add (fileMenuItem[i]);
 *     }
 * 
 *     fileMenu.addSeparator ();
 * 
 *     final Any2OneChannel langConfigure = Channel.any2one ();
 *     final ActiveMenu langMenu = new ActiveMenu (langConfigure.in (), null, "Language");
 *     fileMenu.add (langMenu);  // set up the active langMenu as a sub-menu
 * 
 *     final String[] langOptions = {"occam-pi", "Java", "Smalltalk", "Algol-60",
 *                                   "Pascal", "Haskell", "SML", "Lisp"};
 * 
 *     final ActiveCheckboxMenuItem[] langCheckboxMenuItem =
 *       new ActiveCheckboxMenuItem[langOptions.length];
 *     for (int i = 0; i < langOptions.length; i++) {
 *       langCheckboxMenuItem[i] =
 *         new ActiveCheckboxMenuItem (null, event[1].out (), langOptions[i]);
 *       langMenu.add (langCheckboxMenuItem[i]);
 *     }
 * 
 *     frame.setSize (700, 350);
 *     frame.setBackground (Color.green);
 *     frame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {     // don't forget to include all active processes
 *         langMenu,
 *         activeClosingFrame,
 *         new Parallel (fileMenuItem),
 *         new Parallel (langCheckboxMenuItem),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) event[0].in ().read ();
 *               System.out.println ("File ==> `" + s + "' selected ...");
 *               if (s == fileOptions[0]) {
 *                 langConfigure.out ().write (Boolean.TRUE);
 *                 System.out.println ("`Language' enabled ...");
 *               }
 *               running = (s != fileOptions[fileOptions.length - 1]);
 *             }
 *             frame.setVisible (false);
 *             System.exit (0);
 *           }
 *         },
 *         new CSProcess () {
 *           public void run () {
 *             while (true) {
 *               final ItemEvent e = (ItemEvent) event[1].in ().read ();
 *               final String item = (String) e.getItem ();
 *               System.out.print ("Language ==> `" + item);
 *               if (e.getStateChange () == ItemEvent.SELECTED) {
 *                 System.out.println ("' selected ...");
 *                 if (item == langOptions[0]) {
 *                   langConfigure.out ().write (Boolean.FALSE);
 *                   System.out.println ("`Language' disabled ...");
 *                 }
 *               } else {
 *                 System.out.println ("' deselected ...");
 *               }
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see java.awt.Menu * @see java.awt.event.ItemEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveMenu extends Menu implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs an ActiveMenu with no initial label and no configuration * or event channels. */ public ActiveMenu() { this(null, null, "", false); } /** * Constructs an ActiveMenu with an initial label, * but with no configuration or event channels. * * @param label the label on the menu. */ public ActiveMenu(String label) { this(null, null, label, false); } /** * Constructs an ActiveMenu with an initial label * and a tear-off option, but with no configuration * or event channels. * * @param label the label on the menu. * @param tearOff if true, this is a tear-off menu. */ public ActiveMenu(String label, boolean tearOff) { this(null, null, label, tearOff); } /** * Constructs an ActiveMenu with configuration and event channels, * but with no initial label. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public ActiveMenu(ChannelInput configure, ChannelOutput event) { this(configure, event, "", false); } /** * Constructs an ActiveMenu with configuration and event channels * and an initial label. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param label the label on the menu. */ public ActiveMenu(ChannelInput configure, ChannelOutput event, String label) { this(configure, event, label, false); } /** * Constructs an ActiveMenu with configuration and event channels, * an initial label and a tear-off option. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param label the label on the menu. * @param tearOff if true, this is a tear-off menu. */ public ActiveMenu(ChannelInput configure, ChannelOutput event, String label, boolean tearOff) { super(label, tearOff); if (event != null) { ActionEventHandler handler = new ActionEventHandler(event); addActionListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveMenu. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param menu the Menu being configured. */ public void configure(final Menu menu); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) setLabel((String) message); else if (message instanceof MenuShortcut) setShortcut((MenuShortcut) message); if (message instanceof Integer) insertSeparator(((Integer) message).intValue()); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/0000755000000000000000000000000011410045053015573 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveComponent1.gif0000644000000000000000000002072410520670125021453 0ustar GIF89aÜ&÷ $$$(((,,,000888<<<@@@HHHLLLPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Ü&ÿUH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´)Ä,HJµªÕ«X³jÝʵ«×¯W/”pJ¶¬Y H˶­Û·pÁV €á¬Ý»x&‘weŠ'ú ìá” @^ÌX¨áÆ$CžLÙæãÊ%cÞÌ9ååÎ5ƒMšãçÒE£^ÍúáéÖUÞM[àëÚ eãÞ]ú6 Çì{øÀàÆ“/.žùdT\(@zt‰Ð•ßenÜ9ä ¤ÿ p¡¼b‰àµÛå>Ü;J8 !0‚|ú"\P@A„"¨àñy ÿ]çÀñ]·ß|*dà@÷e@úà@D * ¨€R8Ÿ…ªg{¹wÒü§‚\AÐg¡¤GÝ‚èW*üè$LdâEУ P—Áü'_„8&y\`!XJY•VªX‹¿¹X’Bª€‚ pžWãtt†9cxG T£Œ*PeŸpú`•dB¹g’áaI^y~fУ ‚ŠàyŠÊ˜žšd±É››$*gžÞ %œÑizÝŸáI7ht…Zÿgž‹¦‡å†þ瀀wŠI«¦­rÚ”§»J†(ܘ¤‡câ‰j­ ˜°L‚ [ÖHª € t™ò©@“ÔZ*œ`Æ™A"˜à€¿ŠKŸ°L‹›±#õøcˆÕE笶ì uªp#xôi+»ØR‡$­óº`uÖ (¯gº*PÄÜîJïRöÖ†/NÚ~l2A!Ó6òM%Ÿ|rʳ­lÓ¹.» 3l2uB 5wsk9e]<÷ÌÛϬ  €AÑFÓ†ôjJÿTX; uÔ¬MÚÄ%öØ`5€õÙZsÝõÇ„MöÛp[ÅôÙ ÐÚkÓ[µOWcÿm7Þ­y]ÚÞ=-›à¤¾ÓÐ(>ã£9®S`’Oþ±å™wŽå áKß¼FY:“ æšNéžSzgÆö·’"y¬‘íùç€}¸®D}Zê*ÑغE¯s*¼oâ~‘¸›À®@ »’¢]V` ½Qò›Új´Ƈ¤&XL©|ÎSÀ¾ñF$Œé>®Y>tR`߸ô«Ïur§‚ÅÇb*€4#ûxÌ} (Ø€¸•¾€ñOþ“·"@E }ꃠh‚ í RÞ“ø0ã&ý%I:Å{a” €€vÛ£ý#‚ê¥Ê]½ÛÿÐ7¾f@Nj”Ð»ì ¤z©a’ Ä:1±UT²Q}@°°(GDAý!ùGK%¤!\8Ÿ.ÎH$h Sø½Íg!PŒTФpK:©ÈHHARp†Ø@"=äAT©<ûy!¤zœ‡Oid}bÈÃ"…k$ß'q(=HVò’R úc.@Ψåaâ Õ'EWÒ±Žz»£B¶WéhýÓŒ2`4RÄ4¦t$Çha«3DD:¨‡RÔŸIN?9$Ï•ÈøF&Z¬ƒ•üÄCl¾Ð‘»"_ë'Î$™«xë”a óyÿK‡¬°2nÚ•ö(ÆèHO‰srçÔ­@5ªŠIÑéÄG [²O §§nŠi¢ÚÏœ((Xá(V$£¶9#ÅÄhF郞= v{\låA7vD Á4¥9´^?òOÊÔ‹é#~Ž˜J(r‘£ÏSõŸ¥[ AÁô®(,D‹ hÇA¬ju û‰`® ôm ŒD”PÁà£Vø½¬ â#Yé³;lO‚çÏî6æÔ#‚¨ZCubCnfˆ;jbRÔɸi¬ü;Œ0sÒŸÉús±ž íç@+ÚÒN¤²áœiéˆÚƨvµÞk-c^ ÛÖÿÉv1´­mçn{˜ÜêVr¼%Œo ¸àf¸ÄU›qƒÜäFm¹}i®s{ݼHwº6#-v[]¼\w»ëî]¾ ^a‰×.ä-¯šÎ{–ôªW=ì5‹{ß«œø–e¾ôõ™vóZû’¿üýàïfÀM)°kƒ`¦(x"pÌHêT·`4x)Ž$;‘ÐM“™a…Kra¥d"}ÊxR7‘[˜$%Nʉâa€9ìCÔ‰–ñ$¨}m*wå#Dý³âeQG`êÞ‹;c¤Ì¸! £ ¸5¤‰˜üžR4É UlKÊR«}E) Q€ZKI“òä†h«ÿd j¤–¡¤€ ­sÅ–)Žj$½ݨ”¤rqšA²f£´™!oÆ¡håˆJP:¤£ ‚!I•R˜†=hº(‡^ˆ¶nT-j‘ H=â`‘<@éÍPY²B¡ -¦N>ÁJCÓ’r§=½_žLèCÿaªˆ æ¾íJD–Pðd1P=Ö*kÿäb+B5!Hh0àðÒ‘Ô!" ! I|‡‡õñjH¢MÂ? °vù‡7!‡Ô¤ð²'H.×$æ×Ssb‹Ø''L5@_‚LE&5%„8Ðñ%r‚~cø‹G4$QC1TFçÑKLu%ÍŠÈ(8w%1Œ° A˜’¢LêX ÆŠ6á8БHêQŒ¦Ž5ÁtS2Xú5Žøh2òHô¸GÑ3ñY)YCq1‘  ù?‘/1‘Ù陑;±‘-Ñ‘™ É"9’7Q’+q’(™t÷Ø’«¡’*Á’0 p/Y“¤ÿ!“ˆAv8É`7Ù“¡“(A“@ÙByDY”+q”&‘”Jé?ù””Á”%á”ôÕAÐ#Û§T<ùÙØ„Š`7YÓq.°xN§CÑ2 'Sz Ñ#Æñ?è—VG12"ëó1.!" Ò!<GîCt…ué•3¡-ކxçx–¢'õ3/¨³y¤:4²•­Aj&(«Ó”%ú2D5R(`b&t¦D'U„!¬¦˜ùÆ–BQ#ÓR<7B#Z…=L4­¤,3O9–'ÿá—pr!‘b¨hu¢1βiŠ‚'€ršq&€?F]9"y&EÂG¢Y>`ÿ§ÆE^F=$$å¹.bW—¨'a憴á–p ✧‚´š~Òš÷i!"›.I›Aáaz²#ñ1(—'ŠAʲ$Ø›"ò9ÿ!†Þ&ðHs¦1¨9UBgÝb!þ §vD¿÷‘Œ)2'“7„B™7X1F'(С42DÖ'qD0t2=xò/"(%¬Vi­Ù‚=öƒ³),Ý™*§È}"=L’'gTW­&d"šzfri4„h 7Ê•+ÈH&UÑ(c IÕv¨„ˆ.b5Gx#=à1õr¦;qCP–Ûe)Õ†Û)V…u%•ÿaqñ34‚sáŒÓrc1጑¨Œº 9q3§Æ§qjÑ‘‚ŠD$š¦š_É#`˜Ó©q5ª¶Q7œ)f’y˜Ø¢öQ0;*Hy£e@õ ó‚—µ—wyó{Âêž›:«LA`«¸êp6»Ú«!Ö©®Ö#äá—ÕÃ'‚'’-BÕgi5#Y$fâŸ<²£ yf£É#’æ$a&gv%òú­x¡r0®·Ú9 7{±V$t³«03-™vBŠ"yz"#–"GÒ‰ƒ"T´&†"™æŸŠÁ²)öÍ)‡ÿQÓ韯Ú Àq(÷³@´BKr‹5ë9€±J{±E{6ABuF.ŒÇ ‹RJLrj RbäA[«(…"#.F¡§!õÙ¡±6¯ýù,ëJp÷¶p·rËp7q0±åJ@7G—2—f)¬fCÚg§&e€Â-JT¯»2-3„%_¨ßcëŸògÊ¡÷i¯Ýò-9[¸jàºü†5œºZ`o#ð¨!(8'°9–05R©=CIš•ûy!´#£ T>®ò²p¢Åó£%¤PÒ0}R©oæ– ‹õ¥ [ ào*€`… e÷é¡›îö¼°•çÖ}¢ÿ‚½wQÙ›· ‡œi’åk¾Ü槺…˜ˆ·³håÕ’ª6qŒë+ùkcw¾î«iÙV#Q½Á:µä.è—~¥%ö»âû‹¶CAñL%ij¬š|1ñv1")™µ62;ìÙ©ººpu#ÁOÁÂ`¤Ñ˜Õ“:ŸËVxV!Ž 4OŽæVi'vž×Ã<Å!LEaFL'1yU?¸"y8yHLy‹EŒ²“ÇG|d¢Äx&ŠÅˆ‡Å‡+ajÂPÁA{(P<øëH.7‹ÜøŒ¡HÓEëB;ÔƒBÑH€Ç8/Ä$Lu|| x{ìHç1$äAýë®Åÿ#ŒÄÁ)Œî£%Œ©˜NŒ¼­.J|R˜¯Ô!³‡Ná{H‚|áájÓ{àjæ6â!Ái¢ OÂ7e¸' 1<Šû<°‡ª|1²¯ä³Gò¡…6²C”õ¿R88MÞăØr‰/œNР̓Qó„ O‚-Øââ®'Ë.<ÔMëbx#òÍ7¤>ÕÁ¬f‰ •ÃÓè!úY!"FH…€‹è1þgÇt@rkDÅÓsгɗD)³Dö÷Ðéç‚ÁR!ÂHJ‡á‘ŠÜT%ï4NÓ“O˜‡¹¥(ytQÖd)õ +ÁDxÁ$Ìá!%úÿ|NC©$%b‚s(¸ãšüg01ÔV(EYz‡OÓÔt6/*w.¨ …§ØSFÏä@ ‚§™ÖM‘€Âd…3b‹[,´ÍÑr&)¸†eHÑõG=W´Eú“€µ„?2ÈE»‚‚4ÑQÒ A[-1b$îZIÖ41 'giËûñÍsÔA¸¸_"08. HFxJRÒˆ•0b$dá|ä‰Ö˜VèAO}вJæ%),HV¸Gg( ÊX@ÁE­Á¨GâBt¶!Ò*ÒóN@Ö&€…¤…±{#FÎlwb|н*Ç…îŠ~©í×™aÆPÿ¦DI‚.‰[<»gŽc æ˜BÞ¸ÒѰ¢¡?•,ég…ù׋§˜>ò­|GdÑǧEîýÑ×!Q¼„#@‚?8–¢hÛ;8>3äÜ3âÍ8B‰„¹ÚųG‚à~È#`-Ý‹8"~ƒx¬6M„™(Ú7 ˜/ì2H ^‚ŠÈˆŽ¤ŠÁÝØá!Ìäq@‹(Ð %ãä?6‚=3>ç3'»s˜~’»ºW<Š2;Êg0E:–´û±OŽxÔW—=K~?©ÇEAVˤ !FŠÒ1$ÕŠsõ… ârÇèrÐEQ”‹Ø$1äç-wî®æ‘ŒÎŒOä?Ñ8;LÿCÀ(¼¿ HbX@Æè"©ãA[VˆB¢‡x‹g:âwŸ·Äó¢ÒîzL ÓêwÅ¥.]¼ÄŒ—‹Wl0èçh,&'¬Caµ˜;n=ÆŽ7áB9ñkùèxÌ'œ–ÄÉeqC¾NÀþœpæ7!X6®ðè¿ÉŽðbíNA&¿ƒ†éÁ½ì{mÈœîk²îì^îþî}ÚíòÞæî©Þ]ïëïún¨üÞïFqï¡‘ï¿–e\ð•!ðîÿYôÞðy¡ðÁðÏí_ñáöïï¿ñ—®ñ ¯¢?òÏ)oòdŒò¯ò )ò.ÿ¤,ÿóó4t6ó:Wò:9ß^ǵQÃÙñ‘ò»tž6yå‘F/«?a¢Û<ëFÌu€‡y®§I4ÃG‚çxÓ6y¹Fôûøôëgä—4Ò%i?=š¶ƒY’X™"›I¨Ë)qŠQK¢¼Eÿó!÷ÝR(¦l^B*sOMÍ$Q{d³.„&?zQÔ)¿õHöñÚ²£a+G¯B*=r!Œ„ÖƘ•judÜB!¬É¶iùù©’ŸÐƒÒï±í‚A(^b *É­âE«O£éúûüJ*U²;#{$u6ûE.†ãAAu<ô&­ ÒÏšIâ­­ÿï÷ŒãT§|Tµ^M2RæïT½TF Èuaé郪‚¤WÒòàFüËkx;òø*$Xpˆ‚ .dØÐáCˆK èÑâEŒ5näØÑãG„$YÒ$ǃ'U~\€âJ˜1eΤYsáH›9u6L¹sgA_ú$ZÔèQ8‘.]‰‚¨Q¥N¥ZÕêU¬YµVeÔëP¦aÅŽÕ©”ìYžneÛÖíÛ« ¼€!Z¼yõf4»×ož9¥kWðaÄyû&Þ˜±Å®uï>¦\™èbËdg^h‚€aΡE«Ä<éfÓOLNÝÚ5ÆÒ¯w¢æèÿ„1Q”Ü=Ä‚&€{$qÁ¸ñÞ7Èf»ùQÚ=§@"&…å!=D H¡Aß=^ppüBòˆ&¨¸ûùû›ð‰Fϸ^…$D˜˜Üº ¬+@ëPè ?H A Áä Lp¿ü&T †HCÁ U p ýøSA÷úCÑÄûC@6p(oG‚bãq%ú.º`9õTˆ ‚ ÁŒÛ@ "Ðq '£¤ G6O ÐpE (Xï‚ r„#“äO ¹¡ ’ƒ3;SÌ ›lJ(DRþ @oI=«dP…0)ˆÿàF"Aû~”ÏGIM Ò"ñÐD¡Lö€[¯HN!%(Ô×Ñ8Q2N DAÇí@`2Kà ÀoUñò+`à2S;Ý€P!J3µÆ H hw]ÑDSw3I.ï3¿T+}RoCº¢¢ LÒ-¡ï"XŽ‚tÙì.^ÏŒ€Å1¿,@x4Õ„{ã½ UG»Í²UlQø.×sWUA¼¼4’_ ´1¡v7Ð2Ýt®QGñ W6pGöh܇RíÐN]Ñ&3àÎÈìT™Õåø8Ãb[T –3ÎmîtC|%(tÉ$aá X¿775ÿÑV¢FôË a¶yJô³ÏÝr6™¹’ÏÞe‡RýŽåÅó!™EèRzmõ»`Ëå2°îH`§T@¼']ïÌrÅ ÐŒÀ„<AêÄ“\Éãv›ûjžLÚpØÍeµ_K;vŒØnHÔ²N 8µ¹½ äTèÞwƒ„¢§³¹7¡kV–J2kì¯Ìâ6Ým¸ãsó5»âGè·ö˜åÔ<‡{÷Mw@p¸öФ]ö÷-m‘#×?$×ïOmvý²½!EͪɉÈþP!ÿS`˜@„¤`ì HÁ VPƒáº`3¸ÿAò¨ƒü`Møœ6°„'d¡kR¨À¶P†¢yác8CV¦†¼a}ˆ˜ö¯‡?$â^‚¨¿!Q‰g9âý’¸D(2¥‰ñ{b­X”)¾¯ŠWäbN²H»-vQŒ2ùbìÂ8F4ž¤Œj;cݘ%¶ñsÜÈÏ&G:æÑ"v4õøÇ†ðqd~d! "ÈpÒ‹D¤·¹ÈB6²R„ä%))JÖG$QCp‘M>o•dÌ%”Iš\àY@ вöäÊ!ªœ ×"KR^&Žóã -¸R “£DT9¬¡S‘ÊeYvI”FîHÐ²Ž–ö…ŸŽÿ=ìêÖ¬¼§XÖ©oÁDT7Ù”òÈÍœ}3§* X13-ZËù[Ä:GK6Ó&¦ä*7TPà\{p¥ˆ­È>^ú›~ª£¥GíêoÞqÖ‚ù·aél_ÅùF!Ť}ô¢ÏŠV–@Îm bI¨* ÒêÓ™Eô§BÏ)9ã„,˜ Ò¦ Õ§ˆåIë‚“­vjŸ¿=lLßáiR%&‚‘"Apr*C%º¥õLN¦^|¦ONEN«òî¨ÃNÒ0Ј‰’£+€±ÆZN¥ÆÒ¦p}êH]éq^3™Iµ©V·Z~_Å)ç"à…g;ˆRç|š TÿK¼bê@¡*‹©Ü–о“Y-q8—Ue†ŒƒδœðŽp°ÊVßý•Œ]ÝÉå2 ë°,}rÄ%ÝÞK^ìáP¯b†ÛYç¶ÃÓfµÜ)é6¹ËåP¶ü4á6(³º\seK“Àʧ¦ßbxá3^ò.ѼïAoz‹¸Þç´—&%({wßæÈw&)@êk_ÒV6g€Œ6¿Æs1ð[ƒ_æ  p…-|a gXÃæp‡=œaÌ%(3sðh ,›`7+fq‹]übÇXÆ3¦1Œ% â—˜† vͼ’c¼lMˆd!Q¿2ÿÁ‘‘œä.ùÉ<ñk¤<å VÙ5I´ nd¢L ç7Á±eFŠc0G¤fXV–[3DåUç:kö.Í%Ëð|„‡I³qÌcY¼/^îÑÜPeKjÙš¼v3mfîZQo¥44Ÿ1ï×C+Z™(¥a·i‚³ùæ–>A•‰sKêúÖ ˜Ml8Ë]™ƒŒtÑ(}¡Å* wîL·½Ù*o6 ¼äü8› ®U¹^â:$:ÆMË~«øä.f9î( sGâœç@÷xS‘9åDmçTv@Aêu*jµ 1‚;¤ns8æð„Wûâ%>}Éëób¹ 4÷ðŠSÙ±Zõ‚Ç YÇË_ãžÓ¾wZñéÉ<¼óøø£¾&5 7$n}Æ?R?Vç0Gw=FHÄ^\ xÍ•Õ@ösÆýïï_ü33úßÏþ–Áþß·ÿÊè?ÿ³ ò@:@Ê@4™`=2€XÀEº€è€»@ Ì@ Ü@ÌÀx „$p€+Ažð|ù¤~4Æw‚<ˆcd:êÆcP¨÷Á@ÈWåWN—y¤æ“P: á”d¦‰S”·¡©æ›3±i››pÖé’œ³ÑÔ Ø ž°éT ôé'j€¾&(P@¡‡’–(k‹þ´£ŽB)}f6Ȧ †*ꨤ–jꩨ¦ª*lŠÙ¤©UÿêÓ¥˜ A«®šØé|²öt£¶âš«®OöÊÓÁËi±†Íu­Ê:Èl´Ôª+jÆV«-Cמ–­D#„¹!EìúP _–‘ê©7nDê~¹mJÝ’ö-D)l˜Â˜- .¹ã5 ѰȢDC ä¼(ÕÚ½M X3'$xm Ìuj@Æ`¼Á~òmÇAÐãqœÁ¿"fp%sä„ñ ã,sƇÉò !3ܰ¹ÎAÜA0 ,ýqÓ+Hà#ðï #,°ÂŒ0A˜ Làus\‡@#y%d=ÂÔL¯PB|U‹ýµÚoÍÒ\gÂ’TÿÍ"Ô4 m’àÍPcj]ÂÆU ^“c uÆãñ5‚'À sŒ´ç5g˜Æ}w0®æÉ…àa»Ýd_~ò¸M‹4‰‚‹Døg†/5ÒUZÀîånØAØ$qÖY0‚íJOn“fßž†økxY ÔžÊ6Ÿöùqàð›»îD#×»BPgØýçXg/$êÕÔ—+¤p¾uŸÿF?¨µ§qñÎ<÷1«dö@&¨•@k“SàúF²;μ/!€Ë\Ø@Ï-sÙK]xV` dÀ?¿ÓZÄÓ.@0'Ú2@°ª°{ìayÿ<7à @ .ûÏxrèž ’¤ƒ™ù B”f·¨­- ÂAF ®. ä_ãËÕÔµ¶¥mè_ÿ:_ܶ¶/º±B2‹ÀH5¢Q X´¢ Ⱦi©deH¢HÊvÙ„t| 1#E„Èîj!qYûVr³D*r’Úi–%7©E^¦‘œ„“')ÊPªi”‘)¥)É„JȨr•8jåc^ KÉ’1´¬å|n™˜\êÒ9¼DŒ/Yœ`f˜Ä Ž1ƒÌdöf™i¦3oM¿Hsš³©f_®‰Í×h3/Üìfj¾Y—pŠó9˜´&Ï)8rÒÅœì;çÏx. Gõ´ç«Ò‰ÿ¢uêS[ó”K>ÿY&? üÜ‘?1#˜ ¶+lYãAP² & ¢N!*MÔ!K8;`1¨îdý;ât¦® l€¤N2™È6 ;Œ¹LHªÁJgh€®Ýh +]ì¢VÒ¼Ìbþ‹ÏG¹•P)-”%À–†¤«Qç„›w¶ àJëYO™ôž,éˆú‰jؤz)ˆ­«ÌÉ@ <ž œ5?jÌj~üe€®.U5MmÓSWâÖ¨ÅèKL¢Ž`Ø´§%‘=Ò[¡yHH b¬FÛU‚%u (AòjDðxt=¬A_¢Ô´V=Ôá c“G#õÿŒ6¶I2bW³çÂ$fVk#*ö´ö …-¶Ýš S{Š…›Lª¿^Ô?·"w¶Že“$˜ËæÖC›­oµ¦ÙŸ$Aè/ÐÒ¾Ðv¹Ì-ˆsÃÂMyGk¼o^e«µ÷zÇÝY€‚¶¦µ%Õ;âõ»ªÑÿž.‰¶j{“UøÆW ómJ8Õ(Qd\ì_Ô£FÎñ‹`ÌâÁDŒb+’QŽh„䊵Èb¬IôÂÉ0S.ú³á(:^ âÒ %ÈJ²‘Ç‚ä¤(#î¹ñ’_Òd¤ûùÏ€´ MèBúЂF@¨PaáY3Ó`›¢L1š€\¤ó4éàÒ™¶Ö¦Õi¥¨€Àt¨ORæ¢x¹"(PõªY=jE•zÖ¾i5~nkÝèz(<ºÜÖFòH^¤ØÂaÏ»X‚ìóüW"%¸Ò²ùøk¡ðh\Æöˆ…-_®elÚ)y¬”#µ d{}Õ¦¯‡³+}@CÍ‘—]K !y äÝYZ¯P¿¤¡ÂFHCÄÐ4$Fæ@ `þš½›CïƒOÐt Ë^—Œh|clˆ©(Z#"Ü®ð•÷ ,þp€ç§uêÿsbº’¢7-k.‚ _D5Ì}x1_)ˆ˜ÓD‚oHÔ8sâÒ½ 4ÍJ$ˆëè¼ä„I©/JÁ»ýVÁhã¼êoOÓ^(9œýc=_A㚯™7éêíɺÝf=K®ü' bò<‰lqÔ)ÔWw«É”]”à_Á­u–¼!ø›y0ö1Œ+Ý 6—ÜÛ¼×RÄy.}…¼Ð)o€Äw|+t<Åã 4¼ïEbÛ¼áa'ôM¾Ý'¢Ù“ƒñÆ©.ìÇëÚäh_°éým4ÓàÀ㦾M€j ~1Iý•‡kì\Ø}Ø$‰y¯qI“;ã«W²-ßð[ëÔÿíÇ“ü9~…é{¸ëkM)^ÓŒõI4ºÛjk¹åƸ…MAlw|œ<< Ò9>D3!÷%UsçwCÛÓu[C ܃Aqô4dD^H~­÷XªæPÞ#Ý£@¸Fävì+î×éW%w:cr<@‚‚p:ê’ouUxé‘CX³tìB]6HEÖõ.Ù[ó§Sy5CCPs"<_µ$'È•<‰uD\Õ.HÉ#qÔå¦ZQ%0“ÿè‘2‘ÍQ6Zd4a*É$‰“|Å×@HÔ7ü•Ó^Áe‰:Âéþ±˜n9…M “_è¡T~Ã!¸Ó‘„)L†©Ž€Ñ™Çô™ ‰Q áè(€¥ §ù©Ù§†¬ÙšLEŽÏ@›¶ÙI¢ÉL¤Y•æ(»Y›½)_¿ù ÀgˆÖœÎùœÐIhŠ*Åyœñš.h6gÜÙÞùnVg˜ÿ‚Dž,› UŽbžå™œÖœ4áÀž€ˆ›MqôImî¹Mði?‘Ÿ(žþyz: Q &q/à±™@a2dwlÝç  Á •”L Úé8=8!˜Z#¤w'Ô}õ8Ý”¡$‘-]˜G6öFnóEmô@k4FtW5dG0 bEFx5h8icbkä¢`$Qðe£/JwXÓEüS.ؤ¢#‘-lh}%º?ÿ¢5^ÂCW¢?˜ÓPZ%b‡ür<\êCrA/42Å.ü2BÂáB tBó€+tp¤cˆAÂãr½UüÑtˆY3]ûR*Æÿ2{ m×7=,¤1cB‡j7pMR¨85ârôö ZÓB5S¨ñ8;÷æBÖ6N|A©’©•‚‘>#6ùórV¨‡±/#|G±¨!a,&S3Ôo:ÃvØÓy–¬b7BBs س!J;ge¬1TE®uc8™!»çCÈ4/)g2H£lX8ýeºŠ$…RÄ3&9µRüÑSFÅ ·WdPz¯ª3T7EÀZÒH3@t7Àå%‚±wÞC@M‡4„AÖ·\(Tê‚88ç¨#çCðWݶF_ƒmS`*“3ò÷­Xƒ°˜1U„48i²GUSµW³¥WR•ÖÿÕ^âUäe–íUa Ã$x'û NK¨=I5)t=IÓ5µêò#ë6 u§ã^ó#ǃS¯µfSl¶€M'W| tᢥºG5M3 ^.Ò4.kë¦hš@#‡JQX'ÐKb2Î"Õ^™Y<«SÎ7Z­ûÆB3sw‚ªqd1Í‘3[©ó/újR%•R^Ù1ýÓ¥$&ÍQ6“~ ó &. &FÕ}•J@2¥²b'C4L‘¸È%¢ãE`X#¸.·³¿k¸I³[¥¸C[NÒˆ.H7MÔÑÅ4À'vS;Z€ \í…WKB^ãUÄÛXáÿ%´ö9z×A¡Ga_ŒeY]Ö‹AØ»6SH\Y%`ßa‰šãÛ&£EZ£]DG)@1¾û¢|‘76c»¸¿ª—rDtI‹ëúQïz¡@–¼ïÔŸ ¬ÜÜÁ®©ÁôÄÁ"|»³$D³8æ1a³!ô6X3*Â'\À›×‰‰‡"£ ápb÷?2l·Û¶¢&|Ã,!º©Ã+°;û³0 ÷2Œin@è62“w^ —=³qË’ÝAþS¾é’ÅO˜.L¾I¬Ä+ÄÉ›„#:‘×t÷ÃMãx]ØtÂÃCÁCW«pQó=>#6MÆèá%Uÿ$·ªjoaÜÄn1É”œ@yáB# ¨q#ö<Ôšxâ#~\êJ ªúËU5K—Dù.uÄÉ–¤Pɺ¼ËVA¡’‰É÷AŠÇ#æ°ý¤Ó£®Yƒ9ÓÊßA;®Åz4¼UaËn,˜)£zÿ¡0¹Š9`å^Çv]ØC9è2×÷5tA3×4f3®Id:É1t×ÜÆnŒ&)†òÄ‹¨ÉòÌ‚Zæs7Î÷í"FAø#mGE/’CÌór"5/A<”=Vç=]ºÉú¼Ï&‘š’c$L}5FÍ7 ñÁù ÒÔXÒõÑ0ÿ½.Ý4]ÓúûŠ:M7­*­Ó?íÑ h%€§ÁvUU±I]¸€ÁÆÀ™Vdù«ÔL“ÃÎðå¢ ñ¼;-Š9ML";A–ÖqH=©BoncpžcD_ÓÖM'vïæVGí%æÖqB\¾/t?6-Ó"5Ö¥ñºÄ+õyà!½"«:qѼ×svct#€t¤H7 v%agt!€t˜t=DW´ÜG³z7.ó“Ú!1Ôlؘ5ZÝxÄ"¹‡LÊF¶¤ëÿ±Æ~‘DM¢¦c3ltB!pÙWa²Yêñ%V·šNãiÎB~aY:ºCÚ?wBØÏe饪³1<!Χ؜ùŸ4÷Ú¬q¾‰ÝÍF]×AFáÕÀàmÌîW­Ä^²@>í¯±2û w&«£Ñ ñíaÔSÍâ¡ÖÑã ô ïÖì^ªsîyî,Т³ú8Ù0 Óìò4=ƒÐW¢„ÃãZ ó~]$Ÿ^ç­.&ÿɪ]ïs,÷®lç/¸Ûx¯:=.‘/Ø åR`åë•ùÓ9\—:Ðÿ:¦&o=ée–vûܰN_×N¿ÉrÓ÷1¢U¾DÎÝ1¹>cDÄüµ°óÅüb6Ã%çw¨ Ï9cçÇ&#ó³€|zIY~´,ÿÛýî—£s#CÙvÓB)¨&äÎP8‘ÇBÐW$½ Ï:%6Ks9æfx«@ËA;ߦ*Š¿øŒßø¨¢Ž–4Ó9ÝSAͱ½äÁ ÃÃÂOsðÜ\·”,L0,’à6w€)N^ó·1ðìù‚'ÞjYíµÜó#1öP´4ãx1èBc‚“ÇzæÖ¡ÅjÏŸ.E’%Z:ƒ¬ó/(ØE¼5_²qWRüF.$ȯî_éuÿñó¸ßj¢Qòm—ã:Žè>ðýÁý#±ƒm>QÍßé&ûK&ûÔ5  B¬ XÐàA„ .dØÐáCˆNà ÑâEŒ5näØqa‰KdpHòa‡  nH1Ä@‚)Tb<‘!̇nâ¼â„E…%Ú‘bуRLø‰Ô`È¡P n°@ð„ O,àÊu¦Ä+>ðDzµ Mn]qbÂÃ>XX@ЀD8©bì°`Cß3Lè`AêÅU%uÚØ±ã£3d5é8ïÐË'¨a pà FŒÑRb‰º%ÞZnú‚è‚£ v€Â¶ÿT¨² Bøº™íµºÛŽ€ZwE‰¥€,±<Ôá ž¸»BxXâÇ{ûqæÖÅ[ï¾ÂxDÆÕ¯ç¹,„)>ë œæ‰À(¿Ô¦É 60@1«l é³XJp²©jRI@Í!´û \á%‚B˜«²Ù ")›bk²èè<¤BXÍ<MZÀºR€`û*Î<S«Î Ð&Èà.Ô«ª¯ Ȫ.Ú̃àÇ&ðq¨ E,èEºŠëÇÌ€-'-xͼŸF¨‹+ÃÒ. ÈbïM8r¯(4oƒ63“ Â,˜`„ à+ÈO@!Ès…Ûÿ 6«Œüà̰ØòËLŸìl4Fí°»­>xôBÅتÒBª®¹D t…¾6øà®ÍZÚ©Ìcõ­”L ²@'“þÌ B‚üd3³3[*!„ª\Í€– KR¬·&ˆÑ Yù4É‚¤“µ [ÍØêtòY6s3NvÛ]aN¢ª«; Hª+øÂ*¡/ƒôíkO®ÞíVP>?³`„ Ë U‚>HXPÑðí€- .–¸ºö2 +5É4/(µ|פ»B^!Ûx 2ÀÇ,3=™MØÚ‚׿0,ØP£Žf´öôpcîE53‰K0 ¼tc2zP`Efø×ZI5.¯”Ú2ÿ€çêPn(=w»Ž^¡|ÕÌ%6o…ËXrIƒÔ΀í*‹ü4W»x†%‰_㙪™î¢;Áº¨ûéjšC†VG„„ÍÀhžá ܵª:I»KÐ}ÁÝ3Ï:¡ŠÕó¤;upÛRN1–ü7WÂÝ̼í2ò¬"G-Òº¸•p˜ Ì5­œ;!+ŸÑ[×käÛ#ŸKÎ*…êÔÄU±Ì¥~ W30—Eï­f½'ŒOõ…Ô Þ²Õû¥´ü•U‚=Ì’­ I*÷`ã$nì.)Uv O#™)¿”“òª?ý«tºóKh>°@Õ%z% Yô§ ÔÅZR`à  ÿ'¡ O!¬ŽŠÌc*ÐåÉo+ÒË´´jÏJáZòlè”åuds¹óѪó£ŸýùςĠÿäæ@ zP„&T  gAúPˆFy •è ZQŒfT£¡èFÝuQ†T¤#5HGIÊžT¥+}¨IYª¼z¾T¦3miiŠÃ˜ÞT§;M§KyÚžœþT¨Cu—O‰z‘”U©K͈Q™ú¤>UªSMˆS©ª¨^U«OµêV ’U¯†U¨]+XÅzÖ›’5¬fEk[YªV¯²Õ­s)\·*WºæU£vÕ*^õú׈òõª~la*XªÖ°‹ý'b§ªXÆF¶ÿ§6Õ+d%{YS:Vª–Ålg'JÙ¼rÖ³£e—fŸ*ZÒ¦v=¦e*jUûZ§°v©®=h YØîT¶J¥­A3à—CùÀŠrËÐݵ·ý-©Fc‹dï¸5ÅìrãFdPºØ­s´W@Šhñ ¢€4)&‘¼ù‘?ø[ŒsºM.Q­;”«™Ç‡<ï¤ïŽà¼CÉRÒ" š@¼â}×]jç–§å· Ž¨6v˜ù´¾C½ïäìu›É8‰ ðy- à؉×&ži.iŽ|˜ŠþMìN†¢ k´tí°?lƒñ.Þ Áy­S$M4Ïÿý-Ò”TÞ‘f€Ñ“ ŽsÜØϵÇñî@|Þ a+»±™‚ ¨$‡q.@½l20Sîƒa¬ •O–Ý+tÃBÝ2GÒ7ø &$d"è¶% z…O\É ¡»2v¾‹Ñ *à[èbÜ<çsÏ?ís¦3½ižvº]'µ§u\Ý ŠÔ(µ©5e·Šº]ðe5¬]ÒVß4À@¯}ýk`[ØÃ&v±}laC ¸ÀÍõ­3kk´:€×Ȧvµ­}mbG`ÙPàì™6{¦²f—‚Ûíoƒ;ÜÐ>+¹¿Æmo«;­ì.kª=ªÄ[ÞóFµJQî}óû² ÿ†] |€WJ*mòp„Käwˆ¸eªX³æ1Å Ç RäòüÃyÛÃ.¶’âÆë79Ëd•ìÄ'<äA/cIKÛÔë º®mrËæÄGçêX|¼Lëä—¸!&ïÝØ<>)¸ålj“˜•³|àöîÉ[ØB$k5K}‹SS–ø#=,Z-,yt±TBæÅIEúÉ‹Šö_ÉVïjYŽDÆÉÐ<ñ]OÂÅÎI"ÍF~ªÍŒ˜eå¬+Äâ/%ìeL8€)J,P™æ%ø.CIlV¬›PUŠ«?”œ,,!ÊÖÑR£¦Ál‹T‚2”­NC¡-NÁ æžæÿHÇqæ|Å‹~—ŸÏ Û™ö;>y·û…{Bž_»Æ¹°0.$~ñ%Oïµr=ºZÔjÆg¤@ó†™ ÿ㚉Ï)$¿ ¬øœ\•½àø»“韓¹)’ µ{@]º¶ql˜æ0Â(¿±¿ªÂ¿¸Ò?‰Èš ³ £0š¢Ú 2´ø.'ª ¼Ò’SB—a¹¬Ð9:)á Î1nqêPØ#<8íÙ/«ù€¾¸½P¹¥ßó\ˆã[©äÓŽ©¸ ÿ ¯Ð¤—àÀÖB: û€ úX œèV‰ FR ¡0%Ĥ©ÐãH‰e©•D“Ë8ü8›ø‰°#:2¡3DC¼+ŒˆrJBÉ*ÃM¼¿–ãˆâ’/À“RäÄSlELC•r7XÔ+Y<)Z¬EººE’ÊE]t+^)_üE´ F‘Fb+c )dLF¯ZFjFgÔ*hÜ(iœFªªFºFl”*mÌ(nìF¦úFŒ GqT*r¬(síS?ýS@ TAíSØ6À49e5Í& è•—xTHTITJ­TK½TLT ض8MT8YTijÓ‡ØÔ3ýROP5%Q­¸C5ÕSEU:å-25(èÔW-­XU®Y½Õ­JÕRZU^'_µ¨]=ˆ‚ËU¥# …;9õI‹ “sÖ“pÆaµ!Œƒs ¡ìˆm9±Ð(9.D9¸CÖéªÖäQ¬r©ƒ:¤sJ©ë¥©Áw ¥&fò¡ãÁ3ºêH:{•ºŸc‘§ v¥ºî  Û"XDWä!,ú:´;<);ÿ»´£Žµ ¼sŸ,‰;!<¹;޵·Û»3³±›P“ÚÙD:A±‰Ä[B4Q#øÜD‡õšÊˆËCº3Ѽà¼8Ú—´ 0ƒ ½H¢Ô³ŸÕ³Ÿƒp=í° )–ÙÛ „ñ:Ü› Ý[°ò œdi‹à³ŽáÛÙ3ìÙ®YCíY¾Âq>Ÿ×¾¸ýë?•ñ>ÑØ>·à[ð3A½m”—)?Ž=?’I?’X¿ï›løãù“[´MF¶ý¨bMU)@óA£‰–ÑA‹‰‹@À ´ Ó˜‰D?R‰CƒH L Û Žå@õÀåJÁÍK£ÿ@A lÅËm·½ ”Á° Áã/5ÉÁ\;óÂ$ B²"œ,D›Þ±žCd´xÂz‹íÙ*ì ,D-ŒÖ.¤Ð à ›2ôb,^vYÃÒ1—7ŒÃ„™Ã™Ðß;|ž™ÐCƒëéøCBú $à0D<ü_E‰ hÄ HŒÄ ¤J¼LD”—@Ô†5W>Ë\´© †-,R¬_æ4NÅËbEj]áP#á`å*Þ)`­ai²ß¯¡aFÇÖ©þá0 â›b"VS#¦)$Nb¯áa8ib'v— ÐÌr˜â¿€¡Lýb0c1c2ã 8Ðâ)¿" T7~c8Žc9žc8¾#5¾c<Îc=Þc>îc?þc@dAÖª€;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveApplet3.gif0000644000000000000000000001021010520670125020725 0ustar GIF89aÁš÷  $$$(((000888<<<@@@PPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,ÁšÿQH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“¢á¡©Ó§P£JJµªÕ«X³jÝʵ«×¯`ÊK¶¬Ù³dC<”`€Û·pãÊK·®Ý»xóêÝË·¯ß¿€ L¸°áÈ #hp‚!ˆJ#KžL¹&„ +T¨Ì¹³çÏ3@ȼ´éÓ¨S MZµë×°²^¨9¶íÛ¸oÎVX;·ïßÀMîNØ;¸ñãÈ+GX<¹óçÐ .?Ø<ºõë¿§¬Ž½»wÕÚ rÿÿN¾|åðÇ›_Ͼ(úêÛËŸ¿ó½ÀøôóëiþýxRÿ hàX‚ 6˜àh´-èà„N¤`…fØÐ…vèá@~("†!Žhbƒ%ž¨¢€)®èb~-¾(#{1RT ãŽ<öèã@)äDi$€°" pä“PF)å”; Õ8WF·A˜Àa:WÂi¤eD%€yœøv (™Ñš`v—èØ1àšò&¡Ezò‰™‰:è…whE‰^×'£€^'(¡­eT©u—FvÀ¨£60Ñ£,5ª)ªáùЧхÿªÔvR‚.©jݦvЬÐÉš40 ,  "4`¬@¦¢€(@àì²Õ:+­‰¡·(Û€’h¬(4pº©fº+«¹ê°Ï ‹Òº(,0¦. $ p€@X€AÀŒÖµ, ð[0èXN £‘@± ˜ÂÀ·æênt¼b$oCô:gïIç;( x­À4‡kA»mÄsăN@íÀú¼nÁ9rKº’ ¯r‘27)E)'·²I-û‹Ì:pËH‹À±ÃDl ܤqÂùB\°H§»5®L ]É­FMÝÔUÿÜÕ%e­$Ì"´l®À&T[pÛæ«¤ ¦¦M³ƒB@mµbÓm*×í(§jä÷q€“Ôò¸[›Êq²ËN°ÀkœlÀ0¿Ž.©¤ ¤ÃIÏn3´Ì ÷IMßý4E'34ºq¥ÿ”¸RÅ?‡w¼Ã‹Ç·DË×¼N$,*YôÎMµ¯eÜö:%`€÷IŸœøÈWŸÞõ™ÿú9Q ãúÐÛ-ýñ’|è—§=YŠ}BÉøw÷!~$¢ ¸+*Yð‚Ì …Ô²wÎP¢£`¬V©%h ÿÂ@‰$o!öó þpb …í[áûZ‘*$†¹™áMÿpÃöïs½ §D,þ¤8üžÈCˆø0!@ÄäÀã@Ð…¼_ÅÄz9QC]4Î{FÿŒq^eTÙ3”Æà¬ÑŠm,å§)z±Š¹"B²x›-¨ŽÀ¹c óøF”ÅÑjsÄ"£H‡ò „´! 4IßTrCŒ !1…D“…r‰£Q'sóI†\Ò ™ ÒpÑ*¢ùè£n&1u=ïYÒ²ÀL10Qty`T€ÛDQPQ‰íL €´ä)õHˆø h™à¬Ž«³€7·ŸÍ²gL=VÁOœT`ÂKhEÖ ÓaûD¦/#Y¡––­`£çd½iïRªê­ºÍ­Þ:€ b»»ð¢@›ø2gâ,  Æ5¬Ü×6§Ö{þ³¢á2îE«Ÿ¦÷ôÙânLÏÏ“qDq’*”H”BY”CA”F™”>”JÙ”9Á”N•4•RY•/A•V™•*•ZÙ•%Á•^– –bY–Ùyf™–5A–jÙ–`„–n—,Á–rY—L—v™—#A—zÙ—|Ù—Ð1}¯3-ꈄuKsL5ÈK!Mm‡—€I!ü5˜ì¦ÖÆ8ÎUéDîp™ ¢a¦;oÃTs9¯STÁfQ(`<…6þå\$-'ÕÔ›XR.¨©oÓˆã$†¥fg¸r_÷˜žH ¹6â&kÖ¶5ÃÖm[ó<ö5OÖKv"lµ2lÃ'nÄFnÞöšˆv¤e–€¨]9¨„š•†z¨U™¨Šm•ýÁ…Ù¨’Ê} a ˜š©šº©œÚ©žú© ª¢:ª¤Zª¦zª¨šªªºª¬Úª®úª°«¯Êµ%€²š«ºº«¼Ú«¾ú«À¬Â:¬¦zµ:©Èš¬Êº¬ÌÚ¬Îú¬Ð­Òš;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveButton1.gif0000644000000000000000000002337010520670125020764 0ustar GIF89aÇ^÷ $$$(((,,,000444888<<<@@@DDDHHHPPPUUUYYY]]]aaaeeeiiiqqquuuyyy}}}………•••™™™¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Ç^ÿ_H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]jÑ„†§P£JJµªÕ«X³jÝÊÕ* ¦`ÊmØ!A׳hÓª]‹ö…±pã†uQ`…Ü—ìÞÝ˨Š}Y6(¸°á𣬏±ã”‰d,¹²eŽ‘/{¤¬¹³ç‡™?gä,º´i¡OS$­ºõåÔ®!²ŽM[1ìÚ gãÞ½÷6o„º-·ø]Ù7ñ‚Á%CØpü±ñæ“#=‘âE‹O _qBoŠÜí‚ÿ€a8ôÃÏ¡K/šÂ€{ + €xQ@ È¡_¿`sç–^sëôÙ·à €Á ÀŸ-Ä·Á X`a—àPîAàw‚|)¸ )0Àà rèá‡}…H܈BÉ(v4ê'„/pÇߌ5vˆ#ˆ€-IAu@Þ‰vaQ a~GÉœ{8É—Ž¿Al × jÔÁa¾ÐAœö&abÞE&ofæégK{îÖ矄¢(nƒªèH‡Ö–hP(hÀ¢–5JÛ£A €¤”:×dž˜el:i§è}*&”àê«°Æÿ*무Öjë­¸Î:©¤šŠ*“@Äkì±È&«ì²Ì6ël²ðÊ+§þÚ›ªN†ú“ÒjkmP–ÆæmOšžßæˆí’ãîä ˆ®ëâØ®N(È;/½Þ»ï¿…ëš¿,pkktB)LHQu £‡èf©—BXlh½&ŒQ ÐWqD T÷0ßQ€etcB\¬1I«æñEØ9\ iŠçf†iŽl¡œÌ'ç o Ä&ÃF ÄÀ¥€´ÐÏV §ÒpÞGaÓ33Êq7W´’/ŒÀÀ #X¸v‘ œ=Š&¿pƒ tpa2ÿ@ÁÞÄ8 ÜØ¶‡-<#°+R÷4áÌ¥vI5ŸVöÃažýB ®ø5„%dh÷Û±l·Ý¨‰!…@5#¯ %‚ò 9ëîô ²;M˜å—‹ÝïÈ0½ –0€ ¢ à „SP!A9ß½œ'L¡èNTw|)ÜýFÇAœÍŸ@ëo¼Ÿ›OôöúæS8!ðqÓ¸óŒN“›u,D¼öÙ¥îã]ÓÖf¹’ ‰?؉84Ê/$™3Mý$ò¶µiz¸s˜óbÇ œÑè|ÖÓáF!ç1 d&lõ €¥Øµ`hæ&´†l»» Hÿ2Xš FØZxZ` ý¨:PŒÚ°Á@ñ;ñ«›Ý–Ï Ät&câç°& qˆc;!‚9$ñ/GÂѧegôE³FˆŒàe áY›4"HŸåÇ;¤"²ÇÏôq‘Ði¤g ÉãH²3”¬äo.©™Ljr7œ¼Œ'?Y›PZf”¤Œ)+ƒÊT¶f•’i¥+OËÇÈr–¥©¥cn‰ËÏè²1¼ìeg~©˜` ó5iTòŽ™.bƘ̔Œ3 Íh:fš…©¦5m“L-s›Âf`´ N`Ñï›åT”8ûBÎtŽ©›"B§;ÿ´N¾´sžr©ç^î ÿ;ÉèŸq’ˆ<­©Ï»ðÓ%>Úþ™7ûÍqž•‹1ßP4Å©WÛÔˆ§Ñ7­)h©Ó³‹nhkD‘BH¡8ý±H=£ÏIÔҀBž;èIN¤%æå‡K¢áBµ²÷ègíÉæó÷¬`WJèP¯$%Xv,Á¤ÀBÉs¾…†V¹½•«{¸t¶ñB­³’E`ÀÛ%°V¡ãí,†vÃñöµî}£cg˧ښ¤|u+®ó£á|'±å#È ºSà)mÁ_Ò¹º[Ø<Î΀%\ Çö×ËA"ßó$Äa1C fâóWPþ5JµZìƒEÅQA¼h\ã#*ÆFivÌc•ؘ)8¾Èx•äTy) ˜[¦Lå®8@Zh²&Ÿ¬H¹Ê`óT€e_™f>v‹’^™ùÿÌhNä]Èüf8ÇùœwaÁ8eç“p9)ZžÈ fÜgÌ¥ùRk.ô+-®D+š–ŒXŒA‚”$€´ µô—Œ :'НDR5ýÎëÏHáQ °$Æä/#¯vZœ:`j”pµ$ÃÊ †ê£ð(f¼³Kì‚WÖÀD/6Ô2¿@o?¡€‰>G gSÈDØéÀš‚A›B—fŽÔ à0Ðr ²Ë tlÌç°±sذ#˜&rC¨« ä]´Ÿj"£Q@w0üîÖ i„ÕÖ{duûBº! uà ÀÓÙ©1Ž î–Êf4µ `É|&jÚx7»!iÑ­ºÿÖ›Î;¡ÖE.q¤v8Ì%¦„ŸNNk»!õ&„À¬ndØP d·öÌǃ›Í´µzäÚ¢ïs ºoKæ9»ñ F‘úõ˜Âéõ/jk[pQ©‡¥ÿ,Ø´vd–ïóènÂ}à÷Tw>‰á©ÞFk_ Ρ¼+ðÚ>oéÚͽà¿Å}âËc8¯ n³Ú¾MuÎ+!wq•|NÀäT§µ½0 Œ]Vû¶öù¼ê–Ë÷bŽ:–™02ãÚÜ7µþÝÍôY]ûÍÈ€‘ñl‡‰MSyþýÀøýàr^ÈÛþ?ëÉiÚ'Äyvfäü 1¸sôÞÅ‘=¤á°Ì{a¨ÿÊ~VâÓ®–óÜhwŸö…ÃÎršÐÐR?$™A}F½ß}u̇º¯ÿ‹éE1"T/DCÆ…u¼óB2SÃ&â|4$„atj!2"o=6pBA´ 2AÿÄTDôQT ¨<ÿ$v%ˆ\»c‚ø_HâR¡õ6C“4Ófi€D1"}Ha摱–u3l‹—| Á3€GA<8‘"3ãƒC¡j¸ÖEˆ'÷Œ§9Žöh¹ô…†bèKdXDfx†Ã”†|´†lˆLL‡¼a…BhtˆnèHp˜‡ž2‡~Hvxˆ11ˆ@Qˆ†øˆøŠÿ¸ˆ€²‡“Ô‡hN B‰•¨.€˜‰c¸‰œˆ†žø‰mŠ¢(‡xVŠ¦Ñˆ>ñˆ¨xg—ØŠxаèªØ¬8‹ˆ$‹¸hНúqi_îAÝÆ†µÈMÆ! °…Á8 ¹'R’…vvŒ;‘d1²PÕ¡Y³£6~ó|Y‚%ÜÕÁ%1tÖ{RS8%HB¾…gH:‘d-`%å±UÏ#°8øÑ:Ë…D44_E#5Ô>ŒÓYî¡;BÌØgð˜ÉøY4"B…34Ù¸\¡Å>Î1[%»µ7¦µ?ŸµRÆ(‰˜„‰&AYò51JÄ^Èõl¦õPbRÒ:©g\! ‘ïÿH’d’%AYéÖsõÑ^U! –g3™$'²WPFòg“ ³T#IŠ69P÷ðãTÇ•¶Uîñ%Â(øa4`‰ƒHî!gÖ8q‹»Ønyp—1—6Q— 1hvÙxYz™zÆg}‰I™tF˜…0:)J<™mÖ+ŒÙ˜‡90,ϲ™œÙ™ž¹,Pf•i——) Ð*¹’šª¹š¬Y+£Ò-‘™“V©KF*‰Y<¥·y e±I‡¹ »Y*0œòœ/aœá¹ÈéÊÙœ~ù˜§ô›ÒùÏÙ3-6Bñ&YµÿžibSÁDÖ™'Ù)< "gžQu!Ÿ•%…ÁèsðÉOW]´ž+q/EãES$E aa @²¦;[èaº:vãDû'î9}ÊR`zsâcEº:Ôu¥Iþ©÷‚P·Ð3qá3BþÇ­7»£ŽõfFÔS8O}#Çs4´U c£*Zγ¢0º¢¶Ç ä¶‘CJ„7σ®•ÐYЃã—%šíBw òiÅGëCj¿cE³ãy' ;¾µBápE2ø'5x Zú@Wjaé|çƒ&&9ø%Ù24x>d žYÒ=øÇwnÿ¢y[Š]º˜h‚Óp>âQ <&’@œz"çs7jC&2mH´<^Õ©+ä9ªÇRî³>—? ¨6âH#¨¥©A"Z}E œç«lYl 0Åb"U'ó¨sB–u‚¬?'Sr2'a‚&ÞɈÔÉJ˜ø6iÒÑx{cBÜÃB®ž£¢ðá#ä&#¦pâpéúTÑ·<é:®á>0²;÷Q@Hã}¦u *zæÑ7Øá9 („<‘ÚÅ0\I•M#îU2>b%ÍÓ!”u=û„[…=6›ÑAjÉ6êH#»³rü#'ã87R¥v^2ÇuÔ?='kC÷i3‚>wÿÃDÆõP„7~|#ª*ÚW%dxH”‘Äú]¼ó7O¨£X²~<Ø*K=RcWÙ ‘€¥p‘ËU‚31©'Ñ.8(Tiwç]&``iktâ2¥cRƒÔ2¬„!r©]qK%§®M3R°ƒ4©ƒR>g¬ó&FsQ„ñRJȈå4›Õ>RIY˜å%ë6›ê" Ò…,¶&ñ¥•ÆŸÄ&?1„ACÃe‰åYU‹>ÒiP•µ¥†¹CÂsùÙ¹×K˜È&&ø!tþ±rååç5¹V¦\iù!$>B!ÞŒ«‹»¸`C½ ¡ö9s³ºF`ö9!ÿúµ¹kK鉊"mö1ž[ÑIJàY¾"±¾$Ѿיò;ð[¿9q¿"A¿úkµß:ß³ •J·º™¿ÿë.Ðú"[%1l±!j„3B>ƒ ÜÀq1*Dbã7_7n“«&52ã¶?ô6»3'=ÕSic"arXÒ¦±á¿×ù¼²c°4=­3$º†&®»7kUv.9Î(mrg9Rm/Ô}¡©$Ò©E…±áå¤*“Ö¬u"¬[[žc|!!”âZó̾á}‹AÒMM nVåWG­ÊE$qEUÚY-~Zë6mwγz!ÑC=TâáãT¬ÃáÎñˆVŠ2V¥]Pé‹Õÿ”1Nõß*ƒ—Û]Z=áQåâÑåLÚþœâANX#HèÒ¼6=z©PhnÏÊ3ˆFÎÆélOùöå`±Ð èQçaœ½±ÿ%õ<9þÿô $6Y^„>Éd6šwóÊèÁá ±éQÇ/ͱGP@@Ú³~¬¤ ‚G‰=ÐGn.ÌeÕ+L¦2Âl»Nv7 鲃 ¸Xö©•>—.P§îæ{T„7YR¶r?WãÛXÉ@ÓPd¹¼4š19ãqYâlB¹Y×þ;ÙŽáJ7è'žMÉÚÌÞ3b>´ KÛ=,ìq ú¦Ù8ìl"Bg£t>Ã6`õui¢ð=Ô0Ë¡¢•ðMŠ~ëNéí>Nï°L*óno¬6.&u"ŽqTÃá6B©së~ q³÷¦˜÷ò£ÿµ`˘7 šÖxòÞ±yìQXöó@ôB?ôD_ôF_ô àñ%È3û®Õss‰c\PHšv &+ $ܳ`=D;7êõ„#Aq7tT7V>ztñì”ñ±ñòÞì¥QAvl»&5æ±€Ö&ÆÆ—x»ÓÐ@ô£#Q5ønøÝøR¼“ÑœìnXò÷ÓZñOêGï BŸ±jK¿xÍî”oË÷ª1'ë7 Hä#!êiúDaêËÌóñÏú+ûAûÂÑEÌ×±Øá ¡¾‚n¿joOåûs!ÅZtq'XügÃP·«Ø1ð[V*„?ÿôùÊõBO”F=­YÚ$Æ8ÞoþÍÀÇ¿Oé©Q‚ú&Y°&G=VÜ„a·`Ñ /˜‚Á‹.dØÐ!A %dp¢á 2øbDÆ+jdˆA¡@ H¾8qpåÊ^.TQ`æMœ9uîä¹²AÇžWdl¡rņ K¬XBb‡ *BU™¢£Ì:À@0&V©Y[ÝB`‡£²r%h +¦/ÈšuÚt¬[t\¡ò«Þ1G´ÀÀñ…Ë BA¾H‰Aí  0 Â1„¸p#Oh .RÆfS@ €´é…œ„€‚ç+ÜlÑ¢åÿd‹:LÆ`ÐÇŒ'Så‰VovÙRgÍÄÑ¥O§Îðgu‚žnXÁ`Ä )@îÞ!ùc ÌSXÿbƒÛî-- Qq÷a‹Ý»¨/—+xäF¨% f“Ë»þJèŠ<ŠC.ç^ ®¾ƒÜb¯… ÄNB©>ʪ«îê ‘²¨ Jt-ñ¤Ù,3¡ƒ68I;ñ¨ƒ“Ú²È9ºrޏÃF3*¼ñrd`,—tc ±› ûðJ,³$èº+gÓn¬)‘S´!ñ"¨Ì ˆ<ˆ¸K2=÷T‚ $S;*j“  P®£:18áF;”QF™Úÿ“28)ÀÊ-F;Ì1õîÌ1/I%í ׫„ŠáF -.Ú`ATSŲ ÝšÎ7=CÌ-¨d<m+G2,2òXÊ(;4ªÁ=Ý„“(s®PNèN&øÔs1mš)NÙ¦–#—¼¡—©#xm¼8;Ì%“tt ªÔ-°³®®•š1I+¬i¶Ü³ºA‘»*RÂ¥ „×õk¥Òƒ ø½¸TÜ% H»,?_P Ì¢àÜî¬ ˜1 ž‡À¬Éd¼!niu-µ»‡CI Ôj~¢× ˜þZõ³š>£Ô8kÒ s ¯ÄÈz³†ÚIåɰe•›ÎÆ3(„L$o,Îò†–LD/qYA­Äpt \,Òÿ´¦qBq‘Ðô „â,„ Œ OЂÑh‰Jl™µp6Õlï9£a‰EÀép$R>Ä’‚Ü4Ìh©@!"±º3™°¼Q ›xEêQ:#˜?¤5ìäÏ‹c$#CXF4¾D‹idcÝøÆ•œŽo\ãíxG<QŽy,cùøG@²:{dýXHD&R‘ !ä"xHGFR’ylä$YIKfR“d¬ä&µ„IO†R”’ëä(±JS¦R•Ø)å*ÅDWÆR–ƒ´â,O K[æR—Uªå._éK`Ó!­&IPYLdŠ’˜É¤.™ùLU.š9æ4­™HiÿZ³š×ä& ³9ÍmvSœwü&4Ã9Ntº±œÏ€K„†Íæ'Ý“×FR’´¡dZÍ#´ptÿä¼€¡ì{ç͹˜—þIˆ)„>ö€µü$÷+‹{¸…•ägO{g ’ÇÛ‡¡ñEÏì7)nXT‡7¿&ÿY¿?¿3Ñäo&ÉL~nÖß’÷Ç¿5õ?Iþë?hú?I @d&Œ$<@dJ@GZ@&\$Œ@`š@Eª@ Ü% L$ ÜÀ\ê@Dú@œ%,$,ÁX:AAJA\% $|ÁTŠA@šA%ü#ÌÁPÚA>êAÜ$ Ì#!ÂL*B<:B$œ$%¼#&lB‘ê;nŠB)T3ƒ²Â+Ä&*¼&-ÜÂ8[30t©'´£/CoêBm‚=4¨ÿ2œ£3Ôˆ÷¨£Ò³£p}qˆ94ªÅÒ‰;”Â7„£8|ˆ>­-†Ø¼S#‰>Á ¤`ÇØ<@TCp‚Ä,Ù ôY æÙ/ A”T‘ m‹‘®Øت«É ­b@E¬˜–ɉ>Á ý2ÆÅȪëé€UœD1œš?iîØ–kYßÚŠøáˆ´÷( ÙàE»ó“gÌ5¡bÀr¶0*<™­>9”Œ +¶jÆÆm±FÿòÁ@¤#Kä´­êšÇB*^,‰‘ȵ˜06¡*œyL YÉHi-¶H®FT•Îè½ÂG}\´·’Ä&\G7Ò²·šÅq4ºÿ\,<1²¶º}Ì|üGfÙ ˜¥*~3*¸è¦ÂC€DÅ+Ácô´d—¤B+>¬¬ôp µd‹EûÊôÙÊ€Ä6$'J4§®,Ìt’I6"LÅ„#ÆL#Ç\‰`Çì¡ÈD£É$  °ÌËœœÌì£Äü£Ѐ% Í–M2ÚL’2”XMÖD¨Ã|&˜ èMßüMà NÿáNâ,N㫘Gº—lŠ¢/Ñô,µ4m:³xº©:ª «ÓŽÝ!I˜ô •·»„ˆ"39;YˆŠX»jƒ;¸Ó©¹Óä¸;ÎÉ»³Ø;uT…‚T^­˜›¼OT ÃS<Äc Å;ªÆKšÔQ‹‹¡)¦ …h>Æx>­àNü±>û’—e Hýîã–à{ŸñkÔ_í‰ }Z?TËX‹ºXÆPE§ }Ú¤íÏnQ"âO­ ®õ!¯ýZR‚ZŽ’Z²…A³%)´MÛ\[°j[·ÕA¸E,¹ÛPêÌæÔ§HP¼E& °€\Â-\Ã=\Ä5\H€¿å&È"‹\É\Ê­\Ë¥\ x³ÆÝ\Îí\Ïý\Ð ]Ñ]Ò-]ÓŨ€;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveDialog1.gif0000644000000000000000000002512410520670125020707 0ustar GIF89aÍ—÷ $$$(((,,,000444888<<<@@@DDDHHHPPPYYY]]]aaaeeeiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÊÊÊÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Í—ÿ]H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*] T„P£JJµªÕ«X³jÝʵkU˜ŠKv"† F¨]˶­Û·pãÊK·®Ý»oA@ˆP¶¯ß¿.ZhØe…+&š¢Àâ• F<žLgãÊ'#cÞÌ™ååÎ"5ƒMúãçÒE£^ÍZâéÖUÞM»àëÚeãÞÍú6 ïì{øÂàÆ“?.®ü òæÐý2>ðùf LP/=}»u£*L¨ÿpÁB»@,\„ï= óxØNº;õïD=``ÀƒŠþ.Œ úñ7ß~$è‚`}œÙ~Cp à lØ¡…jh.x€ œ!hBGaP(4È¡:Ø_Œ#ò‡‚´wbŠ®ˆY‹Í½ˆá „ ’&É£(ª(äfD*g$PX¸Ÿ@ñM P–lù¤ ' È SéXš] p0 °çœrb( ¤§AŸlRVernjhLƒW行z¶&›‹6*éI‰iP$X`ç¤Ü=šæ¥A €¦œvj(¨@E£nZªš†.ÿ°^´Öjë]¬ºj«¯Réé”$àÕ°ÄÛƒº®a½ ú«¨þdA²ÙìrÏ®­O¬Zíµ¾ž*Ù_+ð-¸áº-O'X‹®³âb„&šD¡Þy±ðÞBô6ôž ÷+ѽïBT©pÑ^`‚ŠDâF ô§@Ò &dBÄ íÇÀÇ^FtšÜÐÁ¿¡B$m¼‘ËMìÚ±B23´ãEÎl²ÁÙBˆjÆ Œ‡BÀ^Ñ0ptAG3´@ôèÁÏwžÓgšòÕr8Ÿ `}fÖ1[Í¡v_ '@`€ÑGõ|W]â„ÿ³ 6÷Xô¹->‚ÒD«À7yj±†¤cx!6ƒÞa×~¾ú°çy»í¢«î±Ó>»0A‘C€‚ëJÞÉ2çŒ/äøn N ™ .?ÜŠ.qÜs¤=÷–_|±—=SÌãŸv¿àŸÌÓ^ºäa¶ùÊ^úþ·×óÀùf怙MÙ9ÝÌ&ð§jÉÏgô¢—éáT‹ûÓBà‚ˆlqšTÀ‚ôm°ƒ$Š“ò>¦ÿÅÌr&Ûü‡=€€ƒ=; ‚½¢akíéPÿ•„=Š9p R!v|˜¾˜MXþD"Ò‚ ±`m0ȶ‘ èÑ^—ž¦¹À^_ cˆ$“¸ â ;,œv°F¹9Ö)cq*b{΀eH2˜›Ùx\f€QN…4Þ…þ¸ ÂeÇ€hÂXÈ ' Nbˆ J†Eƒh‘6\¤ âÆÀ< ±DGÛÐDÊn’jã œPàÇ£qðN~ó ÞPаUÊ’–š´bß$ÆÁ‡y@N„À*Q¨Æ3æm Ò)‰t4$-éŠN š”ª”>,íŒK_J˜rf¦4…ŽM7ƒÓœ*g§˜é©OÔÊu¨Â)*eŽŠTÞ(u2Lm*nžú˜¨J•6T]ŒU¯ ›¬*f«\í>'Äϰ6Ë«‰«YM¥®²®µTh-ŒZ=B0‚p OáüBøVÄ0såˆÞ ò4ˆ)A âdCôÓ×|Ô&³Ó{؃¬§D¸@zþuíTö²åayÈÄ2M>È<ûÂÀJ—»Æ"ä¯ ,Bø“ ÉÿL AâmO× Ä‡¨âídÉжC‡uPf X¢ð…Éxz>\25ȵ¯«‹Ü Ù–&â`†WÈÿh€´%â`–f6Ü8òˆ…,!ЛÜiDŠQ1«€­—?ØÍîcg’!‚JSÒyûÛAÚj(Á ~‚+7þj½É’~TÀéΈLÚ)0€ü϶Ú¾ãqŠ1»D£DÏ…ðë|Û3ô€ØG¥Õ¤‡€ë…GE"n"‰[¿ÈÖ c¼mö&á*xA€o$cïh·•¡Š+ÍWk “€¬¡ø(»EîË‘‘ü'­é5ÿOw• 5 –8-q޳žô§=J¯ðËÓJK' ̇Oéôs6d¤¹,kn4`M–HKZ:Ú-w/½ÒL[iÓL1Á˜Åi•Pz,–‰`0êR§äÔbI5HTV“ÚÕ#5Sdý $Ëָε§“C€dûØÈN¶²—Íìf;;Ù¸u°;¢ë¥ðÚ#¾ÖU@0m‘T[)×îÈ„°ín {ÀeiAÊmîs›ø/&àv»Iòí¤„{ÞA©7RîïŸèû(—êÓ\åÉ« ª;šÁ5†3#$pÒd^¢€šqÿ6J¤4 Þ‘œ2#â|B>~ÝŒ xÿ†Hí XWe/žÌxQ¥±`>…–ÌØ£–ñÕ®†>ã¸XvW dÐ,{'Ò§[Ž0„ðmXéìt¤SŒ@°WÓ$㾪…ç8Ådöc^ Ç,— æcõa]ëò;¹7eN”EuN“!dÆ4ËY’ ÷Ú|½T`9B/š&øûâüxÚýGaQ„žÍ ‚±Äwh{!àÀå—^¶Ä“(‚ãÉìù…Ñf ˜'àÄÿóš7ÞÒ¯ˆNºeQ=³^ƒ0Â÷ȳ«_{Î^ij^£Wëð6‚È­L€¥Ç­¤¥íèz·Cðog<–=XùÝWRÿĽ§À3ͯ¸n4?íç>lE]ü z,š$ Ïý™Um°A¬Zî.æºhºO“#R7>§@R7˜“'I”c¾e`z$H='ôã4P5Œ7/g€OãC;SB4;R7$ò€K†Død{BQ(z$"‰ö:¬§?bO ÀA%$~£t1Ÿ3'£hãC-h<`äY¿C¼3–„“AE´€/¨@x.¤h=}¨^…ç•„^”ƒ‡qíg)ïgET|gÇ!¥“1Ñd…e£†L‚!Ds!ݤLMC/FÇ;ˆ>Á03#‡ã‚5V‡®ƒ"ÏÓÅ•†YBˆ«'tØ5ÿ&'^%׈ËSˆ&€~ÝtO&…b„2s@g¤I³/hbH¡…Z±{êáY<$AôB/¦˜$ƒóU?ãB0ægÄŠôBY­˜/¦e@æ¡/õSŒñà¸âØäXŽ9qŽ<‘Žêxì¸îøŽ5:1ô8ö˜ø˜ˆò…†þˆûˆý8.Q7qé(ÎØ­¡6Áùj™2Y‘r‘“‘ +ïö‘É‘Ôã‘"9Yy’î)&É’Š‘’4±’0éW$yA/ÿY““v“[”“:‰iù“•!“3A“B¹D)F€qG>ISIKù –"7qa6•0ix2]'h0hâÅ2‡w‘sr'ã2h‚v^!Ä;Q$–'+£Äg("'t©•}å•/±fr“%Ü„ ­3"·E8#eX37;²òᘠ¢!ÐGW9]·Å7 Â@™?£Ô3‰óÊ47X¹™ÖF]É“ •#lç“ùp¢!è•`md^Ü]Äc=tF2^ìµ ­3]C"ÿás`ë>¸)w%˜.qd7ÆGæÑœ86œOò>V`cr"‰%6ÿöœ"%Q7BDa„3žÉšëäša^5HŸÒu¶É`¸ùAQ–%éa†ßù›t"gHœåi-& â'ËÓ3äIbÒÙk¶˜™5JÓÕ˜v›‚XB^ ‚C¿W&ˆI Ã \Uƒ[ â}=SBˆÕ j¢ Ÿ%Ÿ¯ ŠÃ˜Š»¸YP”u®(ʈ/«XŒ¨…&°8Z,§I³Zä1¤«¸po¡,a”Ûy”¥A£1AgTjVªU©Ò¶¥¶!£ …¥.cEÍSg·5ÃD?ÕH£¤yC7žS\#DžÓ‚¸W"'£3_´¸g9g{²¸:R¹8$5Í'8^£^¬w‰€—9ÁGgH8DM”¹¹‚t‰{e¶#H%×=œƒ9Ý”‚Æ#A°K563HÙ±>ãCŇ@e5h|輚Ճe–'=HAi§;Gÿ”1 t'…õ€7³z=’!òA'‡|9{4ÞÇt™ó0$wXvsÓƒÐ8Ãxcs;ƒ$"³dòK?#š®Òb3ƒ}q›~æa¸ÑÓ½!ñ"‹c~N£L¿G#_â4qó‚ö‡Á"š’1¶0Ã!R#1738%Û<$1&¼8KäNŒ[3!7‹ƒ10y£*Ü;ÜHÿA­¯ƒ—9r_ãÚ#OcNÙê’ a9ëW®ÒrbèžRÜÓs¥‹R9h u1º3^µ—Å-•‘©EULNÚŒÚ:¬!Á ªn\bL<Ç…Ç!Çvì«m¼ÇcÇ¡Ç~ È©¡«~l„Ì‚ÿ¼Ç‰¼‹lǬ<Ç‘œ“ìÆ•†|È4‘ÉqÉÃêÉÊÀ*ÊAʽjÊʶªÊ¹±Éœ,®,¬üª³µ|ª· ¹ì©d,S°Ë0±ËÀ̉z†Äì½LA1F…¥Ì¿|SÆl•ªÉ3Ô*d1Kµ¡¤¡¥Œ©e"cƒZ¶¤HzF•E¤>ªÓÌSÕÜdâi) šÑaçJAœ 2‹X÷å`—Ø ¿¹˜ ‚":\#R ;ÌíTï¼Ø1]hâ:1(ÑD8äû%^rÑÊc Gg~ãÂ2÷§FÀ«áŸ]kNá $b"£"#=ÿ‚Ïì93ñ"ö¿j,š%fñÿÁzrÓ#²1è3<ˆDx"rPÒaïÔH7.•xKZŠhˆv'rÂ'e©"M—gx–ìÿÜÓ•;«ša²–• Çš) eÔº‡ýZÞ‹3&™‹½ûa°ÚìÍÍ|O]ÑC±ßÇaÛÂŒ,5h‡r|ÖHW@NtZ:Î*¦:¹ò6Pd \ÊÊ%‰Ù)B­;zS¥ÎØÀF¥ÀnD–ÅcÔDïA¤æ$¼ˆÎçA/vy‰ÄódMZ?bKÖ–|âQk­&”ÙÆn'&÷É%ÓÕ_)\Þ2Q™m´×t-:’‰HVƒX^bå²ÇD®£jäþ‘,ÛvRm´%ô¹€[R`_ÂcË#%@ò$€@R' rŸrcHaþ‘z©†~èˆÿN¨™úkGÞ+ðlé’>éÊ–­í:R4XxýÑáY—xØpˆÞïS<aXí ©‰þê°>©ŒªæÎ’ ,£R¥+7ÒÔG°é<z`3b\s{ ¬Óçñ¬Y7›Q¶›ƒÈcžwº*,^“ +¤ÒQwž–8É ”CÓ5®™%7tbœµõ>1ÒÅb‚Ä`¡Þ[oZí:Ù-€-Ëc'ƒÆt|µ2eYZîsuÂg¹ËZÚuÊ™¾ã'€Âg6㞎í'qö®“ª£ï|üÅ¢^ í€Á«¡LÛ3a6^ñþÇ&_U¿ò¦ÑòZÿ¥«óbÿâÍqó6:ó\##1ù-1ó³€ÊGp™è›Ä!ŸM±¬!à Q Ç#X1<<\Ÿò !õÌxÏyFÄC#äT£5±·GÑõÛú@ãËQëöQsS/ó_µªyÙ2cOq³!øQÁq3z«5×42^+¶GÓ0}ÀtMTþ%Ѽ=Vh'6¸–r²Æ3²¦<_žJ$²LªÓ}§ÍATŸ •:asÂWÌ4Œ¸·Ÿ7Vc6ï„=‚@k)Db3|f³DJOƒ“¯ ³!óB"=¼¸ç¹4–½ü>ª\7¨|å‰ÏÿÃ6­û9^[EàK{Ùñ¼<œ…„Jéÿ\k©ÍÑ$µ••[1”BwÄ6í «e];‹ \ $XÐàÁ‚) dØÐáCˆ%N¤H±ÁˆŠ =L(Pƒ‡Ž.&˜pÁሠˆR¥‰•#hpÁ@–/]Œ€Psà„8¸`ÁÀ…£.â,8Á¨4p9bãÀž]xHi€…HN¡2è9²ä…«.  0a€äJIWflh+H™g Úõ8Ô&‡‘&¥P`O…ÞZ3èÇÍ”R ¤Cú0$µÊÀ4e*쪸L£©¨¢þÓo„çÊШ´à[ލ9¹üÿÏ슔½Âj>Ê~Û)Äâ&j+ªf{qFPC• i›«ÃŠ¢)Ǥ¼r½¿rV $SŠ£ÊHŠ‹…ÒHb”*·DÒ€ÉÍrÕÍ 9UkGø>+i©¡BXi¥õ\`«¡8èɮզ ÐËÚ:”KJƒ.¸Í€ÑÌe$â} #È…à˜äÏÀŸÈÊWA˜ bQ¨HÒJª!3w£¤ml[¡JI­ð<]hTŒ3®­ÔÙæ²k8øFks+þ®š€½å˜û«âJó ¬ƒ`Ço¿â‘?šP˜ød—aab‚{<œ¿í#ÄøCAÚ±ÒS+³¤©x¨árƒÿ1))ÒZ¬ ª˜ ›!²°Óˆ~ÆíÓ¬ÓVû!Že;)˵ãVÛC/ÈIn†BŠf!˜½¯!"Ûb¼ »íØt~×pÆE·°/ˆ­ÀqS¬¢ÈiC[rÎcD¼sÐC}ôÑ7'ýôˆ>G}uÖ[w.Ó_w]uÙk·ývÒcÇtÚw÷ýwà1Ö=xÎ{'þxä“—hxåñ6¾yè£?žyéÓ~¾zì³wzíG½¾{ðל{ñeü¾|ôÓϘ|õi;¿}øã'\þPß§ÿ~üb?ÿ‰ìçÿÿüí€lËÌ x@‚ñߨ=>p ”`¡A RЂœÞÅ8ÿ ~P„¸ÃàC8B¾®„ïwQ¹ÕÊ.•ŸGéR’¦Ô¤òC)ÞL‚”Âo¥ñk©ÜZ€À4¦è›)üj*7p1§;_OÛ÷Ó¸a ‹*QµgTõ`©S¥jU­zU¬fU«[µêZàTìA5}H]›R»8€ |¬Õ+úȪ¶p­j]+[+J÷f­˜k]Ÿz׿Uc&H«_!X Ö°4lkù»X6Vÿ|¯Ô &P¹ )FRü ÍxÂY†”¦i£¡IBP@È.±)|ä8ά#(S¥CìôŠ”f©ˆdÃGÇ›$*ø ½Â3ŒHå?Qn€23!©°« ²A8À«ÏHQHiâÀFÄ‘WìAnK~H¢dFxqQN;N #_ä­þV‹B:¢¨$Ãb”Ó^›8ÈBÙ˃„2`{r 0œ•– :—Ò”&Òz§Ýž9Ý4s ¦°Kjâ2l&åC †(£8 Q‘\×Lõ…ˆoÁGG­ ˆWºQ GœE4Ç* TD¢®½HÑ(yÚ›^%ÖÄ\ÿÃ2cd»•Ç>O pv²-! +$…‹ââî™±26ùU­¸æ˜´³¶i®I”³7ìäûáOOS:;T4!i/V8Ba¥ä™=^Ù"Ò¡9×ËZq1½l0kOÌ­RÊWòr+ô—(EÚ‘:b”áÀËkIeÎU»XÖ[åÁp˜°õa¢PÅ@C×^¦ræÐä`v#5¸HgoÒÇ2cäbø4S*¯J¶V6*¥ _ñz¤è]½-N+\©IJP”£ yd&‹S‹i¨ •Õ*<ÕvhePÔŒè÷× 6öÌXžöš€=RDAØ.GØìßäÈÿŒ) Ýín”#8Q¾¢]5¼á ï,y È€örnxÃ8ozßw„tÌ—£‡_×K ¹7Q£¸Vz¥–‘˜XÞò >öæ ¬wõt¾óö\z?ú…=¢ýG‡^Ò•@‘‹ÐéOïhÔ?8uª—ÔêÄzÖeºõ vÝëêczóÄ>vž‚Ý‚gG{QÕ^A¶·|eW^ÜåþW—ߨtOžÝõn×¼ÿ]¥oÏàËÏM¾#Ïï‡o^â·xÆ'Ïñă|ä;xËsòÁ«|æ·yàuÞóÅüèÅú߉Þô·C½ïT#¶@qõ¡jýî^Lõnéóì_ÿCx¾|n”}F¶ˆ^ß'ø,>éô/ð>e ydMÛb+ñÊô½»Qߤ«Ün´IPñ™ü._†ÍÝ~RiaÖÊ;µ¾0}<Ëæ«»¥ád¼Ê"®|qŠúÈ7rú¸'J¾ÚûË"7¢ û ¨¿á$m³Žt!>6J'žÈ $˜Ž ŒiB?HS?b?ÑÀ\šÀé«@ša¢ ¤À¤§øŽD߀ji"S D>lÀÛy@àhAÁø#QjŽi™@Ã$|ù´ŽÏøŠKÒŠ(ÄÑÁ‘-t"´»û§2‰‹‡’˜ F“sqÿ~Ñ4†i)j'‚ˆCf‘isÃ/ˆ0¬ÛÛÃÜAARAâñDµéCÙùCˆ(€&;DD\A$"B$ž è¢ €ÄH¤½I Øä EQER,ES=Tü!ÔâÉSEÅ;-}TbTÉ1TI…JmK½T¹Ó“rTNžLeœM UÙUÃ)USu T-U]ÕŒhUçUXEY•›W­ÕÞòT–¢U]í¦HýÕ¯KTa=,b-Öì¹ÕÃñUd=¦c½ZÙ¶x‰Gk¡ 3‹ˆh•!\Çm•;e]›@e²tŠ<íÖƒ`²).º>ÆûVµAªd{{!š¡ <¼P§A ©®*Ó‚ šàN Ö`š i§s±ÖrE‘±V²x¨ÆˆX‚µ¥ÿÃWëaÖŠp£h2Q–ý¨šh•ÍÐðti¦Zv&r‚=Òv1³—]Ù‚ZLb²±è >’A”ÝðØýYÒú;ŒÍ¤ò1&3˜Zj B‚5ùРɍê®lúÁ€”>3ÓÚ ,¤øKÀèØ Lb˜‘¥Žª•“í̶;ZIÚ!›A ´Œ§Í¢å€'Q¢B”%’‚yZ3ãÚ¡@ ”ÀÅhX^’®x‰”í#¥`[´sیۣÛÇ('gJ%éü£áàèðŒ²‰®ý£lª@¡?‡23Ò5—Á]YÂ-&Ó Ï•âRÛÆMȶåUšÒXŠà{bZ{Š—ÿÉ>ZŠ‹x±‰ÒÐ>3Ãŧx ß Ù+ÞA£‰ëËÖÄ}'ª8Þgƒ]žu¿‹Å]ŸÒÝf•ÈŘ\_`ߣ_ômòõö Ìß÷•WUˆhßô{ÖàY(€ümßú­Ÿø è"Fß•€ x`Ž` ž` ®` ¾` Î` v€©J`d]ài` a.a¾`^*.V6Ÿæ¢þ`õUŸ\õßnÖöœæœÈaú­á±êaÉ™_b·"býµ!$v,feGßyÇ3©yt ÛÌ&ž,_ÍGŒùRÚðâk}A<7“ÛÝW¹âÔÚaÿiÈœˆ”V›È ûAÙ¸ÈØÈHtMã,þ-ZýHŽI¶É‘@ÉåÒsñ•”“–,ˆ—´±ÿø™T mÑ‘EŽ yÛÉF65¬(‘O”ì£ä¤< m1Ï$gžÍ)s>³ÓĈÔTçÕd‰Ö¤Bؤ­ØJö´æ0ÕÜd6öà2ò$NáŒ(’س÷à‰[«ÎgŒÿæäˆç Ïé ‹B>µÀÎ $î IúNèσ O'Á>}3 !IŠõô2UÞ‚Þ ìÏ[û –()¤`q¿þœ‹~“ä’Ðâ˜Ð*ÿLP£XPŒPIq£®‰ Ý8†A§€ÒPYãP¬PâŠi÷™iN1µMÒNÁ™“Ù-´fMyѲØ7þèJù #½¬ÉÑ·V åuÌé»—ñZR:,RmC$Ð&aÒ’pR®ñ€(­fþ…ˆ£",…ì`µH¢Ô!/ÞH–4¯^bÎëÙ8_ÐÃζÏ.mÆmÙ mÐfmÛHmÕ.ئÙžm2lÜÞ9#ZØíêy  +ê€n¶š€à*ç~nèŽnéžî«Š€rTnìÎníÞnîînïþnðoÁ ;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveTextEnterArea1.gif0000644000000000000000000003125310520670125022223 0ustar GIF89a€÷  $$$(((000888<<<@@@HHHLLLPPPYYY]]]aaaeeeiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,€ÿYH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£2]ÁƒÕ«X³jÝʵ«×¯`ÊK¶¬Ù³h³zʶíR$¤K·®Ý»xóž…`…Û¿€j¨¸0J  +^1ãÇ­BžLY¤ãʘ'JÎ̹³ÄËžC#Ü,º´i O—&­ºuæÔ®;³ŽM›1ìÚ•gãÞý÷6ïǺ ê{¸áàÆ“#-®ü/òæÐƒ2/8Bƒëسkßν»÷ïàËÿO¾»„GŸG_Ïsú@8ˆ˜O¿¾ýûøóëßÏ¿¿ÿÿæÇ(¥{Þäž@l`ˆA‚ö´ ˆà;qXá‡-]˜á†å!ˆ(–C#"x"N/¦(£e+.Ô"{1Ú”ãŒÔgEÒiš dPèO‡F§²Ù%H”¦O,ð€ *,é’J°€¨I`Áª,HÿÀ™NºS¥Ð±6 %4´(Eô)OаðÀ,ˆ€Ë‚ * DjdÀ@Úª®Ím¶+8ôëDÁ4ìN ,@‚Ì€ ª²p€$ll» ‘zÛÞ¦}i)ãÿ5@°Gé´®Nø›AÞK+¤¨^\*³öþ°Àß>lÁ¹V«ðÊŒG€¤#E<ÐÄ9=p€ Ò¨m²ö²šÁÔ‚ì/¤¨@rNà*gÕ ²®œ€¹&s$³@4ã„Â[  °Ê«,Ð!ÛëïÑ8%ÜfL+<Ô$MÍBÕhϨ¶q¬µÝ­BçJÿ$7Ýu§x÷pºð¯£sF'x݃ ça¯ùfA¼5Ø >¾\Ô¡®ãy_A¾ÑêµÑ&@ ®³ÀzìiX TйçDEþ›‡+Àé¨|¬½…jA½&,@+_oíszJ:T€î¼å;o'"°òé·q«ƒhü„*+Búýd;`¬¼ýîÝ[ú@¢+GãÀÊÀMqíËbÖÅ4ž±àb TÖA ï€åÉ 7¨Añ p{~ÉßÀÒ¿ä\ ÿIÀ€l ~YÀû`4w¡¦$[A àýD… ¢ÿ‡(Ä p[´aÉH¸·ƒ9ÄnÃÀ™`s dc 6à®$+‡ò«ž°®÷#*ìITâYÔÄ\‘Q ' ÏT<‚¨`q²Ã: \¬@ó©¨Â(‰j¤ÔþRB¼½q‹RDÝ"12?·”‰4Ô$I¸G"¤o©d&'õ½Ýxhá@@ QŽòN¥Ä‡âH€T®r’q£º<éBá1""°bELp±n 8¦BùJ¸±ñI "¹lÉʇ¸²&P ¼6RDZࢤ@ÀM-2D‡ÍÔtÂÿxPaµŒ.ý¤K‰ñr%à£ Ž ÿ;“ÂìgAxÖºÎY±uAh½I‚¨À’²¢ë$ÊüÓ¢}`ÓyXÖF H€Ì“QõœÙ=U2 Óy¯¢–0™µˆ.`wÍ‹•BE¨š†ÊApÕ²ªnÁ«h¢’ÀñVU,+ÖzZ‹ Gù¶É*Í“ï¬å ªùÄ”Rm¥(Ù€ún a&˲ÀLÐ>o²àX*ÈÔ຋Ë+HD$žÑ¯ÈÜ%L-€Rê'« Í…¬@€Z­c̼:7°ž“Èëù•­«U6#ˆøÚx55ÐR>âEœ–d[1aÆ,ÿÞô¿T¬$×é&†| ²·Œe·6Ô7{+«HÔŒ¹Î³‘í «8Ú^ H²ˆùb˜¯¨Âl_Ï­íÖxæVÝVޱ½] TÜÉ'6¼rI ­ï’í €-³Öº¾ àrî‹á[ ›,þ‚­$Õµ†ÉÓòL¬jîP©eÞ„x”6aâj4‡kY“ØÐ|~ ¬j šµ:(™qM^÷V¤økùÜï1ß7]f@ƒdëÈ-ŠUR«­pGÑ«§7XÎÉ: †ä¯JÍHó´yS SȹplÂÔ á¾÷&Š{3Cæ¶"?cß±¼XÞ™ÿ""P{=,u˜ÍÆÑ²kÒTpp<@Ò—ñ,#=·æS) âB\BŸÆÐªi´I$íhÑ@ú4”&I¦+Ý™K›fÓ"5§1ãéÕÜ9&¢5eJ-šTÄÕª~ «CëŽÔ:ÖŠ™µgn½^ã:0º–Í©aâë_÷†Èˆ’±lÎ#Ï^¶Tš™h[ÄÚÒ&²h¢ag;4ÔÆ ¶)2îo/%ܹñ¶KÊm›2ìŽH¼Ûm”wOfÞÁ7½½·m7*{ßyî÷èþ páØ2únH GÝ-Y8ÃGøÌôEâ11Ú !hU†(Ëg Æš˜î,lgÿfHLñòÅŒÜQ6q-í\+LH´@%Í“(Њîüu5wF¹&[mñ\˜®ˆ@U t+ýŸBn¹b^n=›€­b@óbÅ|v¬`YÐZغð¹®ëahØ¸ŽµHik[ÚBp?‘ÃVLhwûY.ð«|&Ó‚0×´æ,Àµa𽀿¬ «@Cýú[ ßfÍK[«­g•vgóYúÚ'­0o/ÍZêÇ8Kâ}6¥S¾_KÀ$ůÖû‹_LÖÙF¬Û,[ä5½Ñ ²*ºg_/V MÏw7'»Û6é@-)>r ø XíYÕäŸñŒî»§<ÿîëüÒ?ðõȬ˜¤ìså+žìͯø›‰ïk©*Y6{Õe¯ýÚv k(/ +’~ùv6£8å‡5;íÒ.™R1‚\A~´€ÒÇf¨WT7F7C+&ÙrcÍ")w¤!ád/j•Â4[íƒ1yd4 H0“‚~´WL"X+3¤!ﳃ0V+Q×wk£z+Ñ ÑzgHhOLQcKÈ„DèH7…±Ñ„ôc„*ñ„Q¶„…MR…t…maÀ%†¡…ÎÁ…)á…Aðtdj(Y6ÒqV}¡DèƒÔb"¨M:HÕ…‚}¤!(Я²78”)Ì$)3äb ð> ðP24šEd“-í³V%¶E,¸Eï$Õ%L 8™²²ÓàK´‚<ÁLÉô‘"(’[t/4fò8Œ¿SŒ“ÿ¶RÐ…FÒB_àÅWs5ùUE!”½×<r6JUXÊ´<ÌU€‚$=‰E¶`s>Ê‘Äç_ @(]ÓPìƒEÈe•‡×< 3ƒ×{ôå.T¹Wd¹EæØP°ÓO6”])-@y/j)—¸¥&óõIa¤âZ_DZ" MåVŠ)—î’>àYÙµ5 ãÔR 5™Ì²Sñ3™ñSާtðH^„Bw¥Vb–8Y9_+æ/¯ò]cQCåRÔ"¤ÌâEýÂG½L÷µ< Ó{í3€¯Ò:-%Kjdƒ\6ÅGõTºùVê£{;uXx5¦|Ä3©,®"[J¤)Ùu³©‚Éã;ËT“ÌU×l'°Ë Ëxò.UÂ@!DÅ\T¡¸ÌW ÆLоSÅUÆV™…qY6B+¤¨bJˆµR2˜óÇNX`´­¦WAY¡M  æ\¬Ý@:Ê„¶ž"S0SV]›Ñ_2èjÁŠ$ÁIr2ÖÄϬkK@JhrA8¹å÷c‘… UÿxÅ“e„3âõ"ž²¬˜d-ÖY3˜h]è@¯„ÄŠu¦.Sã­d¢ñ™%’‹¾/e™vNq-`,Ùªmÿ«¡ŠSjR/¼3hÑX)ýnh¥kÍcD·)ƒHX›&µyÂ7¨£WJºlåœöOo¤¸ˆ/³ªe–cÍ(!϶,B(±»ÎïšPy/¨è ÷¦ÍuÚ³¨ºUº›òáøÆOõÿÚ”À"½^í¯7ãœóõ¸¼“³¡ƒÆ‘lÔ/²N"„’¤„TúË„‘B I¡ç¢hsîj¾!è—¿žù¸8R¨4ÒMyßà…c¹óÑTáµò!óªØ­0Êì¤ÔÆ*‹ ñ¨$k4±Èܪjeh"ײŽþÔ#–®„%|ˆùg?K'¥‹ ùÚ™ôåíY¨ëÒŽ.¸ÿ˜÷€ìfòц 2T‡z'¨ÓÐf!ˆÓS0ÄýÉ¥ bÏulV«!Qê %¢›øfÁ:&ƒÉY¢ŒTp½$F[%¼Nv,“Íp§-¼ùRwvT¢b¹¥[øºáµ6 Ƴ|æ9I’Ϊ%­-Jé}3!"P(H‘ÓEQ1MLÝËw‚ÖèQ)àY‹‚d/*Í$G›!½jUÙ¤&*)RˆjeÆÍè3ãra‰0’÷‹dõ%HÉðÑ|~ ^ P@¢²(à1H~T§ÝU¤Hdj„U‹ˆQ*ªyeÒ¿ª ÄF@É/±µÕœç—\¦ÃwJYÿ>F•ÁÙ¦Œ€À2›³ˆ[5¨aq!‹j¤ZØ-,Sï<§2'òµE­ð9yÏðjÕ|feW×H +sMS‰¬DS7ÿˆ†3– ½ “Öç˜H8  PîHUðÍFV2žwÒ$!VI^M>³%àå„*ùœMT3P¡˜ s íhmRÚŠ׸÷ÑNUÄxE¨ +SÅ×§ô„Ùö\( ê4@c6¡~†.ò ¨/)¢JUfWZùä®.Ó¥~2žÝZÈLÆk^òP„¸N]îq;#åö79;+(kF™TñŒH`Ïf–´–1©QS’Fu# 0D™‘Ðk@` ÛæF%ÛV@ð#l)#šT—´á²xeQ[2ˆADE‚ìWÀ,ú¯³ ÝO)¦£H²ªË_x~ É,ÿg“Rɳ§A$IÍ1ÇØ5#Ÿ&P˜!‰W\ÂÏí35'<Vùe“L"ÀjA˜4§h¤X!ì–ª yN¼ÑñŽy`Ã(wË-Ì—’bh¹Ôi™c‰Fð¹dŠd‘µw"IÃÛ­óZd3eÕÚR+_-®;§™V{š$ø| G£N]ŽÊe~*(Ç;«U0Ã…ØY̰³Îªë…c1Õtö3EŸ#Å+ á :J¼’¼íy!žôBbâ”ÔöxŃHC8Ò[ÒŒªRµ­¶ 5é…t{økÈC°s³Ãü¥ÍTT´…ö©˜’ÀGt¡ÓŒ.™ÙMÿ\,¤ž)wK¼znE¾·¡ãZ©¡b›×'q5#<à3éa°ÝZlÒ&ÛEÈ­7P°ðep9ѸÀ×$Ðà¨Rñ\%3c¦D‘y†tƒ/J¥N Æ®‡ÎBsøœ%- .–‡(½á ™`ÃdAìŽ"©¸õ8©ÔUf“i†Ù­*éÉA[rºÀÚȪ¼îFuj’übª{ˆÀ(±n¢Lœã¼ì^Ñg…]AÿU]ÈuNÞiÕâÐ2°v63pp”´­<Õ´ólôT§ C=u„XÃ0É ×BqbŸW:IIÛPqs¹E ž ’’ÜÜê&‰Û(r×ÚBÏ$Ì˶ó ÿ=Þ3¤ÚPEDÓ½‚NDøqˆæä6â­MÛ„îsà‡2x‘×ô ñ¢Ú2óèT ÝÝÇr¡^Ê-yñŠrcœkSÊëDH7`–Nz$Iö”h«Aéßb{&ĦÃÈ0¶z± ¶®‰¥ê³¾š86Â(­ ¦Gzˆ%9ˆPÓ¨®‰ÀVܱÀ2üñŠjˆDªˆºŒk¦Ï¼ƒ ˜ÅK Ó<ŠXŽº’¤ óŠ:bŠ`«õ2ÀL‰T@˜`@¦p@ºk¦¤â¡ù¤ Ãј¦ÝxŠ aAcJ ºè­\¢’)¿¨ ©ÂÍÙÌ™°•[€¿ð–GË:E»ÂÎ@ÿÄâ¨Ù * ŽœCâȾ~ÁC °:3ࢠ~ÚMI§ùªB'ˆ-û”¼ˆÖÐL©Bá ¼'Šð¬+— ô!|¢¶JYÄNù¤{* ²CȨCRd =4™TÔDp!Œ¦sðÅ›ˆÅ  8q¡¡EüyBù¸S4¶UÜäŠtÃf2,£¸oJ· ¸Ÿ €°ly”6•l«„ Æ;Ä>n¤zÛ€Ñ0*9Ë1øµ É–x¹–³PzªÆúB6Ùxaqì–¶PoÑ–×ÁŠò2 S F!\ŠüFå0½ž¹îöLlˆf²Ž©ˆTÃ"ð ÿJK Õ˜–3Bª€H°[]‘1´1¥m4È(ȤPI” Žƒ¢…Ûˆ|ºŸ„ð–K’’xx9Ã÷p¼5K‰Ø$Ôø" ᄃ?„“–LÉa\¦\J4‘ü©XA©@0èÑ–ø¡°„SL>ÞØ0F*$Õp’¯¡8‚3 È¿Ã#9–<й„JÇ)û fR „äé©3ÒØµk¢¡ %Þ!”¿¨Ž¼œˆ’·I±&mTÊ¥¬Ë¢ L»< ÙØ§6z€è(¡Âjj2”Ø ´ØHŽ03œ9;^é‡9›3šŽ}ê œ‘ q«9¨ÈL¨´L»LÔ(®S ÿ¶c4‚p²à¼ ]ùÅ“DIÞŠæôÍÉÈ9ÅÈ hÄ N›`’|YNƒ|ÎðNèL Þ{ŒÚÚ e„ kLJݜ̧DŸö OøÜNÉlIð̉úŒÏ¥ ÈS¼ÏëÃOÿ4ý$Eþô¯ÿ,P:|KŠËbÐ|O}ÐZDP¾RP?cPš°PUÀµC }‘ ýÐÂØÐ9ìP3qP=QãÎo$ÑnDQUÏñÙM5}ÑÑQ ¬Qa´QÝ U@EÅÒÆÑ>"R%…‰µ¾ eÊ%R”ÐТÐ{Ò4AR)…Î& <,ÅÒ-E¥.•K-å¦2 S¨Ó=Sÿ bShÑ89Ïš8D4e 5­P7Õ¦<Å3ħ!³Î¬©Sù\OúÜÓä2T)ÂÕè Öúk¹@úˆÇz²XG3¤ˆQ©•£ªT† ’®x  ¡óT·4RnüRDmŽqé €€ãÂ!‚ïx™ Ñ™bZ€Œ—§ ЉÉùŽŠiU=‘+%Õ– ÒâÒT ´f]Š6¹Ô°‰©ˆY厌Q'qiÂéSZiáÊ ÕÐ +¡Ç Td=Š;½ÒgmÀvMŠhU ȡ֠i“°± 3dŽA¼KJ½¸Œ}Ýj]tMW="õÆT‰W¬!.MUZ…WåŽÿA13LˆÚʯ‹1¿ÐŠ©ùSƒÕ+e=ÖþBU\i“[Ñx†aˆØá™aŸ¨€Û$½EbŸðÀٮٳ|•’5ÉùdÎw%È£ÚåZWSÙ$**UÚå`Ú”MÚ•´Zã ˆZ©ª].§M¢P€­íZùZã ÛâXž*[³5š“…Ê@+º­[»½[¼Í[½Ý[¾í[¿ý[À \´b€·½´-µ½ ¶…(·-Ü©[öTX±e\®uÜwÜB•ÜÒÚʵÜË5UÄZºÝà€ZÏõÃõ«Ä=]øLݼZ]¤°€ë”Ã¥H!¥à–)ü$Öˉ߉Sž3ÿ㬠I^Ñ^« y3²ïëÊ[ª1°‘3s5 ;À›Cä,#Žƒ§I‚§dLù ÌÁ ª±³ÕÌ/Hª™ `¤!8%­ã§ºcž‰«ÊŸ­0*Öâã™±–Ð3–“:ˆQ‘®Zƒ§é ]98æûJËÀÄeŽš··8ª2˜R 0¢]%e 2åà©àÌ3\¶ÔtæÙæ·Ã U¾s’“Í)µ¨¨‰9M|¥EzÎLsqHœ aO tÒ‹ íx,ø(<ѵüaÐÝOÒ­L-Å7B+’  (:•f‘¢f°ÿ‡>EðYRˆ¦(‰Ö‰DÉäµ^ î΂ 0e]hÉh…Úh“æF”'•^éSlélzi˜¶C™–%š®i ¼iTÊi¶>ž$Ÿþi j=j¢ö3£Ž"¤Nj[ê$jj§^Ú>R!žêo„ê’j¬ö+­¾ ®îj¼úêö k±f+².³>ë§JëàYk¶)·F¸Žk…škÊ©k»Î&¼Æ½Þk1­êSéÞl›ìнjÃ.jÄ&hÅ^l¥nl%lç¤lÈN•¾.›¿¾ì Êl¥Ùìû`¦9±ô´¯„f f‚¬ê½ ”RÏ.Ðf¶•YˆRƨéÈ›àXÕ èíÚÿ×&šØ®(#Ó E¹$Gü$ 𠀍ðÃnü& A¼¬‹™…# êV8=ÈyÁZÙ²…ƒÄÇË'Ýø.³ýí’ nßz 3\4 Á†)½í€©Q»ôÃ.9;'i˜ˆÙÚ¹€–ÉE8Ù•©IK$ô0XÝÕ ð·EoQïšpðîFָ؊åX;‹Ý0!’¡ÕÄÜÈ ¦/˜–qØ]Í-”šé Ìà9&U ÿ § ´¤y Ùk9: Y©–K?Õ(ò‚PñçN ÛkåØ»êŽ –tžÂ¨i˜Âíq~ùq˜rk¥oÿ Á |«˜ ‘!¿'EÙ© ›×™ˆó ©sÖ´Ö†År­¡!%Ñ !sÉæPËþNÒ5s–õï~ÞU'9qÙ‘õ‰“8¿–‹ ››…þ‘• Ùt"áó°áXÒÃ¥.ŒïÌH—ó>ôMtÁ[Ž|"„ Äù½†˜ˆ’¸rZ·6쉋hûõ`¯u„p6Mˆêè]/(ãaˆh›pWÏQX·ÏjçìóÇ,l ~‹Ò×àôèâ_ù`áQiQœ DáCæ(Î’6‡ÿ~Y~´Ño3_i‹Wìá´Q¤o(œoP¦¸Ÿ"vØ#þ¨hâÆRbI‹å–â œ-+& ,(YÃ4Õ_‹/Þ°0Ί12V„@ãV'$nãîßðê‘ãµgøÄw-Í㬠H°XP…‰HHÈÀâaÂ… Y<ÑЂA ><á£Q\`¤ˆñ€#‹$]²8P“cE :>D!áÉ“,ˆ “åÁ >fØ@òáÇ›,T­jõ*Ö¬Z·ríêõ+Ø®8pe ",Ú´jײµŠCÛ¸jßÊåhóà@$î>XÓK‚P$¸¨@‡y9ÿ.8+°cE'Y¨X B#ϨŒÏ.x€âñzmæÍ0Ð`áÉ•U<Øy´¯Cš,$€=ðñl×uwóîí;ëØ²g/Þ›®ñâÈëÞµÙ¡³…»¦!v–pûeÂÖ Zx¹÷a_ŠgAx°X{ÏÎ v>0ÁÂÄË àŸJ°Ñç òb|°Á¡yá‘dÞN‡p }Ó·~ÝdÂ&7!…^ÜVfY¸!‡nÁÕ¡\ËÉel '’‰’"‹-‚…¡Vº8ãqÒ–ˆq´ÀŠ7ú¸ „ý8d‹0f%#‘Iz•£’öf‚{MJ‰U”SZiœ‘X!y%—Lvi#—aŠ9ÿf’Y^µ%™Jzyåšiºù&œ¿™išqÞØæ”xÚ¹'Ÿ}GV†Ãù9£žM:(¢‰º9gUu*Êá¡IFú(¥•ÉèQŽZ:á¤Cvº)¨¡rˆ)LšŠúÛ§>¦z*«­îF*Ghàjr8H檴꺫W°öD€o ;,±Å{,²É*»,³Í:‹¬ ¬àf®¼Z{íQ¾>´Ïzû-¸áŠë- Ô‚‰-ºén¥­º×VÛ.¼¢²¯®ïÒ{ï£óâ˪½ûú˧¾ÿ‚Ú¯À§°¨*¦•Â\‘ð0Ä_™ñÃm‘€b[¼1—‡ú]ÂJÜ• ¨¬òÉYEµÿÀÊ*/ “fZmÀKqiÌ1ÏMz *‚X`ÐgïuÛV)+vÅV)Í•¢e|nÏU\nºDÀp B*/eÓ„•-ÐÐ ÍQteÇt€"x²G‡½¶ßÐ(Ð àìˆZöÀßhçåõBµ³ÕÏø³¥Õ”ó¨ gC›`òlεÀJÖÙ…š×"ìUàu@H0#øÒa"€òê!ý„‚Ö$A?Qt×a¼ƒ>›AFøUŒ;¾¼‰S*BÈ$þ3¯Í¹ \÷…ByÜÞj?}T9 ÜÛ÷ôa»·_G …\“G&ëg×$„] ÑÝߎÿ‚i&O5óx%çå Š×X`ºš„s!\¸gˆï!?Q f8½¼Ïn0a_MÜç´=¬2¤3àpVüM°bå RË`¢<Ò09TùXB¶õ°ï@ÿ¹Ëê€7óŒî!³Û€×"X¹Ÿ˜€{9 S2`Âö9QÑAtH‚ä=$‹ Üô R9´ý¯†fœÒ %‚ÆpD>P {0" äŒ""ƒOgª„¨ìÇ!ÝQkVbž Xg?û1VB‘ ’x<šÍJ*#²÷¬'‘cL:#ŒÉ€güäã°ÊAÍp”¦TKOé)Oª²•J¥+iTÊXÒòB¢¬ešf‰Ë]Îæ–¼ “.IKX R¬,&2»rI&óJËl&4ÁBx nÖ¼&6³©Ímr³›Þü&8Ã)Îq’³œæó©Ï}ò³Ÿþü'@*дž;ªÐ…2´¡}(D#*щR´¢½(F3ªÑ~2 ;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveLabel1.gif0000644000000000000000000002232510520670125020527 0ustar GIF89aÙ4÷  $$$(((000888<<<@@@DDDHHHPPPUUUYYY]]]aaaeeeiiimmmqqquuuyyy}}}………•••™™™¡¡¡¥¥¥®®®²²²¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Ù4ÿ_H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*-  ©Ó§P£JJµªÕ«X³jÝʵ«×¯`ÊK¶¬Ù³hË2°´­Û·p•²]87®Ý»x󾬛¯Þ¿€ ¦è÷`áÁˆ+|¸`ãÅ#Kfºv²å˘{>¸9³H6ˆMº´éÓ¨S«^ͺµë×§9¨ð ·ó Û´;v8 ¶ïßÀƒ ‡­á‡ÜmmãFžÑÅÌ-²(à":RåÖGª8½âÙ݉bÿÿq;y‰ßÏ ¯~£ùöÓÃ÷É~þÅ÷öÊϯ³>ÿ‰øýgÐ~Úä_ˆ @.(Ó.¤à‚ F¸We:4!‚fÈ„´a†˜ˆ&4¢€%F¶Âq £ŒÇIôbK(¦øÂŠÿµ ¼Àp`d ‰#†:Ä#>¢” @‚@Ty¥pÀ@'0ÀÀ /@•$D‚˜5BÀ•5ziå @à–€@—9t¦ZÒi'žzºRŽ)>™_”'‰‚˜/0€ ð"‘y2‚’2†@%@—dðB¨BŒ¢"ÿ 䩟BP‚Œ )f•tjºª‘Ä:+µÞŠ€2ÙdAŽÚiI'úB /D‹ä¯1V Àq”¦*Ð¥”¾¬ÞF昷–m¥A*9d‘F~ëÁ§+ˆyBºëvd²t-ë$w>K’¹Ójëç¥ÙFËm»5‚»o¶—Lã‘ù¶ä~þ)&«"̺²²»ê¾‹*ë¯@ÍÎ'0I{¶éªæ ²¶ ¼B„c õr±¹ К/†¬ï«9Ÿ 4µ%4…dÐC3P´@Gó«Ðr¦ ßÊ#}ê $Ì£¬'D ϖŒ \ù3'Ô+£ªëž]&nÎH#ÕûÊÿímÝÍqÉýžLÖíqSĹ1j"âê)~ã´9"äçInÓ Ô6nòɘ“§yP+T§˜å†Þè@©P@¦†zÖ[È:P ðzìŒ}î¯êÝÝþ“NíØìŸ çüó°9•ñz!¡òÖÐ<ôÜwoZP)0Bï…Žrí ïñM‰/˜õbú=%€û²û¾¬üÌÑ¿ øC üÄ?äøO',€ÌTÀÜÐ|ú#Ö’‡>qíJW:ŠÒf²¥y°"4È Ô@Ú¬ L!P•H§ $LÈRÆV’+íjc AÊ„ ¨„ž ÿj4’¸ð"F$È à&l%!óUEÆ$®r&‚:bf¶/©•‰Jªê[2P¥#žíK<,ÓqD%©À°m'P”¨¾è)!ÕéK)h#–ˆX­LŠJß:ê„$1 Kƒ#ã!«•,íëŒ;-bæYܬV^Eÿ Uê^ƒãÀ™œÉORÀˆ!€À1ù‚[ÉK®Œ—ÇÚÕÄ@1Ô•!Ö {©ªzQí¥ÌÀ¤6i$\‹a%­ÔI³).0}0^ÉìÒ›@jËH3ž†9åãRÉ¡U*„ŠFZbšH@ÊaÚÐ+h&… 6RÖ)Róè@0¥4‰˜úTZ©àiM©!ìÒ-‹̆NVe­Ô%2¦ 3LZM“[9æÅ[º±HÈ‚›Òvh«o½@£,5%= gÏË<‹Š¶Z&2׸ÈUQ‹Œ}Tl/…TH˜éó…/Èc êE¦,é²³¹T÷å'/QëNâ:NÙ¤ÊdÁ3b U©¥ö°¼ÿ‚–µyýV Yuâdµèê§'JP§—ã)‰|š*zñL]r-:—P…*‘1lmf§ÉÔ+)PÔ› &:)ª©n¢Sy9öÝðNULçEä•gɆf ^uRÔ”™Ö—¨éí/–æKzÝð“ךR 2¸ kP:ë!rS§\1!à™q3ÌlxžWƒàù<ô¬þÖ1ÚÍ ˜ú2aÚ‘øÂ"þˆÿSXË<0Æ,è*Ü#ã˜#3æO'sã;¦Å|±‘Cäü Y2E^²@šlŸ'G&ÊR¦ò|¬ ,/YËðáòb¼ld0·GÌŠ!óͬ4'FÿÍ8fóyÜŒ8ÇXÎä¡ó`ì,b<‡GÏ‚á3ýÜ@FÐæ#tv DNÑÖaô_}2HGGÒz¡´¿,ÍLçEÓËâ4r<P7IÔ¹!õ]L­#TÓFÕvauŠ\íXÇEÖ&¢ufl \G¤ƒ›D"o­˜$_ÇPò1N–¨6Œ à)}ÈAw¢kÌðú-¾~ˆµ4$ÞNcÔ6vüý(eoîÙL š·ÄŶ©}ñn@rÛˆ¤K–ÀkgÍÞV¥'bÓ¤Ú—¹¶[²íœñµaûú¥ŠE+-È€\õ´7^ej‰@¦E¥–>u–9¸eÞ‚7„`ŒÿcC+Æì=A§ÛKëÕsI¤7‘Kµ}wÄM@r;ËÜ›ëÓªlÙË‘àUF R b…6ƒìISÿàÏr.ôëøw>WÐkB°Lé,g) ÕžòäN}êšûžX)GéÝ=9Ñ¢8?Î2Ð9œˆ|2$_ŠÉ’Ç *Y`ƒ/ƒ¿(BU :TÚÕàœx­55ÖN™m›Cx“»K&ïJÙ»ƒ,Ì'Eó â/¢_Lë2€4àùоô§Oýê[ÿúØÏ>õŸ  ðî.ÉWÌÿò‹b”àüèO¿ú×Ïþö»ÿýð?û'ð”` ØÈç9ƒ¹áEMaøW=úGBü—9þg €T€?t€¢“€Da÷w:Hc¸:(e~‰1~Dñz∂C!‚ÿA‚ƒa‚Bqc$°tF‘+Uw!ƒFxÑ-p-¡‚‚Á‚Añ@ÓE8ø^…Gˆ-¥d“b!R•R>@”K™åF~B´Aá…~’T‘ Eƒ”A!ä'^˜…qãGÓåF¶†Õ²…Ñ…jh\\øBC&'€A &GSUøÔE‘'PÉ”AÉT$^ÿ4†$ƒ3YFC<8)^"WMd%½Dª2Lž(4–8U*ÄVY•rŠÉËd&ã"$¥H5Œ˜Š¨xH1’1vƒø…èþsSQxt~•aÖ”åeWÄKr—^ÉLÔòKQ¨V}…äW»¨n4Ò%‚¢35’[ä´*éÔÚ¨$Ƙ2ˆ%÷ÒEJÃŽ„qB–Á³QVV]”’+eDgÃPø8Fa²&Eµr6#w†7ýøOÞEQÁD_5èhWØÔWk2'9úh1gR5r1™z:5AǦdTpIÔ2Gq”OLäU*éG"PF)\M*ÿDŒ­Å-ÀU+ ‰2y“~õ_5%cèßbS§åÑ’H"4ÑÄUÑö½¨¿Øþã\}7ù-geU€ä)pI'ð•¹ørªÅ“-pB5R •ràDG·/"&:¸–a'-ùW×ô‡RA('P'eóPX¸*ôuPžˆQ%(uô˜RN&Ù±•dbt¹t~¸´I¯B–ÀE-CœÙ€GDcšMTÑ–ñ"3-å•qBRªY*¡N›BÂ6MÚ¥.ˆy-¾¹›°xœ9De2€‚H™Uf™ÖŒ¤ùaöa“Y{M’•<á?/r|ùášq•yÿ¡;‚ü!žxAž:ažùžw¡ž9ÁžöážvŸ8!ŸóAŸqaŸ7Ÿð¡ŸpÁŸ6áŸí o! 5A êa n 4¡ çÁ má 3¡ä!¡KA¡2a¡á¡J¡¡1Á¡Ýá¡I¢0!¢ÙA¢Ha¢/¢Ö¡¢GÁ¢.á¢Ñ£F!£-A£Ìa£E£,¡£ÈÁ£Dá£+¤žƒYóCˆ¤ScDªFZ9ιeJÚ?LÚ¤¿·z¥)1¥ž!¤Cá¥(¦™!¦BA¦'a¦˜1…—,y Wj@Y¼Ùm‰˜E~Uê1Â9@ƒ :§T§0A9 -zˆ ÿñ)A!jŽT^òe(wb%¹œx%9(…W&dù%mãxå•jj"1) †jˆ†J³-M™A¤‡n4‡T§<Ái^wq–‚)š2$Ä‚7Ãt)æÒ4¿ºKÞÄÑò%MÓZÒBª„jB†ú—bp•Â6EÀD$ô2•BWÖš¬ €©Ñ¢'@ÁiëÖAÍŠ0IGY³.Ù.Â*-ãÒŽ±h¥Z§Ú*1#4J5—¤v»Eq2r/ÿJ*¹¨ƒÇ¢0×Z­Ú§ A9ƒ-ëš092ïz¬4µ§5q¯$qªMq­Ò>Š4S‡ô2#+8ó®Uiu\:bbS`¥62ÿS1ì:¬Db,ÕjšÛB0¹7ä¥;§Š*2œCYå⪑‹óŠÕÒ-»K/r›a27`#6ìún ÃDãrH²6O‡¬©nŒJE+§Ê-–´'£’&Kä*ÚbN%#ÐqI€V%tÙÒqkkwYm™&R[¢ÏDÑ걩.;x$lµ/yº±Ñ„ƒÂ‰$mÉ4Çñ*ònNJÌ®õz£‹»E‹µ´p T¸"¡4”·¢§{O©{wr^ºò}#F¾¥ ó¹‘GKv£µ¶úlzhš+@½;yÒ¬áOµ™¨N‹á‚ë¶µ›&ÿ° ”Í›»@\V%û†KlrI˜ê©:(¢z²u˜xi_hxh0û½8á0âÛ€º[ CÒ>ãceM“B¾‚3Fâ·{s)iù+Ë*3 ›Icb)•²-C¢p̰"¹ËK<¾¾—c)ÞÓÂ.l­ò ð³›QdãªábCQtÇB/ó&`’½/ä%ÆÊ7?ü%Ýå'LÜÄNüÄïGNqÂ)œS)á¡ñÂZÜÂ@À2G®áü+…C{ƒ\«¼*2ì²Æ­•Ä !Χ}xœÇz¼ÇÖÇ}ƇÂxQ¾8ÑN!€Ou…I*ãÿr~Ç4™yM#-AûKëRœã-þd)»•*“L^t¬¼þ‹ð ÀƒXÀ2* ¸#5<¹82Â1P‹Æp oS6zcsOw7–òH±\-Éë#œIMQÊ´³!À¨"­Ld¡l±gÌŒÌÂÌÙ¶!1ÌÕbÊǼ¥õÔÌPöÌYæºÎW&Î_Ae9†Â[íL¸™œ™´ ϬÙ/Rv‚ <ãæÜeè,$Åœ!†Ay³´‰±k¶+Å»dBK"ÒÈ`ΤDA"J Á QqQýä`mÓƒDT!Iþl’Ñ]ïÌmáÑ«r%ŸÂMÿ4&´Ï Oî• Ò]MeW© e¨ƒy˜YmÈM™1R3C`øD˜2±E«cX-¬ÈD]ˆA}Ôš‘å]}ÈV)0âa0›HÒÏ …$¹rÆ™YÄ œÇbÏ5r›„TÚ•‹±(+w²It}ÖMDEB;(7ÓP¥44êò‚ddHí;’I5‰%Hk‰Ä2ÒQ(^òr(ëˆ/g²´$˜”&˜( øŠãZ©ØOa„Sb"R½´¿•Ø X¶/iU`UJ´uMàDƒG¾Í®øU_j2&ÁEEõR/$°&m7Mí¸‡dûšèܵD5ßåA©*K!°&…ÿÉ1“âaã—Ôrµ¼è;ÕøÔsÔa`ƒLîÔIH‚Žì­3Ø4†ÉPXÙG WßluR¤(z­*"õÛ•IÄLÐT)ÑxV_m;ÏœàÜ´YYG½Y=«’„¬É4˜)T„–}1|õ˜°„B“ˆßSu*&…%%Þ‡ ­*x;YAÒa!þW £VC‰‚I{¢ˆ‘®´‘i|F­…»üèO)ö«e”ÁÁæßeI2m£Ü®V˜$5¥$+ÚUÇkÞQÛ ü¼}3¶(+$0ô§p˜7W¥3øŒu¨v£3çmƒŽ~µ„e(έ˜gä6È”YÑ&‰%pIIW~8Û\ÿn•¾2§èAX^^)iæf(O3›~ù½å朕t2Ûm×9J…MK„QsäEäBØ»D&·ÂÂHŒþ}ÿ2â¢Pž.Uê2\u.Ãð´‹`Å`ÈâEÇžŠÈÕÀýÔÂÎÃ8‰Mì­ã‹Þvy3Œ &†XÛ°„ðc»+i#›Dñ£•ßôöWÜ|ÔìJÍÿý´+™˜³ŒÅ):sšˆ™Y­…‹~ô*r…œ9Ï2iŒÞ%Pš;›:èZ³)MûóHrÂiìÔIßQÆð¥ÔÕhXwD&:(«t8-žy%{ÈÔÔS=-ÑH&h¸öcxÔU^©êmÓBykè™/Ô“ƒ+âÓv¡YË ùôàéóÌ¿äD ݵô÷!øÚ~uã5ª'§Ö´ëiÖ€ùp1ì±Î!È>‘õ¡Í‘aú=ú"ÐkFÎ…Æùoûq&û‹Fûufûw†û‘¦û{Æû}æû—ü&üƒFüfü‡†ü‰¦ü£Æüæüý©&ý“Fý•fý¯ÿ†ý™¦ý›ÆýµæýŸþ¡&þ»Fþ¥fþ§†þÖ¦þ«Æþ­æþÿ±&ÿ³Fÿ#gÿ·*^ $XÐàA„ .dØÐáCˆ%NT ¡EŠ5näØñ¡ŠEŽ$éñ€À’)U®dÙã—-eΜ ’æMœOæäÙÓçØ ƒþ$Z´ M£IeîTÚÔiÉ¡£>¥ºiU¬™fåÚáÔ‚`½Žx•ìYƒ[Ñ®m*v [¶qš•;Vm]¼8áÂÍ{–n_¬wN¹—pÞ¿‡› VÜX£aÇlG&ʘòå‹™1“¼9§eÏ¡ Bµsé¥(Q#ôÀÁµëcW%½úéÿiÛ*A£fÁo'(Bà€µvn¥¸‘“ÜMUx á+N¬ xBøÀ³¯C¿Ž=Å@ f˜â»tê/Ì£@†ÙO//ªœ¾IÕc0è !<êþ îŠ;€8 <ÔŽ‚³î„ï€@BØ"Ü ð­8ªæ»Ï'ûNܨ¹§,ô°…O Àü#Ð@%´®ÆK …Þ€ƒàÄó@<2 R¼ðZX¡ÀI,Q3‰J±JŠXtª@_ˆ‘¿Š¼ÑK5ô Âß €Â3èÉ  ßüCÈoŒÒ8*±ìéJ?#Ò²).ÝŒqÍfÿÓ=ë¤Ë Ç<…sÓ ;K PIé"ÌJ¤”¯Ï@q4T‡UªPñb,(èÔà z;aMf\Áƒ÷Ö\¡7þøûÎÇ’¬Œ8À™ÌÅðÀê‚ ”´/Δš”Ò¼ÓTŠ×ô™Ø¤ÙLŠÚ,™Û\ŽÜ4ŠÝ̘ºÞDŽß,Šà„˜áÌ⬠ÔLÍ‘HNÛ`>@qΕ€NÛ  °>ïüNð OñÏðäNì„·Õ¼ðßkO÷|OøŒOù„O Îó|Îô¼OýT±üÜOÿ´»þüOuíP ½=PåÍ]P ˜½È> P ­P ½P ÍP ÝPíPýP QQ-Q=QMQ;mQ}QQQ­Q½QÍQÝQÅ ;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveTextEnterField1.gif0000644000000000000000000003127710520670125022404 0ustar GIF89a4€÷  $$$(((,,,000888<<<@@@DDDHHHLLLPPPUUUYYY]]]aaaeeeiiimmmqqquuuyyy}}}………‘‘‘•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,4€ÿcH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£JªSE…X³jÝʵ«×¯`ÊK¶¬Ù³hÓªÝ ÂÕ·pã ëìòÈî0U¤—ûîSy~œŠ&@¼äè‹uÕo¼5ÔH½ròÍ-æQe°ÞöÜSÚÐï¶9€Yá^’&‚D@TÔ"”@žU>å-/B7+ÀB€ÿé‚LËÚ3Òå/C½ÿfC Fë™’à"5yÅ@[“V„ŽçªÊî/0a•vÈCÄX`=ÈÍÿ>ø±ý…ðsô#ˆ Ô3% Ë…á ŸWP†6ŒßõÀ“ž ‘ˆEdÈeƒ¢ ‰A× 5ÜE ©‹A E3x+q”à¥b/‚Qb<â÷’8 ¸Lr‘_íx‚!þ*Þ;!âA'Ö-‘{|dÛ" £IÆ pKä.ÙEzR“{ä_ã8 ”i$%GLÉ“¼ ±£EV@(†Ýq º\.QÉN¾É“KLÏ+Ý‚ÈRfR&xA Ø‘R¤_«b¡40Ì*Ä›Ä܈13fëyåÔÒ¶®S²¤©Ãš@b'ÏÈ3vYÕëR0ÿD¬±.Ÿþ$H £Ä€Ó­L?ú]”Ꙃ€v@–á¤È8}ó Š%€PÀÙÉ4w®ÄZÒ²'Ðg­‚NNZXÞAP½ T`y+cÞòºÆ¼ D }Ê[§@˜U¨Xq“ZÓêÀ°VÓ›¾°_ÅÈDvÊõ(`2Íœå3_ÂÒ“–@žå3a 4‚@m ÐÁ À¦Àè‡P†)gÉIŸR7ã*ôN.u0LjF–:2OB*£“±$GñæÑ”lïÏÁó‚žY+•@iYU´'°æ¬RÀ(°j奤¬¥YšåU¯á+ð<¹§$ª•›ªKjH¨TÿyKÔJKådÖà‹ åãÚä<;Z(Bq Ë™œZ¾þ¶P+j-¢ZÛ ­Fh‰“º*U)À¦¤ ¨¯@ÖZ]Õ'×R³­ùÉZ»ÕYWåHª,OZ©k >xjŤ njU)HIVD»†“mKjØÀ9ºÑO={h×;¾ñ¨žÅ£êÀ–*˜'è€påX¨8zµÂsñS‡SúÂa x"ÕMŸ‹¸Â¢n 0HN÷|}q— èñ¬hõb¥8H6Èeh|¹œx"1 7"å•!µÈ0>ò“’,< ’ ÁÑZ†eŘŒ\Ž .€ÑûÐgÿ½[d™¹sfV¦9&rž3vêìš<ŸÄÏzŽŸysg˜:ÐÍ´jMF#Ú8ŠN£E2éGÿ&Ò¦©4H4miÜ`º4œöH¨;=›O§Ð/5©_cjШz#¯^µjZý™XgÄÖ²~Ž–ÁT¡\/‰Ö›ÁõE„íëÍ{9¨v ±‹™cgfÙ6³!ãìÊH["מ¶\ªM™lCÄÛÚîÜ®Õëp‹ˆÛÒIvKÀmn>Ž›Wêf »Û Éw‹+Þ+™7½‚îÇè{!ÿÞ÷Rú혀“y6Þ 1¡zI‘_2›àr1¸Úf£kuÀV£ºÕD*nˆgß*ñ6ëêù7y¾v4ÿ‹] NÞº¹­üŸUB±&¯‚^¼uòüÛ<#ô‚™û¶Uõ,¶Çá"ñvÚD`@Ç 8ª¶jT°âÖÆ2àŒëç飲gÆÎªH]Üf/•ë¢%-éÊâO÷ºö´=ô·½£5‘W¡Ðg±¨@Bý›ÔóEÞ÷òÚÆ €óÚ—à-i-Žñ¬ûý+H<³^ð‚46ñ[|Çí=4§äÚryáy&Ô(uŒïã]HK¯ñÐC]Tm ß¿¹iE«V4`éwÖªÍÉåžIäSרáÿ<ö¦ï)i©Uy70Z­/¼ÆÎ*{Íß¼ ÌÒx{£ô‚ÝÏÞ÷~ÿQ²Íªd=KT/_éùÅ{бª™@:ý€€[¢òlõ¯õÒ¤Çêkú¢,ZçR0GûW~lÇydãy(ámU8Õ W(Ý''¶1\Õò$ZPóP1Ð}·EGQ#)8G  p §b…£prb;Õ5&˜€¿·eÁ—'p7ÑvTñv„Å#†ƒ-¢€pÀF„@¨k3Èkãg„7‘£s„(¡ƒàÁ„F…5@[óc›4‰H¤Š Y6–G…B\I£pu$% '- ÷3x×5/à'õ8‚’yx·/p¡Xq3Õöee$büX[85 §:ie–§>‘GvD\òžÕ5ÌR=ð´;ʸÌ¿¥>Ø^åÓ@¸…/æ5TÑ’%Ð\4ÿ£qÇ“V¿Ô<ºÕúV- ÏbSÓ_Á$-uó5«rUûB1ºÕU–w“-`PØT_s“rä*D‰GYY>€Ç:®‚1Xäc PØôscV«rVW6'©)  å[ÏÓc¦"-4d=FPs#Ó\ö¥ð[&%+éŒ!…XÒ"O¤õV%tÖLZY¹1Þ‚Y¸%WDG õRúÒ˜'šêÃU/Ô*±ò,%Ù>Ç#W)p™®Â˜Ge’ä8Hæ¸5´™ÎC˜ðe_%T“¹›”Sƒ:¹St@@å^©Y ´S…2™Ç5- GÙ˜:A9+Ü´@yI;måO•œÿ$šÉSCÀVÅ@‘UP¦©>0ÔžŠ—I1—QC\”èóB‡™Q`øI’¿˜/Aiʳ\öb—sAœÈ5  T8SŽ[ó–>Í%'/@Zª£, ÄR+é‚Z= D“q^{I3/T URr˜ñY›Öˆá]üt+W(¦òU)¥3Ñ$w5ŠG!ЧR5úÒ<«'€[“67ZQ¤7“*)µV[i/Ôò|¹1/¥Í³<¥rYr"'–´Ã[]ƒš©9¤9¥¥i(å[ÅÈ6ò‰ôéÛ]üDyó4¢!ŒwtOù´:ù47'7¢<—Oó¨ƒ#_ÔWÿõ:ŽúóX_äUCÔO:–jO°ƒ1 u§Á:™j§:‡Ž´‰Š÷v› !Ö¦oQU9qÚ¨7oº¢Ø<2G•y:áb²ê¢„ª±¸³ ¬ÈR«Á .¾zLÄz¬¥–¬|b¬°­Ì B¦ÚyË:­®1¬0J¯ˆ­-¡­Ü*­·&®ÞJà:qZ®¶q®B‘®êŠΊ)ä:lóú®?Á®Aá®öÚø úº¯©Ñ¯?ñ¯‹„áGƒÛZ°ü¯Lu­ Ûl ÛWû°”!°>A°«[¬›±Ž±±R¯Ñ­{Š«„áZ²¦²;±*û,›""m3û²^ÿ±«Õ±6Û=8k]5‹m? «+ÄHÁ˜ˆ1›.›¢Uqve*7¹‹@¸´2´ß¦µ 1ܢޕJ(©ã‚Ö5 G½÷©¨²2 °2õG¼oX·;ÿR¹ ‘†—{“g·—7¶"+òÒ*ô×xÚ1[ótù%¼c+V+pà[w‹só7-×Oü´÷Ô©Q©.G¨C´ržê[¸¿4Ñ¿;˳®;„°;Á€´«Ôgâ pÌ`6Á<œ(€`;Â2QÂIQ)¹hvÁGqê«Â1!À>üÃ@ÄB<ÄD\ÄF|Ä@¬=ŒÄLÜÄNüÄPÌsˆ00œÃ2ü°ÄQ¼Å\|ÄJÜÅ`Æaìì±L6«Ã†öÁö£L°´³hœjjMP/½„M”WPR½Ù_˜y¡¸Ñ tXí׳’*©ã*+)]¨ôÎ!ÏjÈÛ™<=‡wêGS)b"ÿ:O4]5?‰YÒ3©c Yù\'1Örž¡¹Y!S½¤S×Ì0+išÓò^)E(]S—³²^ºeZSP›‰EîLÉ‹¦Ò¡è5TUÌsm5‚jêR¥œ «~R³*à8™"¶p]s1m* ×S)‡¡ÀUÖôÑ_´ÕÕV j!¦¦·B(ÝÒš¥©Vâ«ò5¬ZoŠL‰–Œ5º—U(§RªcŸ}šùõ, *› M”7sÞRU D( š*Ö›rÍu>/U(™µ>ÛÑÙ“S¥&¥OÎ%RÁ* 5Ù¬\É‘œÞETÊ9^`ã<7u~§ë,5!Š*õu3F›>¦ÿ"OÃHÚÜÝPÛGàä‹5„Mã©Þ]y“°"L·uú6îÍ`й5ªÉ«>ñ€Y—#h_"9*'øðt‚!†«ÄõØ#âÕ’Ö°h«W÷¯œDFD1ÐòtŒ7-ŸÛ¸/U>Ùr@I¼¦·ºD/w¯ži.g!–¼Ê?a|wa|ò{{YRhw-“CZö›w§É3@ÒŸ÷â sØÁà>q¹óĺ‰}€=®1¨w⻇{°bÊ ^Ùå¸ÜÁ Ð м۹;SzÓ{@’ÃÛÚªýB4®FÞ€H®®ó§tÕƒt¬¢šR>äí{v[ãkž¡÷æ9çExÙÿ7rŸ;=÷:þ„5¾ËR®£~©Aaè&ÁÂ{ò÷w¼Ãå¶é刌w%ê,Ë~ùK¨œ =÷ê l›séãŠè’<ɱ‹Éíé Q¹Åº ±AëÑêôBëñ’Wæä¶­¸žë™Î& e‰¬×Ëäikì;Ç*ÌêvdÉO´.ìC®œíAÃ&! =s³Á‘7’¯s½)Åîf•æf**Ú<9ÖÄt¤}+•Gâ‰Mîˆ u'¾áOç줎î”=¢÷£|{ +Ë¢¡zÑÒY÷/úŽ˜–w¡Ô3ù·-Ýrq=ÓñÓzÛ’”cîsžë0Ðbÿ<ó4Ä€AŒtìP` a@«[¿ÀõX…yˆÅ@QG-/òΧ/w—|ÈÕ¼OÜâ|¡·{µ//É1_ó^ÿõ?|óAÜÆê!:àó©Úx6ƒ¨xï,Ú 1³ñxtwd)/Ÿ õÞ¼ÛÒWß@Ûwë ¯ðüÆ&(PöO¸J’%WÊ"*¸¥¡–w¹Ûø133t?¸RT#uw>³÷óB1™z~'ÐYçòÏNø<‘§…ÕnŠ+§“:Îs–[5-§#OËL;OC„MÓ²•§M°Òa,º50+Ôrû^9ݼ¨OÁ‘ㆭ¼è áÏïÉfÉýÕ§ÿh¶¤ß ‘”!Z¾„}«^à…-j[¿…Ñ4M!MÄ¿MÝÔÆ}š^ç1$XÐàA„ .dØÐáCˆ%N<ØADŒS¤˜±£ÀS0蘢ÅÇAfô(Ê‘+”ˆÁ‘cF›-S°ŒÑáE  °h84èQ¤I•*¬béÓ‡M¡N¥ZÕêÕ¥$c”ÙAIÁjèÀà¤@bT¨P–&² @lÕP!‚Úe¢=Ða+\¶¶=®]µübeh´1QÆ‘%K”:yjeË™5oæ<0­Ë%<ˆ¡á§+hnU¹VÄ‹¹=ýਸBÿl Š`áçÈ'´j!ÜeŠÛ./*î<ÐñÂçÍ¥_Å<}buëÙµoOã‰1DDˆÀ€$ˆ-H¦ ô@³1Ú8|í‰÷[Ïq óp[¹­bÈ/>›‹.¡¹s2§t; +´p²—d[á€Ä ¹ ~¢-õ"-Üþ[̬÷ZÈO¾½Xó5H˰ÄßËPº…‚ìB ¢0Ȇ$òH$'Êð¥ S(ÅÏÀØ;/%’PLAƒ÷"‰-ð® íR(k«‹Þî½³<ЦëÑ 9“¬ÐH"ñL²¯‡R8àÏ?§”h1;ŸÊð½,:ÿa¯ô: p…¹@xaQûO<`C+-¿$è„P(QL1¢)6JcÓžtãñG…ê,ÔA=¬õH>J€ p"÷f} „â´²J¦ÔÛ/(d•mAÐW‹‚UØ;#œõV"ùŒ@°'gZK°µ¼€ÐoÒ ¼ni’‰·™6ä•Ú¤þóޱP#X-©zi"7ÚÇà½Ûjý­ñ+ONÁ?;ØõóÂZø¤¾ 0á]sûó…?÷øcxeunZ³X“/ü€‹¸Ü.‰õo×^ëð™[py$ vý©_,yèBEÈh¢-K™VkáýÓ<ùúRl®òÈ«ÿiÜ‚*0/<÷|a×Ú‚NÚ¡`ëp¢î•èÅês(m‰NXv2¤‘;²¥¹Ë[ŠY^Ø${ƒ€å«{Þ(#ƒV•¶g« ì¨[»û R¡(Á¸¥®¯…0וsËê&yrÍöÖÎtù¬àÄ@ú$@[ÿk ÷¤¬iD štø>ªI¥³cx¡Ã”æ¾q§L“m­…›J°Eäb^,˜$Ixå{×LtÞ›Cݺï‘äÜH<µà*ë¿Ø|cË-ŃróÒ4¨+<ÞÊ2v«Õ@,ÿÜȯ,iÂÈüÔÒ•¯Ôï~5Ú ÷Ê·™ðI'‚A}x•÷G5Ç9ZJPÿMÉf %Š päR³h?&’Å!ᱨC/H!Œ@#žÐ>»‹Œ/¨´¦Ùi‚@zI~X™¸$%ó) ~äC ~J0ç*ZÞ#Ôà9#ÌPÄ9œ±M.bâxÊC’+â…‡ŒñáñÄ$ ‘H,˜›²Cq¤D[A|R”—U«eÒÊ ½"äd<¹˜F¦F+iÛP‡cŸA¢°££'íx8"IŽAjA2PÇOJ8kªœ¶ò-q)8oIÿjI›ÏèÇE‰¢ ÛJS3.­@&N Ë0Ÿ4L> G4´yR€ðâlRZ©dÌ(KÊÉÿ5¦D%5œÏ (5±AŒ,åJ-= ›”G3 j =¾:K²œd1*ÚK¢Š³(wÆ3mô&(©eM e`pÛÛ ÄÓàq{ 89Éx:Ôã¥ÀÒU¤9ß³€j+$“k9["ûÜ“Ÿiíf52,ÿjöª±i+DË+•b­ø¦DàÙÐÃõ¼+"R7 ,M‰RlcÙXùù ¬>³\×}mñV‘X^%µôÇ%_)qWè·æ±$p0@ƒT®PØŸÖÀ%ÛHƒÕÆžJ­×€ÂÞ‡¶%"L›ØD+ÎýÞ}ª/©V¢ëêBÞôD08»8|8²­¯P=UÒ Ò‘=’ Dû£¢û£Þ˜,²(»&"š9›¹@Ì«•ˆ0!AåP Ï£®8ƒ›+Ò0­=¨>ä4²Y  9´ d[%4j%­½ ÜÒ8šˆ¥÷8¼{ÂÚx·rj9Ûù»8ò  Ô(»'ÁBúy¥J©™'ã/©BÑBJ,HÛ>ÿ"ùAc ªÂó8 G!'sJtb=D Ä韹ا'«”ý@Ý@•Ÿ Iñ-é:s$'k…¡'«/´èŸ !7,š3«„Àí¹Õ»›ú¼ ‘q"´1Å Á?±0¬øèœµX4¹êÄMd P<\„ˆ"+¤ªÁ  ø7Š8!ñxÂá[à¸/~OÂ]Ÿi¼Ex!¯ÆÂŸÂˆÅ0-Ê*¸@$uQŒ»@¤^I3—#ˆU Ã"݈ÁU“ 2ù»Î€ÃA“CªÐGkÜŽÊ¡ !‹8óU ý‘?ÁàUy … YrÚòÙŽá1 ÿ‹TÈ AVì![ìÇc«F I´“ˆ³ 3Òè3æI h!"Ú®Ñ ú˜ÐÁ¼°ð-Aöˆ¨øÀÁ¡Ò¾’²â*ÊÂ#Þ€°:Ó®¨°u‹» „H4‘ýà˜ÛšÀ†Q  ¡e©ÁgŒ•hŒC’ì ~DÊÎ/°° Xꕞx¦ÖÀ"LÊ5ÙX$Š(åÊ(1“ð5ã±;LjÃÌÀÇ K˧PLµÔŒ{ßÞxÈ3) my ¤Ë$Qk‹¿›­qæÅêË-iÓÓ­òàˆ'±š ¹ˆŽôH¢DJÆTŠØlÌÉ(‘2» 8‰Û𶄏MR›úHÿµœMÏ£ìP Ï×œÏ •Œ Qø¼PºJQîSQ½¨-I]ˆQÚdѸºQ!9QýÑÐQ¸âQBóQ Q!=+"=ˆ%=RkLR±jÒ¬1R'Q( +)9*­Ò½R£ÊR£Ì©Ú`l&äRñÒœÓÿÃ3*Ñs2ÈrˆÀ4Ý5Ý(6]‹-ŠU;ͯÀ‹nY Q‘ a:£Õ(‹D ¡ö±°Þȶø 7²«Óô”OÝÓ9ÔÔ§€Ýê xœ°¢?{÷@šÀ°ˆÁ€ƒ2Y­—PE^¡4K ÎÉ<ÍR>AB°šÒ˜ÀSeWmóHü©ùƒY­ù g¥cí‹]Á¾^•¦5ÑÝ¿ ÖÇ1ÖÜá°YÈ?q‘h…Vƒ8÷:=_ t:íÖ±d²ÌGN5(;Öp{ ‘›Þ0IeBUyõ  «J-º…M¡zÓÿ¯Ä×|E ã×pEm ·YˆÉ.WÚè?Œ†…ר‰=‚B[ûµ°š†‘WŒULÖ~…Š<½Y¸ºS‡ ÖmŽ Ÿå -(¡½ 0Ú£›¤õ¦¥½ œ§Z¢™ZjªÚÚ€šÊZ­ý®M%mò*´M[µ][¶m[·}[¸[¹[ºMÛÀ©± ™œíG¯-°](ð¼Í[üÜ[kìÛÁ ÜÁ%ÜÂýU¾Ú¥èÙˆ€`\Ç%[ýEÄ%ÜÌ™²ý¤Î Ý*];*]TE$NfQ›ÜñŒtˆ…qÙA™ÅÐE]7RÝS$Æ«¨.ÿ¤^Ï„Öü/‹@ñ8Þ±ÕÝ#â](ŒlŒ±TOY1ò°¬oœÄgA±+ô«‚T²ž òÀ‹)jí^ƒU‰sáxÄp±pùGéU£äëFëø Ü Ç26ŸeÞr^`ÉæH¥+:ð¸ˆ/¤~‰ð°UðØÍŒ4‹>ÒÄ É$–ͧ“0¤'¹HHY‘ø /¢ ž´L`U‰Õ(ŵàÈÜÝÜM`‰8Éß •îò©¥sÙ=®,Š}–©ü©žL±Ë¼/#Þ®Šë bù©‘¸´“ >DE=Ó-RÛˆí’4zÒ³V³L¤c¤«Ê†ÜÕ\Ù$O¥L0ÿý3‹§l‹¨t7îÞX$ßìÊ “5# ¯âã¨c5®Dàøð¼ÉòõÙãC*_ ¯Ù#æËÌà ¢aˆ`K¡È'²0¹Ì‹M†˜žPAàUÁ𑤡öŠ ‘PŽæñµÛ¹¸^±—(e*È‚ *C¤µÏ+$ÃŒZI~ Jî’5Þ¸‹÷˜L™¨ÌÁÞК: Ç¢ãšD”’á:õ(‹_®¡f¿”Ĉ¹ˆ©³ñ=;Q3m~¥ØÑ'c9£Ä@eŒ “ãoÍÔŽE ÛT^‰SÍÐ×]^vÃa~ˆä¤Åí»4Ó æòè·ñ΢OÂUèîahÿÓíÒ€Þ>Š®è •hÞÉhvPŽ&þh éÉi’öO“¾”Néû\é±ii—^Ñ‹þÄ{ži…餑iœ>O&žîéãüé¡ j¡nL¢.£>j¤LjYj¦.I§þ¨Žê~œj©j«¾E¬ö­Þj7ìjxùj°6<±¾iQ2㲫³²^ëAkëkQëâ„k •ëByk»ö/¼"º¶Î¿Þkjêë8 ìö4lÁ¶#ÂNk´Nlô\ì#Ñëép±)¡WˆUñ_‚p±ˆAƸkÈV«Æþ˜’œ2…šnˆÒîl}æ­âuéÐÉnˆrRbqò G\•Jù‰ÿíò‰O¹® *Á«Õ£'ÜA8DŸX§žxœEnU¡ PA‡‘Ö?ym¡ží»m BÑc€ €„˜ÍV‹€º`&RÝ4ðn˜ÇÙˆñJ%Œxžï4Âu-m=×ðpU­Ñ²WïÛ¨ïµæîAìú”ŽMƒî¾˜ñ™¨WþŽ2¨iV=Ý2öx[õäÜ –µ˜@ÁððÖÞšdÔá Ú,C£ØNi·Ú†íçæ©Q“r­×§TäÎ?™$£—èñJ™@-kñ#¯Y°)m°ê – mŽ]¨ñä¯iiônÉxpOïŸ1äbg”4¨¹”sUoÿ°Yï?bóduò¬Y×Ù1s‘qÐÆr³ÔòÈàòšuPïç6¾Ð-B_óNòµÀ˜ÇYY¿Õ^! G§ tXJ¿˜ÓÊNt3s °x—²®q"›ëé¾" ㋞ߩ‰aisõLáˆS¯ â;‹é™õß¹=ã;>T!gÓ¶Œ°>°u”apþtìþ4öÄCöUöe×sŽukg‡v¤•öĬvâz 6ÙWk‡ f÷>jÿ! UoÿöÄöõÔv à…ª€sG÷SwÿBª­ºw|תªÊw~ïwWª®ª)x—w׬gl–’)…_x”Z)†xˆ‡xÿšòªŸ"øªw½a÷† ÜˆP¨ww‹'6zPÑ z€Áøg£‘OÐ’·Ñ—ŠRRù•gy2æÜ˜ïÑ R¯yÂky Íù"õyµÄøPz&Ez¢?£×E>¿֥РRŠ©_rÙEŠÚ%ÓÛEÇHúUú)½ ß•²2=FÉ^O'@íþ&°[û›mz“{-… l< m¤^|Š_ì½^í¶@_y¼ðͯùE¤09ß—L1sIµÀw_sÔëÕÆr4ú­ÞøE ýe,Ñë_z†FÚ¬ê,`ŽȈSá.º¾Ì%då…s!°¬à¶t Q ®-æPv}‰aÿ†5Ž8áyMáïeaÞÈ/s\¸§Æ§‡Þæb•ýavI™P³à2uüŸüb •È@oçç‚Ë÷²|k 0à€-¼ÙC÷ч‘T+ rJ8a[Âee!…j¨œ†lqÈÖS˜uHÜG#ZT‚‰)ª!†Wµ¸"Œm}cW3®E’|4ê¨K;úø£W/V%$EZe£‘.!™Ög&ù¤UìA9¥Dºd%•?.ùä–Yzù%˜_b©ÿИa®Ø¥‘hš¹&›mŽXf™nnW˜jÊy'žy²gYzÂh§–tú9(¡…Ù§VqÚ >6º(¤‘†É§¤>ªã¥•jºi•ˆ^è)§Ãe㨡šz*…e6°ª¾=`‚™¥¶:+­u•ièº+¯½úú+°Á ;,±Å{l°(°¦¬µ:ûlXq¦€,µÕZ{-¶Õ‚ೂBû-¸¶‚n¸Í’{.¸Š¢ª¹ëº;«ºïVÚ®¼õn¯½‹Ò›/¿†â[i %j%ØV)|ðW/l°Àa-,Ø RñQWµo¿ëùo¤ PÑUîÙ€ÅXÊ(—|U )uÿ2Ê UÕòÀ0“|ŸU8g”ÉGz«1ÐðŽ[«€9V% B+_e°€suØKˆppÃAÏ ìôÑެ´[?=v¨/º X{Ekò)Ä]ÞM"E0`n#ÙƒV$w/÷òÇ/—ÜÁ?PáA·öK‡Å €Ìà=vw"õM^Ï‹M6è’šmèOñ%Ú!ÅÍs "°B þÔBê*Ù;•¥ÝÝ-ÄÎÀ /HÓËNöû }Ÿ ·Å/áÌ@JÕ$Pâ/TÐùQ‡þ=”£J^ /·¶Qc4±^SI4 Èу¶O@Iwk$µFˆIÿ0â*‰õOà‡›ðŒ)¹Oì 2»û¬o}ž!%¾A¹Ž@c_jƒ´õA‡z5±NÀäÇ·ý9-vHÉ£v8›à €«KAðH¹Æ`OkNc sî)ésü¡œ&è'û):-¸J€Àõ™=Ð)E» ä$%÷1_M‚— ¥Eaáÿ´X‚´õ­y2¬Üõ®w‘´p% àaF¼Ä9®HˆyªLåÒšê0E%è A¤Tºå>(’ ÈbðGþq1ˆÀe¨‚ûP Ù -âÁÄ$—œƒd“÷Ò-)¹KA€ç3:²ÒMvl¥£|ËY&餕´$•,o©KÙr—)’£/ƒ—^ sNÅ<&Œˆ‰L s™Î4ËО™¦\J³šuY ¬9¥ Œ@›Þì Vu‚q’³œæ<':Ó©Îu²³î|'<ã)ÏyÒ³žæ`ðÍ}ê&œ ø'@*д =(BªÐ…2´¡}(D#*Ð €Ÿ½(F3ªÑr´£ý(HC*Ò‘’´¤&=)JSÊ•€;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveFrame1.gif0000644000000000000000000002561410520670125020546 0ustar GIF89a ‹÷ $$$(((000888<<<@@@DDDHHHPPPYYY]]]aaaeeeiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ, ‹ÿWH° Áƒ*\Ȱ¡Ã‡# D‘AÅ‹3jÜȱ£Ç CŠɱ‰(Sª\ɲ¥Ë—0cÊœI³¦M‚&„ØÉ³§ÏŸ@ƒ J´¨Ñ£HƒzP á¦Ó§P£JJµªU—"\ÝJõÄ®`ÊK¶¬Y‡ œ]»Û·pãÊ7-Ý»ÝâÝË·¯ß¿ í–«w°áÈ[¬ØláÆ#KžÌ1e®/kÞÌÙ¯åÎS3ƒMº4ØÏ¦oŠNͺµë—¨_Ç\-»¶íÛcãn»;q‰½ƒ«Ô-<"íâw@μ!ñæ C¿É¡@à–¯Ð°¼úõ# Pÿ°NaÚ§«ø|ýAéîcž( !Eó›ÞÏo‚y)4°œr#ħ^{_‚-q¸B „@B( yf·‚r B‡ ƒ †¨’ƒŒ â !A+ ¨¢Št8`z& 7b‚%æ(Ñ|„pŸ@ÐBúWã BP>ê¨V”yQ)Ó )P„a9d ”°pXg%n;Øã™l¶YÙ”m®éæœt²'›rÖ©ç™iÆ—çž€æØ§{º h(šwžYè¢ 1@ŠBúÚ ë=j©Aœ7i¥›š†©z&eꩨ¦ªêª¬u§çQÿª¨Z I¸æªë®¼öêëGÀ+ ³’6êtš»Â°ÊªìhÇB—l±Ä ê³EÛÜ´³à,¶ÆÖJ%·›¢p-¸ i˹趫™ºÈ±ëÁ[œ¼ @Á‡N} ¦@ 4ß A€A'„ãBÖ5l&D%|p‚¸ô²d¯pøvfæ¿6ሔ.9x éÐÈ+%P ŒÇtqpo†Û}Àd Ø '~¿5Ðè8C‰˜L‰³‹}Ìb–\‚Zp€³@@7 Á¾UÓ<%M…@Ôí|BÖK œ“À…Ù2L/÷³f,«ŒZ),'ki°@#$ÿ‡#` Œs°oÒP6ÀÊ#\B4«,d áq€e öYÂ|‰{ÝÀÇJßÝÀäöðxä#œ÷¹k§ÔönoS”ËQ·‚H°Š65Ð!dW‚3Sà7ŒQ$¤ΞøLæè…Yá–Ž`piCøqS¹#lµŠþE_} HÏz뽎[ì“)mr`cð†Ç˜€}W AÔáO„§4µý.Ô››v–“¼,'=Èè0 ¤¾Qoa,*žAG4p9\«^ÂØ·÷Ý~’QZúúV0(iuàÁ‘v4£ð¨%KD*HxÌ”š©îCbb!Âÿ¶£!°‡Îã òÂê…Bad”Bú dôÈâ0ž =ñEd4SÄô9"©E;áy"“X†7 „xú šþ˜Æ¢>Ñ; £ï>p•Ùq;‰ÃͬXB,æH‹¹ûò·§œàaŒt#MIÈ‘e½Ç2‰Ú¦“)Áúj3BR–r“!B¥+gISÖF–´ÌåSl)\êò—4áåk| Ìb–$2¦2ï"L×s™ÐŒH3[óÌhZóMsªæ5·yi²F›Ü §²)Îr.™<2§:¥âÍÔ€sÑl§iÞ Ïeʳ4ô¬§1ïIÿš|ê˜ü?ÿ©Ë€‚f ¥¥A;ƒÐ„ºr¡œi¨C3 ÑÍHt¢V¬¨f.ŠQöiô2íèÚ>J™Š´b$ŒIe›dj Oþƒa4¥’Y©kJ›D¾{ˆy>÷=”H¨£8ŒNã¥)ýFKÿ3ÔУ§&@gPƒ€T©–%›Éxæñ)—Vp9/y5‹»êã&…Ttª P@ªæó9& §0&…7•È®x5’…w!óÐÏ<ÈR˜xJ3œ V…Z­S·'µ•œ{òРĤY õeO +ß6 "‚ãQÑa/žIîoœá  Úòÿ°ÖC º¬›–šÍL³ÂáE«~È´DŠÐ“¾Ç¡Öú4Fâ±Ûr×\Üb I… oc! е»+pÒq“ËÓŠgB¥ï¹“ºœ5×<åQѿȳÚ^òÕ•î*á™ÝÆl1ãI,gf3˜ZÖ:Êu‘Ý€càÄY8á)LV°$L@߉0“–Ãë곿ŠùïIŸâĈxÄÅ*1bNŒâP©ø0,® ±Z<•&Ʋ!ÁNBc¨Øx08– °ã;åÇ€ òk$à©"9˜nõ“¦Lå*[ùÊXβ–·Ìå.{ùË`³˜¿¼a9ùÉl‹2¡ÆÌæ6»ùÿÍpŽs›Ë «3£Ù%Hþ‹’]ÃäóØùÎxVs¦h9ä?:И%¥Žy|h™äÙ/{fÍŒ=“G÷%Ò”¦’¥ù‚iªQ%˜kÉŠX²ßƒ¨rF£ŒH%*hR­‡Þ¥D¾…’ÅA€B¡@ªWPŇ$V±‚Öõ„öÙjd©ç’-ñ°C.·%d*bÏnˆvd]ÐbKK=AZÁ×&D¡}5 a3L£1ªÍj²YZGë „¢™¾^#©gôÓvSÒhamgI-Ú»ùÚMnn£< 7zoXêŒZ{[Ó©b˜f–Cÿl§~‡3¤@ð ì9fc^x¶Ä‚X­zsÿÌ!)nÇ0iXeéHJp°¿9I±i+XÑšbŸ”Û€+æ¦÷Òi¨äÏŽ4¿õr ¸% h„¹#ž€RIJ¯50w|£v¯ý*Çz?1éZzÆUg°ì¹­¨\§[Ä®›±z 'áÐñRô§(­oó±Ð>ïÖ­ÝóS˜®v>«äpeY”¶䬔òzi«"šAÐ œyÿ€g3íÔqˆ‡du¢™£´«±Ð>PšhÿÆîüm@êfà"—®î¬ ÿòYÁÞhó¹²,wË9}·/#2¸)ø6Ë6/_ýÑ®i¨"ðòb9JKžÓ æ;êÅg1åÿÄÀþ³ìi«ëv‚Jomø›=œ('¤–í cSz¦šsU±ð÷•T5.$l5r$z»5^£;NÑ£4Š1;Ê4wwQwOA!—kY‚Iˆ±îbt™Æ "8$X‚r‚„¡‚Å‚q‘‚.¸028ƒÓQƒoqƒ8Ø:È<؃Èñƒk„B(%×w„åD„ga„J¸LèO¸NQXN8…¶Q…dq…X(Z8\Ø…®ñ…b†bÈdfx†´’„lhO x/o¸Mik8‡é‡ƒ‡ÖT‡˜Á‡ñ¤‡0ˆÐä‡[q‡„x†xˆè”ÿ3##°j¶ˆVш¦Q4L",ϵl‚8K”X–X‰•‰)¢"’èkÔÆ_;tH6Ó7Ör”XfyÊq^Úö`n¤‹è9æ$ð{åZK"A,ƒkr ŒÃèT¸ŠïC'.âAÀqÐs!{õ‚C‰uu;cAn5â$àha{å]ß(`{5S1›9èÈ'°Žª§z»¦NŸH¡èÍÅ7Ÿ\Á×SãeY$\bY‚`=¤YÞH8PŠŠ" IâX=02ŠØ'4'æñD!@#rDÎu‡ó$ÂUF Y#‰5#)‘)‘×2Cò’¦ÿ(“å˜PýÒˆVvuUèè!ĵ‘ôx!23HÓ’úŒãqÓf”Äó  óDó!¹øO©“ÖTõÔ“RñNñT3Çkr=É·Yû^otkGDù6!û§6ôf3iÉ–þ4€¾ó?Q—c²{yÙ‘nø,™ˆ–Q!–lq˜ˆ‰yJ)t‘yK³D&0™¡˜PÁ˜}™9™œùžÙ’£™ˆ¥é§ÉÕâ)¢Éš•ÙK¿r›¸™›º¹›Q$Â"„ØšªÑ*ÄYœÆyœÈ+0­4‡Âi¯¹pÍùœx51xA×Išµ9L³ÿ$Ω™ËžÎdžÕV˜ê)wèIM²ñ)°Hq4Ä:^ùCŸó¢4ñøû)½Öª?°8þYC4]XÛæŒè 3Š÷/'0ÿÂ1Š2j:ô¡SIè¡J ³jÿ2j˜³¡bd¢J(ƒ¢|»#¢ ¢A4B:j£1¤JÔÆ1+Z)&&`b3÷I/*¡7ú37ûâyÝs0#&¨UoÕ#4’m»G¥#ÀCC3|Z¥mpè3 ¨8ñ?3c‘h$eô!ez?>SFV:¦x£U ´?¨UTDuZ=o:<–%ÿùžßÔ„ÿÇ/¾#Dç1p×%ó8R%S4u#˜Êk’Ç/k)D ‚A`CVAZzÛ50†C;oÇ/ —C¡3S0R?ú&þ!r*ÃBL²‰à²¤³Ñ¢£møæm#s_z4a68TW5|P‚#hD!Ó^@W̪ù³08‚{Þ‡7¹c2@„uA’\cHª£­¢®™J[Aä:6‡s dÚ“mPIúa°±ªq‰ÊžœÿaH*=Я-Fø…k€{´…%PbE˜%{0S]§BB c×7IK5ÁزÛQ>éªPä@þ1¦ãó?äºmûµcky*¡³g&ÿ£=Qºq7´H©X¡ü:OþZ 3DAõq{6EsU>T33;q{¾cS”¾s;AAeŸ"ù/ùˆ«© GŸ†ã;˜û7£9,wq4“û7Ž{{¡»~Á:I}A<‹ä;ƒ+ŒLÒ í"¬0a‰ *r¤²ll-C»/a‰÷Hk ¡»À:»u‹Oí©PÉÛOËë‰Í+PÏûPÑ{PÓKJ¾ëÜy½uQ½ ŽŒÿ”½-±½àËâËä[¾gq¾¼¡¾­Ã¾*‘¾îKð›ò;¿bQ¿(q¿ø{ÞQý‹RÿkQ¬¤¼Q\³ ˜ÀÈk³ l)ú+üûÀ5vÀ EÁÁjÁ%…ÁØÁÆÁÁ$¦Á*ÂÊâÁ1Á'%ŒÂ˜€m¸ÀÅ¢Â.ºú%<5|ŽY&ü(|5|¼Q$ð(`wŠ¢àA¤¸§((⣛%a·§(%D”#º©s9ì;lKÌkJ*B0”C}Cš0)aÌ7š‹Äª0ÙóÑ0°Õ0x{‹´Äá%Õ©5•]YÊ!»|qÅ ‘Å4葬T= ÿâóMÕB›ç!0p4YŠ…Ïýg^ ÊN«^ÂÎù¼/,‰©ùY5êÜ´DuÆhXØ)nÄbKÊ Y^Ãå"ÍÔwô O'Ñ‘Ï6ÜÌêÝZ×ètý&´¤MFäX¨ â“fJ1™€kΩª+ŒõÁÖL’€·£ºÁ#‰Iœ,³·Š+FI#Ö­ÄB£»÷è;ÏŽ>W>!dŸê8]ûÔ«ËrÞ5Ö€|N,7¸6±,aî”—Ø(‘î]ÔÓØµ–’ÚV>Õ(F€%#@Hñ1ªƒ_kDËv¤‹cS›·8j©s¤XbŸÂ?׳?ÚÃŽå¯3¼±^÷›m{{ºCŸ©rÁñÛA5Vi8î&F¹“rt4sºfüÁ#ŸÆÿ“€¸+0ØÎkؾ·1‚ó÷Yó;G)`íwôìõU|¯.jóC‚>ED0~ãzŠ#£ôP”¬f¢29ãDà¬XÞ¶H‚£¦L’|¢ÛÎÌw¥ú¯Ã^ÁáîU´ø®ïÜʰþÎ1o? cY¬ªóó®=`±–“³£¼?ú®—«670©ðÓïú¾|i£êè3tëzUX2ЯZ+ƒë cïÙ!xl¯áE?ì6åvBv”²ö€“QãúO!83>”úâ;Úúaqñ!¿¹óCP@Cä7Tß?ïôÂ8eúCA]Eg§“Ä/­Úr£€ûö‚Ó@‚çqaÿ$x¨°5;‹TgáT‡]c¦ÏM(¡Jè/ºŠNᄜshÁFàê¡,¡Â¼$¼n ãzèKð0!çlƒ0ºÃ0tÐ3âNÚmE_,8g.¦†kŒ°ë“è½ÊúŒ1ÇdP ĬR«€ÒÀ *®×p"<ÏŽ,A+è,Jí4¾L+Aƒx2Š0(h-´Ð2ó MÕTcжÌl’©'Þ è·áûÀ,- Í=9jñOA­HFBÿ-©‡„BPÁŠ.¿uCH¯sî¯ +JAÓMŠë¯2MˆÃŠ@üðR 1$¢4„õQ‹ uBçdÈ·BÓE^10•FíH;b]ÑPd—½ˆ ¼d6Z—0@HZk¯Í(Pl·%IYný ×oǵ(…jÉEQmÓe×[vß…—[ þ j#9Áãè©öµ°ÁM¤Ê4À%‚%nÝx¿uwa‡&ôÙ C»Ô"é<Õ½„3K,ƒ¸éð06ÉÙ†ØÚ†Sf¹å‡*lØ*˜`ggê„™Ñ,ÀÓgà`fíð²<üVø ªa+ -î ˆÊ©ÿj `¢LãJÐnÞJ£3*4ï;ÙX—¥]ùlµ×6 ƒ»êk­…¡†}N«˜ÊòЧ¾¢ÊÏ¡÷CHIÒèJ`Aýhë—!8Ð**s#º°¡Ò.` î=à rˆoóVD™íCÓ6=uÕ-Zèç""u±r›¡Îua.Äü/. ){V;¡%ZC*Š-Üjšì˜˜gȽ\×÷¹®+˜t³W'uî¿W[¨Ö²¢}éٺ⵶ÉãÕÏïhK@¤FPQ:æý¦`Ä--úRNˆDNŽxÒðP?ÐÏúÈ$“í%¬à£‘÷ 8Á‡ %)Ñ«Rƒ3ÿˆ€ç= IœëТ˜ Æv|鉹cžÅ@jL8#]ÔÒ®Ìd1ÎSz¾”«Ã‡æÓ%A!1] ëľåB^Ù˜È*#³ oXf¡ôææº|*1© m p¦DNµ›Mm.¤š)2DlƇ•½ qFD´c±EGt‘l$!ÙâFBs½¨tzì ¹Hd•g‚­¡ŒûB2IºèŒ|‰"1¹ÉAé|ò#GBé@NþF“¥De*¹wIU–ä”­„e,!ÆJY‚䕵Äe.¹EK]bä–½f0ÅKa®à—ÅDf2‡CLaS™Ï„fK˜LgFÿÓš× É4YMlvÓ›Ñf/¹ùMrF3œºg9Õ‰Ìsæ2ë„g/Û‰ËwÆÓž²œg-ë M¢‘¤ƒfz H*vÏYšû|&cH2Œ14åÐCP‡åS–U¦B%vžˆ›c¨¸Ð.Ût4!(AG¢PŠ”œM&c ³˜×„E¢`Ñ ú‡ÜÔ+ƒŠ[€ŸŒñ*:m©K¿ SdŽz©WßJ„j¨™J°˜ª^5ªŒa(j°¤*Õ›L-fú‘è´2SyMDBz‘»ÌÍ­?a¨CêEÖ²V¢ÊD«0•ÄðªÎA©Lª—¹Ê¥¡ÿX;,_°ª×±N´¯é²h,L…Vf¥ûú˾ÄÂÐ}ñ ,BùlÏòÊÚ5ô²ñÊ,,7 ÌQ%R«bn`¥¡¿TÈbªšÐmúZrŶ•³µ&Á¨J\DW•Èfú˜ÛÜ¿&ºÓÅ®Y»y]kŠ&È®›JîZ“ønx!8^T–7š@|Ó«ÞÕ±·”…d~õ»_þö׿ÿp€<`ØÀ&pâ»àùÒ—möå$0a WØÂÆp†5¼awØÃqˆEüaµ.°€ƒMáMºšX0ŠQ âW™.~¦NlÓ¸Æ/õ±FN ã §ŽÅ˜Äÿq2OÐã"ÿx©M†òzm\Ì$GÙʆœr3iû&„õfk¼ÿ†EOfä*¥eiIz ^Ù"Gfd•㥖áúƲ,ùXÄR‘$‘%ȹ›5çEÊù]ÈוžhdÔÚE"Ø©•±0eðf¬ƒ%M„e‰š[psCËÓÛ˜Û46+9õ‰/Qqˆ¦vˆŒæÎn&4" Í.&%qkÙåöA˜Ž'z±Ojƒ¼ oiQŠât6šL)|}´é'†¼GÙ]™¯šMÈ † Õºõ•s­Ç]£+C;Œa Ô#í¤Ÿ&Þæ0“¸œ˜¯!ÐQÿ}ùÑOs$, “CÕ{Ïà¼cüÆ$~äß÷Êhõ—t[yÝyl7¹â¶RsÀ„s Yä—g•ÏÏÞWéKwÄ»ðÔFâIßfóD‰èå*`ÁŸsz&W:F„=»óQ˜¥ ú"·cÈÇË8‹¹ú7*Ï'S%¸‘“U”N9•±”A‘¸ÀMI¾±P¢ÃS!K©W¡ÃiCMaÃxÝ-ÜBW4LÁ”`{RqU¥¤°½hRÒ½ÔkÔÿ•—B²&‹U·W½/ЈUŽåAEµB0’•A‘–‰EÙVRYfaÙ–M¥—]–˜•ÙR¢Yd±Ù›Ý¤œ=–åYFòYbÚ ¥.(5ÚøZD)Ú¤µ£¥=§-@¨í©@ª”¦µZ ÂÚ!ÚÚýëÚ?ÑÚ¯Ÿ°Ý“±%ÛU2ÙK[ö3ÛjÛó{Û;Š[ñ›[AÛº}°µE2½?¾3¿Å¾»}‘¼%—WQ/äŽÄ•µ$\1Ü©s­º‹¯:«´¨ ¸Êg‰J›ZÀ-´"ãÜšµª3EÄ‘à\“Ó* E ]¤M+‰H€ñ Ó*DÄX"ÿݽ4Ò#‹ƒ/Á1­ÒåÒ°Ý$q WäÜŠiNÃù]ÈZÞp‰¯Æq[ÑÕµkrEqÔÆ 09ÉS¨¼ Õ°x ŽR’ž¡ªCô^¤`=£ª—ö_ö ömE’C"{4ß°à\å#ÐÌ¿¥]ÁjG^L_Ì+/#ñ¸·ŠÖ(^EEÜ«^Ü]ûuÝþ(¬¨Ùžp` ² >ºÞæ¬>Dë _´*¶ð’§£X©~‘à›¢à±ÊÝ FÄâ [kˆ×*ëÝ«Å^vÓ^ÎgœD‹# QL /"Ä(ôeEù9DÂB´ÇÛ—ÍA"$ÆbS´_oKH ‰rþaÿlU¥b»¦~ =ˆ ‚Ÿ8³¨‰9¾c„€– …ãº##Ò Pµc4é'8–c3Ù-Ícè\;Øø‰ÙUXÁu¾ÈMIž>J&ŽÉµdíÂ&Mf`ܸÅäáðätAxNKeá(åti+ å­]eS´ 0±T®ÛYö«äå^öå_æ`æa&æb6æcFfb–€ÄL[]N$A³ËÊ\^ã¨4èI—”dgæV&€i\nÎ o—ÐæMÖÃjö;u–?v†=w†Xx6>Yú€0N]”ð¤=ÏeMÞiH”h3%áE")ëí (è•`h,ùŠÿkœ–h’ ô8z¿X:<­Wz•´3¬H©ƒ°“¶×5¬ B¢˜¸¶¹”I•¡i˜ØK–‘^Õ…œW ¾Ôèòƒ¥­RûR²A!³( ÷Qꃠ$"é¹L´ 樢œ0üxøy q,‰ŠncŽw“ˆPŠ5!ë«ó$¦V¶jEˆ›( ÈxUMسúPäå| \ Á¾F!´3 E9щÊ‹»»Bä ó¸Šë!†kҰνðŽåDl¹_*BÖ[ÑÆ2ºÃá #çi%p; ò¡8% 3rÖ·š€Ž0#3Ò`É ÿΨ ÃöŒ0]P½9Ԧȋ˜7·Þn? ĬÐ<7I %¾¢V¿Xýº{ӃЊ¸sí2Ú˜íf½1yŒ½Œ¬º»ŽRãŽHÎ¥³ÒÌÐÆ+P-òŠŸÛ¾n¡óÖ bc¤©;4Ùé( p SW=è<’UªŸ’(¸{ÏÌaȹYpùˆˆ%ˆÿäµ0‹¸RnÓ žˆH¢â)5¯È ÁÄà g ÈÈæ<é˜Ø±¤pAÊè·#ä°ñŽj5‚Üœ0NÁr§ ˆ¨’Êg…\`©ˆË–‰ Ñ &G,$ñѨØ{´M¢¹ç Èq_ «øÍí0ë»Þ.Xúðnú56ïdX¢šñ&ù™g—g ´î÷Ûs9¿&sþsïësúôŒÕóCŸ®ÓÎ$E7ðHvtø&€Ho2 è&¨€BÇô^ HæR7õSGuT`²Pˆ€;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/DisplayList1.gif0000644000000000000000000000576510520670125020626 0ustar GIF89abZ÷  $$$000888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,bZÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@kvJ´¨Ñ£H“*]Ê´©Ó§EC)ªÕ«X³j-Zâa ŠK¶¬Ù³hÓª]˶íØ FLuYâA·xóêÝËw, E1wå„…YVpÐ5ñÉ 40¤Ø1Ê,§\ÀAóI ˆN˜àÙ$æÒ&t@Mò‚†£Y<-[¤êÚ!]Ã&û#íÞoï¨[4ïá#×(|yÆâ c;Ϩ|ºÅæÖ+BO(={ÅêÞ%bÿq;Âîä#‚Oïp<û†æ¢ßp=}…îï'Œop¾þ„öýgP~Ä_AþXP€ D`ƒ&HP‚šÀ`ƒ6(á@Bx¡‚*¸¡@6øa!8¢ %*x¢€) ¸b‹¾ø_ŒÿÍx\…Ù¨ŽúéÈ£A>Þä}BÙcfJt$}I6i!“Q@ D uJXiA– u e®6—=ù^”M*g€•@Ø0”™&%Á—mðšA ¨)Оm*Ú$œJþöAQð¡"|@h–| f¡&ð©‘§‘€ê|fù%¨&ÿðç§¡.šé@¨fJª›ìA:äo*Ф&$PU +‚Dà)”:à@²ˆ@© VrD¬@0PìŸÆZûm²t`@$HK­ Ì:;*¥ ›À:ª¤¯<þÆ—ÃRJ©¥&ˆP®·&8€'¶°ëµY0g² €½Å~ÐÁkd™­§ WIA;ÐÂÅ¢)Á¼¦‡o…¿@j,P S°°ÉpÉÀϬf¬Á90&«ÃþÌ€§Œy­ÉÛ*´Î7cÐ3(Ͳ½C¾ì!“ËôV†¼ì¤d[1 [ðo$sAìïÙ+p lÛÿʨÞ[ ì„¶Lž×&2i®•Îr¹ç²Œ ³4ë0Û¸‹mСJ‘3@©§‰.Š-ßcºK¹åžB¯¨†‡‡¸‹Š[©³¨ w`¥—_ëÂVŠÐ° ÌQÈ 3„ÌoÈÊ£|Ã(Ï%òºS ª ±{7{T:„2C“n_Z÷Ù}/`‘`¬´ü²†¾uêÿW$}óOW¿~÷O×XA±ÃÚ¡Ò°±™*! XZÖj²¿ûôÏ9˜€\œÄ5ˆ(0!K‹дe%XàL¨‚á [?£W ,£1€P ˆ€ B:`…ÂÂáÍ~ö©Ÿj†/¤Nøÿ Ä@‚1ܲœµ°‚%`^“À +&-DÀ[p›×æp—§>‘^ÒŠ@^SE\[O¼”è´¨rgG–«G©±e¬`\:ÑH;Z 8[ÁòÄ(|`_&°Àkh8HÁ%ÒxyàrF€JQ.† ¡µžf„ÙÉsú> 1ÂÌ©Ð:Ï Dt“òTRX ”ì™n ,­r Ø£DHˆ«- K$Œ"YÂɤtÅJ —fUª8òS{b•·Äȯ ì298ÇIÎršóœèL§:×ÉÎvN •´äY‘R`•ìaZYÿªQ²ËX³Xå'~oü|¢@æôÏ€Ìj©d”eb„h«èüĸ“ k “å¢È$8ßU‰¶Ëè"‚:™/ŽGt§LgJÓšÖTñ¬¤PÁ† ”dž·(O‰2Kx¢·––Rg‰ `­´”,¯ÅФ&‹ÌÂZÃþÊ—BÄ¢aT²Ø…¦?ÍŠÁìÝ”ùš§ñ Tc¥ÍÞ¬…nëo‘ärrz›–Õ‰U•›ªÀdöË£š•ø”X¨hèÁ`Í[ç2AšËÃVr5!$*)ÀBâù“"`-ˆÙÖ°ÑVÌZ¢ó™ùH¦´R ZOäj ùÄ@ÿÍ–oW…d$‡hˆ©V‡%êBFÖó–fDD €t¦^aÖšvËÈJ¬cu+ÄhÂVŠPu’,Áª]˜+k~Â(Ý8LöÊŽ+É[re¢×‚ˆ¨ÜœCÈ«Q —‡cE$pÉPð&^Ih7‚WÔ— þ}XëÈ* #³SÃca4E«‹L¬ú’I4JJY°FHì`ÞVÄèě§îÙJá÷KsZPA^v2•QèÒfù§Jêö"ùsŽŠ³ó`±¹ŸV’eÇÖJ¨ ²Üà²F¶J¬ÒËÝ ;%Ä-#I^Î’­Óäa=ùÿ¨!4Ö ]Ê*´ªOr»Œúä0›1¨ 5sGÒŒœ5O§ÍP¾ÙŒš©ZÆÒϳ“ªrÊ@¹¼¡"™§ÍBÇÐÎAô}[ ä83Õ¥³d€@¯9Y2ò²ð¥Q?ñ£“—Ý{žBÔËA´omG(ÝqËJ_Š-0FÜ0u }~Ö íF†\á•xTÛˆ§lä :"”]HjÙD—l»7Ýη!RÆ…ü‘×+97nÒ œu#GÞµ¡woì=|ËF߸á7püÍ€×Fà½!8j .„ãFá¥a8k^ˆ{F⨡¸l,®Œ—Fãòóµ†à=!øæËÅ<Úâ¸e<î£FåŽa¹f\~>‘‹ˆä29ÌP^!˜'Fæ–¡¹g|^ ;Fèš!ú\Œž¤[FéSazaœî¨Eês¡zb¬¬OEë…áúO¼°ÏEì>!;PÌ>´÷Dí?a{PÜθûDî@¡ûNìÞ¼ÿDï:Y‘€bp`…7*PøÅ7d°©ä'OyÊ?€6wPùÎ{þóælÀþ·€þô¨Ÿ¼&˜ø\ õ°=;3øÚÛþö¸Ï½îwÏûÞûþ÷À¾ð‡Oüô;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveChoice1.gif0000644000000000000000000002447710520670125020714 0ustar GIF89aÎ^÷  $$$(((,,,000<<<@@@DDDHHHLLLPPPUUUYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Î^ÿYH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]ŠÔ†§P£JJµªÕ«X³jÝʵj ¦`Ê¥ˆ„®hÓª]Ë-‚ cãÊ;°‚º.ÀË·¯Q"üªœÀA°áÃ:#6Ix±ãÇ.CÙx²åË!%cæXy³çÏ5ƒ¾Øy´éÓE£–XzµëѪ_;l-»¶åضÒÎÍû0îÞwN÷7qÂ!gÈp|³ñãÉ“À¼ùåçÄ£…pà@,ÿ Ï‚»÷ò X€€Õ­CÆ>\;Ñ PlÈŸEþù퇂z"€@]X ‚|“Ñœ}Cu·œw& €_Þ¥7^ÓÅÇ cö¡Pë‘ â‚ p÷]Š+zˆÔ8_`6"WXXB(ø÷ž@=þ˜ŸŒð¡p8æè[“6ž(Ôé0ñQ¹€•ÀUÞèéä“cJ9æ™4•È›™h¶ù’š¹±éæœ*Ái›œB¡ð¦ÙYžB Àž|zæ§l€U Z(f‡¾–(P0ʨ£Þ8&–vêé§ †*ꨤ–jª§¬)‰PŽ8éO•ZÿZ€ª®ºX¤®½êÓŒÎZ«­·¶Ê ®=!à+°š:IìN(ЊlƒÂÊ·ì³Ô.„ëjÓV«­A×¢–mD$€™!EDë ^š‘é¥7nDêz¹íHÝžöíC*d¨‚˜- .¹â1 Ѩ¨¢DCä¼"ÕkÚ½³&‚ÄËù@¨€Âr­€qo _|d°1At°Ÿxg î¾ ¸lBbzLÐÅ,dœsVæ¼1˜+³2à ›ÛÄ ($€°@Ó?Í€‚@Âÿ²@Â,,° €¹À`3çµ2ŽgÂÖ$TítÎ^ÿgÁÕk?mp×{)íõÖ"(ÿ9÷*J½Ñ™ ÝŽ)Ñ,×&h|µÐß1©±ÖRc,Þ^$X`ò .·xBƒ> ²0ÁÅsOÀÜÖ‹ ½ž»—'B^ÆÜÁ¸O—.´ˆ„säðhH/$µÒTZÀ®åfØÁØ4[c ¸îLWnA“hï†øËžöJ§\PÉ£Çýç5kÏ‚üöî»áÙ!Ž’Ô²ºÖÝÉ9é\ÄÞ–,PÇžò|G€ »ŸÔ¾§¸ØL`¥ÃZAH?Ó]l*š ¸V9¹Ï#¿Mð"¸Íe€]Õ!O×4×=ÓÆcP]†Ç5„‡;.ìZ` ž ,À‡ë_ÿÿ÷:Øt6Ì(ˆ‡‡S{×7ÂÏŒ0!LÃÛÔÚ¦‚i $P—ò¯ƒí%kêj[Ó2ô¯¡`/,XÛÂÇ2,Œ£@ÞØFtq‹9œâûÊ$¿“¨ 6ÉÙ?”ˆ@t‚ÔH=sÅ„Ä,k!iY#Q‚³HJr“&*¤'G)In¦’¤Ü(×$ÊTFÒ”˜A¥+mËËÈr– ª¥en‰Këèr2¼ìåq~ ™` s8Ä|Œ1Ù›d:f™ÌÌ3ÍhÖfšˆ©¦5_ƒÍÃhs›«é¦a¾ ÎÓˆS0ä,'lV§VªóYçôK:ßi(vÞÉô´U<û2ÿÏ|^Çž§?µO¾ôs ÉÊÑAÊ*B2žE”@˜ ¶kl‰(8 Š—…ÎÄCÓ)¢¼Ö¿‡¦F£¹š('+&°T&S\ÉÔµ ¯I% Ùl·G–º”гá¾V£(Ž1›šOAÔî´Ï¤á(]æ™hIHéÁÚtx€±u§kÀ¬¤õÀE=b퀒–˜ŸªŽÍª•:Ùºœ ¨ Gã™ÀZñ³±®N®ï)TK‰Rl©Ô$rÚ‹¼´¤é¼kÍSÏx¼–!mÐfÂì„‚ä¡õhí=í2’: ÌL³â,×<;Ø‚Hu.ó„AdÛµ§ÿ`/ž¬h³él­ðq†˜g³Îr-DáׄÛ=Õwµ%m-a“%!Õ{ú’«oÁÙ¨íoI Lj‘4¡ÎvqÐý,ït™·yµå®t òZ¹Ìó?Ýá"óûÆÛÊ7²Ý鎺¸³€ÅwF ðyã[`¦½'ÀãújŒ5øz¨Áó®²k’7êÑÃ#U°—ô¼1*jc½x°ÖQ]|ÔÚU F8’˜Œ0Æc†ëJ$mæ ÇâãˆÔ4È>²XŠŒd±(9,LÞH{ôØd–<,Q¦bX©\e”\™)YÖ,•Å.{¹°¨‘Àõ&Ææ6»ùÿÍp޳œçLç:ÃyÌ*³™Iòå¥8 ´ MèBúЈN´¢mèxJøÕž GݹhÀRNऋViû Ó›6IŸ•fŒ¬ Ðt¨é…f{qØ()PõªYÝéY³Õ{µ­Ã‰kà½:s] ï.Lšn=R\I±ËCáD>ÄVJ6ÃF)ËØ±ŸFœÝ51m@Ú(Á,—#"µ `{[ÔFʉ†¶S¡aˆKÑ+0Ä»ycIhê—ºwžxc9Wrwg¦Ä€%V )sL€!ÐCí êîT ]ðvãRâÀ—ƒë•Ûò’·Å‘ƒñcg訄ÿK÷QN$D ÂE€åÙKýÀ"=n­æŠóÐr&г¥}gLÜ]Â)7À܉³5¶’ö¶u *˜÷ÕŒî/§uÑ_&8Ïӆκ <íèâIb]ó%s&Ñ<ƒ(Èúwž¦4õ¥¼×"<¬ëbò PlA"K%â½› §ìÊ`׸AƒeÈ_J;ôX'¾žn¶Ñ\ýU\šÒ tìc$Âiæ%Ê/~¹óØã•XWæä¼=_[¸:oÚmÞ}*7 „·Áή† O— æìÝ?¨È: BzÏ­lVÛÐà¾Ç:¤²›¯Üç^@Ù=oq[ÚÜCµÒžèÔ<ÿA\Štå+èñdÉaw+vp´³Ÿêâˆ$ŒE×f^×ZbA]ÝñÔs+äCTB:uÈ/Ës¦Õw!”pa·DxÅ.ürBÁCdzBÇÃ|Ëe<ÆfØ:~*DÎõw²ÿ…‡xñ[ß¶]ºËR{ƒmØw=ë“1b‚‡˜Š7óoLâ¨4EÁf†l14:Ž š W H@`‚I¹œÚlhìC@d“=xc?ŽJ©J1©±,PX@„!S2mÇ=ŠbÐJ:'ô¥S9þ±$Üs´³V̪EzCeªù|‘y6×?ã“ñòTÎ ]ÃTÕYÕ¬AQ2pzT?%SNåR-2G¶¥0¥.•T-#k‘¡ŸÙ䜃Ã:ª©4`s}• Ô°ÇÕBcóBA€H¥.4Cs–ŠVb3®Çm$û| GFä“Bú1€ÄeûB^$6y³\8‚­BÿÁø÷˜[~eUø!WÍc bµZt©•K²WÆšË28Dd5-´=Kó5xµêâ#Ä8°vftÌ¡$ ° #[¥ewÉÿ˸|¥$«ÕC‹pûã2Ò+ 1'Љ]e`ÐUÖeaĸV˜_åÑUæ¼~DayfìkƒF-vcq$F/³»CýcF.Vc¥8½èä ãX)K$˜D±´1¡ê”²"úLL¡=QÂÂ(¬*\,ÜÂ’U]©$æÒ8@È?[B A¯(Ã(\ÉI_]©q"GÊ×R¿”?|Â-,!pœC\]ù? ÃpX’uþbnCG GΖ¡îK0‡!qdöf%\ I*ÅS )`)âùK¥#yàÁtäSb`S¸´ÆãCáC3@p‘€ÿsv졚Æ3@Ì0Д\Éhá‰â'¡ òMŠp~\:LÒ}'øH@cJ$%ã¢y´!x… r¼i)`É´\ËV1žÂ ðŽÊwƒÑ…Ä ä°xˆ׃Ê[³0¤ìÃ^:Çb±¢ºtq;mwB<£E75ý†h¬-ƒ}»8çz²ÓÍ‚U¢±ìÌ,14› (°<-´·“7ÐׄD„>¢>L3 ÝÓCÌ¡%pÁÏwy¬ë N]őРa¤1ÀÍ€)ñ¬ i°QÑÍ܈:«Q–J"Ù"D‚IÔ§"ðT1'UÀf¦©¡±ÿ1ÒšÇmn|fÁò´ÐÌ”½ÁfÏþ6MD6-òÍë7\—C22\臸82`ÚUÒ¡;ДÃ=ú³/LÒ>}LGAù²ymÇdóÉf8¼\„¸˜ä“8…†\@PÔ|¢‰YZÍÓüÔÕÂ4DŸ«D¦©=1½ä:3î55ÛvÕ7>%)0šÇ°kÎ?ˆÓ҈ץ׽T\™cn‡ª0ú%5ê7y`[qsZ=-URèbX€.“¶«üz#MÀ¯ikv @žl:ḩS÷E%Ã:d2C4«mS’pÔo}[@Ï:;¬‡6«šÉŠŒ”ÝQ–KgY±)3.Ô¼4Xbn§­©3¨:Vÿëpêr!T×F„Õ±D3ƒúÑ3ÖÝqÅå‹0]e\cÎ!Q†‚Ç´sr,-jÏ=UÑÝ[êº[Wû=@w’ !ÐHMlK‚up Û õß1¹ R6µý‰[ݾ¾²õ‡qTG6¦"Eå£Hj¥˜GˆIŠÎ¾m ³µÇ¦­gZÇ6ss0ÿ$‡É¿[Õ`î,Ùs*0¡3qºaä”ÛâpQ!Ñö“87šXûÑEC…\3$äru Pà æ ™Î#˜Îß:qŒò¹]ÅoÇf kSâÈáùÁ\¹&C“5PšGI Fý#G‚®cZÿ3Fñ&˜“F|×by„:šÀ*Ð8Îßlž@›¥õcë¿êUbÒ¯lt4é]‚!DôwB«ÕR‡§9,J€f @Ä¥™1´ÄþSb‹ª§uZÜ[£q"ÐëâÑÝ1ãÄ Ôß°õâ![¥ƒ*äæŒZ9¹82žu]2V§¾>aÕ«_ÿ5äü©Øz:J¾ÈØ×t]ÓIã«[‡¹ˆ:ÜíQ³Ýöz͈ìö¥ì±¥.¥1Ë3|@*&üŠº°ÔGÌ,YT:ç!LãzËŠCþ$ÐêRñšØ,Ê:¨Œ7ÞÊ6Ýñ“H OŽöÞcø.0¥·¼QBY¢;éu B±ÿ7΃GCÕ§$ÄwV3[@k5ýs;=¯m6»Ó™>Ä‘½±@a8NÃd P Y$¶\Tò»·Â5V»Ö6†ª¹HdeSÌn¶[ÒÜ‚ËiN>iRc3¶31Ïš &No»1•3À‹1Ÿó¹8€wd¬ ðË“7C:ÈÌä ÑâÉ'pòEaS¾¤1,*ÔüøÔ%ŒO`›£g!¡q²ËòÆ~ø%OdŸ/¼žÂˆ‘œ3û :ûy*¼ßû¾ÿû¦Â«.&ðàAáu?DæqéÇéi?±Â(¸aíöaæ:œãóÿÇîpHôÑ/¯_ýÞ²Æ bñ3ó÷“÷1!32=eµT9¥Ó2n´ßþ1=2t`Áb dØÐáCˆ 2!ÑâEŒ5näØ1ãEŽ$ %U®dÙÅ‚‚X€X@„Ìš,^¾A††2°X°Ä„ D'Í`bˆ †2<@‚„"œ‚ ‰bkW0‹†­8©R¦,„¶¼H‘í[¸q9‚”[—䉔võ!éK&T ð©–`ÖÁ,Â’`˜U±b PP¡6T,èsÁg, T»a´Â ,t˜PÄPÆ$"O®¼v-ÿ_·|uïöH—÷oàÁuçdÍb `vÈ€•EÔ d2„‚ô«¡EÖÜpCë‚‘§ï0~k¬ ¬7ª»óí,,$ÅÍYø}à¾ñïçßcÎùÂRÈÅ X(cA˜¨#*3dºM¦a<ÑHËpº'+¨ÃÏ+hžb!BËbÒ ¨úüsQ.ýäÊ@… Ô‹Å–p4ˆ@0»è¥Ï>£#Æ@°O¸œjš,å¦:€Gä.ƒiœ³ º pb ° SϸŠò€Ö®ì’ 3 H¦ /+K-u‚ íZ|ñΖb„+ƒÌ¦²Ë±–1)Ÿ4”ˆA«¬ªÿŒ#§ï>›Ž0TX”1†HjÓ/-0†65Á„ù@U,QMÁÆÀV-ˆEÂp´ê±TÁÜ-7±5 DPDãJlZ,L…§/ƒÖ\^³R;¸wÀ9d7gÕ[. X”N¢©öµˆ¦ Íu‰ÜÇÈ»ÅH9çIêh‘ØîvBËJ$ 3eI!Ÿ£ öª‚?ùÀ)&ê÷lÕ¥3M° m‚@k¦Ãÿ0¢È`?¡»¤¢&á5Èb Rf|‚­*Ç£’O*b0»¤æCŸ©Ô¤£ˆDA% ÓE€h§p¦lÿ©L=â+•p€+`Iu›YaJ©jÚ«:ó)S%F']| XÕÃXy±Sc4+3CVM[3LTõz8«p©‘[ü^\ö…%Òàé‹_½¸f€`=¤ùÜE–Ëðè2‘2AyAúKxBÈL¡ R4€€ ZsIjI‰Nh&°ª¬DŠSÌUK²úÑò"ýêãJ À*ÑçŠícL¤ä¨1Jb…A–:÷²×ÉäJŠ¡Þ2Q”èÿéät4a¦  ¹G™(Ò2Ü|ISTØÓUë4ßQQ¤K*-¯Á<-2>¸Œj/ÚËЂҦIíI()‚€QŽ’º‡œÆe㩉Lõ«0Gq—eº¹íЯ& ¬;’(íÈ®#³´§lYR”Âe:’œ„ %“F± „ “T€½†@ DZ̾~"VE‰IöáΈ.Ôñ”z uôdb°ËÔô/ö à;Sꢓ^U«%ñ}êOÇ) —€&ƒ© ¨ABŒAF“= `]%Z”fHó4íf:k¡˜X*M©¨ ÒÎ1I’n58YUlc7"gzëÿ%Ò”üJ• úÜ„²/c!š'<Æð/4¥¢ ,'‹ÂàQ4/ ’U´)À8‡Aë)“z²/!GxÀIb»ÆþV¸¡ê[ŽÞž(#* O63r.–øv¸z ît­{¶ë6äIÇéȣܙÝÅʼãeH]Á‹Ç˜÷»ä®xÙû^øGºñ-Iué{_ü"Öªùe‰}ùû_Gd¾& |àŒ Áñï‚ü^?¸! –p…­a SØÂv,†+¬a‡øª–0ˆE|bx’øÁ&Fq‹o§b³ØÅ3ÎŒ,cç8`6F0Žuüc½í—Æ>r‘÷ÃãÙÈKÿ®g¬d&G9h@†²”­,$¸ÊWærK²Là-wYÌú]r˜g§‚:îqÌÓýr€ÍÜ· @ÎræÜF@àÝ5­Í~3ßâÌ2E‰DLyæÛžÿÛg¶<逿 å³è¦*7Y4 °h‚ŇÝzÖ¥å'šÏˆ)Zrî%¡ñdhþ"º%«#ÊDÐdM~ÖIlbM5æÐ¨BÜõ¢mÈV(K©PüÌɈ鸦¾ªó«j–дÕb ËZ)dkÙ@Lk¢©t˜@7 X Í¢…"?ªÕÚxÌš³ñ í•H;~ÔN÷ Õ-‚X+¦K0]M¥i‡¨çÓbJTÿ‰$mG³{ÇNv1¼U"o™ Ö°™Ö–[×dü^á¹*çÈ¥"°žNÇW¤˜ eÑÈRx³Þb‡—¤ Æ S€MÝ>ç3QUn›û™Ìà½ÜyžÞµwcDÊ‘¨ÖôøáìÏüëâø—#‹êÊ"ô^LSj4¼êŒÇºZ*0fôâ O„.ꌌA Boõ*“Æ2²‘Š*¯P)¿ Lñ4Ó$å[>ïã0ÖŒ¨«Ï² §`÷©À´*œ³2œ'©+äPŽÒ Œ퉒¢¸ ¨«'™Ÿ²A²Rˆæ8¡¡˜DÉíŠ 4‘ä¸ê G*®?ë’1Ç@ƒè ±“™°ïpB—y¥ìÈ‘« ;ƒ‰b¾jÓ‘(Õ¨‰%Z ŒœB/l ÿmó5‚¢ø¿Ö!”¥ œt$ =³ãˆ’K XÝz*cD÷ DQ« ¥"Ô.õ ¬F ‘G” jD†`Ï‚ aˆù˜‘¶ãD¯yB,ÖÉ™™¢Â<ÔÃÜ0ó‡yŠšSCb'òPŠÿy¥Ñ®E¡¢ iÂÛ8µñ›¤¸Ž 0,ü)ƸæÒ¦æÁ@>ZìÅ(¤!tZ+áËÃ=®WTˆ*™G«Ó± ©¸)ƒX r¼4Åp5µ sAº£€’ª‰ ˜žỷAs¦‚:Šìé€ÌŸp|‹èоrÔ&}A(! ¸q›UdEÜ{¸ÿ×)œáH†x ‚h<ެŒyIâÎP´cy™IДܽfŠÝÛ‘@ò Ý[‘{¿ ÁâÛ !é Q…¨¦[Åo.%Œ̱‰¬H¼È’¸³Rs1£J‹42ÙÓJ[ÊßêJ¯´0°t,±K +ËÆ:K´t0µT,¶lK{Ë­ŠK¹40ºÔ*»¼ËËË«ÚK¾ü/¿L)À ÌüL”*Lü/Ä,)Å\ÌøjL{zLÈ„°V̰>¬Ì<“Lx¢LÍ/ÎÔ%ÏüÌì MZMÒ¼°Ëü°ÌLM.3Í)BM×¼=®lÍÙ”2Ø Ù¼ÍÆÊÍÛÙMÞÜ*ÿߤà Î[ͳMã,²áœâ\Î’jξyNèL1ä\1土`œÉ¶‡ˆ–‰Ñéð5ït‰n$MéäꔉC¶ç 3ˆ4໫©ÕL¸ÛLϼ±:,Q“¨Ðü!›I:VúŒ©€"¥)‰Ÿ¡€Ÿ¡Ø82y˜™0Pá‘’¡8¿@¬Rr+h*%MÊÏÔOÜÉN¸($Ñ;ššŒë št£)nY¥ÍÀ7¿7‰“ŽY!>€èx’ a´õ•Á4¿#¾±Y-^«5oS 8SѬX¹à$Ñ¡±:ª¸n[©ŒK¹CŽŠX!‘™q“W£©z£}Ä ¢ÿÏŠµúœ ( ¹ W[¢€#ÑëŒ1}‹+Í·,íŒ-U7ï9p»4©’¸j»¶t[ŸA[ŸF½6jÃP¿Y-s9;¥üœM*% >e‹?•”æVÂ ÊØ8&Ñ©%):é‰X³€±aRW›¬µ!> ™Õ/‘6Eý³‚[9«ˆKs—ÉT<]6ÍìT±:X"iÏÈ JËsZ4íñ4¦©Š6Q·,Q6ÑX;ÝÖh’4Y#Ïöi—¨´ð Ëa5ÞDÖxªÎ©ÛÓûTxE1wÕ•õ¬×“×£WÚAÐWÿ¸×Zò×ÙY½ Xłœ|Õ ³„]XáhØÿ;y،м9›XŠå ‹Õ`‘Y’-Y“=Y”MY•]Y–=Ùx<íØ[áד ¨œÍYÝYžíYŸýY  ڞŀÇãX™Ý‹Å*ƒ¢•X…=Ú)û1ŒÅàѧ…Ú¨Õ±©µˆ0Z¬ýšÕ²¥ýZKZ“[²0³í•›´‹í‰ßãðT â+¾¸½ˆäóư3´ —Ñ2V–¾– ÜðÀwT‰ì3>—ØÇ¾]³µåñã©pY?åÒ#'2@Si?üË-*¯7¢?P±?÷ƒýK·þ#@œ?|§óÓ\K!Œ—Ñ)ÙËÈÝœÀåøéAsÒÀÿ†à@µ’FlAêHŽ}$ºì’·‰Œ AªX ͈AäíË` B:æMóº@<¡ÌÂWR"ÄC©¼]üPŠ`Bú˜()L*|ªHq ¹¥H™.ÔŽ/dŒ0 ùyPåH ù`™×Êš Ü€647Ä4 :$ ; ,ó­Hô½p”@Ä"ÍEïÉ­†@DÝ‚©¸ KŒ‰ID· E‘š©¡ \ŠÖA‘ñèDº¶œÄQtˆR\ÉAŦ&Û}\>û[XÄÅY'Ó©Œ[”Å8<ÖcŒ‰_ÔŒ„Ƥ(Fˆœ°dÔÉMŒ‰ZS•F,–k§c„_ÿml”ñÊ Ž –‰qdœ2ÇIKÇeGÆqGŠÇÉ ¬G͸Ǭ }ôã~””å°£ÀA¢ H4ÈŸˆŠBV ¼mÈ|¢c<°¨ ~ÒÊ7¯hËH’ìÈ!É*ÉìH¦¹I–4—üÉçˆIPRIµÐH›\Ié¥e\ßž|Z.¾ÛðÈ b«1Jµ@J´ åüøÛ_J- ‹J7&âCû[«4²¬lfkNµ¿MÛÃìægûfpfLq~7r.çÈi”Ni ;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveFileDialog1.gif0000644000000000000000000003231310520670125021505 0ustar GIF89aÕÐ÷ $$$(((,,,000888<<<@@@DDDHHHLLLPPPUUUYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,ÕÐÿWH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´å‰P£JJµªÕ«X³jÝʵ«UMÊ{QÅ„ Òª]˶­Û·pãÊK·®Ý·2ÝË·¯Aü²DAÀ„àÈ•6‘8å#Kö¹ Ää’/kÞ,³2ç™?‹]Ò3iŽ¡O«^Ñ4ë‹©_Ëž½Ð5m‰±oë¾m{·Ãܾƒ«î-\!ðâÈ7Onð8ó牗Cèür½ÓgKŸ^]òس¿ÿÞ½;Ñ tQÀr‰ö#P0bÅòœx @xñÃY Aæ 5A'l€ ¸‚¬0¶÷x`A ®FÞs•Þuê)x‚'>Á'à'ßý×áh2"Pó #‡°x¢:Öçâ 0‚7c€GJSðA“'H@`Òw_•/f¢€I~Vcr75¡‚–pß%H¡}ا@œ]zÉe‡aÖ©çM_"—瞀vvç€jhK}WhP'v¨n‰ ·(P* 0£Êip“E\šéxƒØéO€ ª¨£ž¶én ÿ`À]´Öjk]¨ªê›­Šöªn(4`WÄk,Wè*¦½rö«n§ú”ìªÌ6ël©âEÛÓËZë*¶Ùi»“ ¬zKÚ³·‰kK[žzQ9Qà:´~á :A”íKQ2FTÂ< `}mPæB°Ûn½å-ÙÐ'¤@çD ´IÑŠ% á pC#;dÁÅ–@!Ap¸Ð8Ü»³ÝØ^P­°–+Ô,Ð)œpÝ  Ð$ÞZþG¦@j†ðÀÅ+4FoP‚Ð¥ÀôÒ+¤ à 5ïŒòƒõýåÊ/¼sDß@„ÿ`š!Œ°À>ÆP½Â¼ÚœÎ²Ýøò#|@Ëp¯Ðb‹°§ñâÎÉxœ2®×œg¾,Ëá¥05ƒ€ü#{#¸üA  õƒŒ¾·„X0àò¹‚å•'»ÂIO0{胻ø»ãC ¢Ä @%…%ÍÞ h\4èwÝp}#X e^²@„<Ð ÂNÒNÄ¡¾uà|æ[ššcúÙïA> L}Ʀ:ì¥ï뛀±:ƒàŽMjS{‚Ö°Æg웟êÀwȽ&D×Ñ…&d¿^Á“Æ·À1(ÕÿB9údXù܉J°·¼I?'{‘ñ²Âè'>* " ö ©h Á“jº6¹,†>óß >·Àððe¨¡fÄ qˆ,Dˆ YCž‘ó»O”ðç³êgj)H“ö€š%’_À³¢Öôò5){ò ’4D¾qE)$"—,°ž—õoŠ ÛÀ›ù?Õ!Bæ£"'g5Gf2Šyl¡ølD¾„Äð:'ê_î^²1fàJ}3žðVÔÉú´H“€^2ߣÁ«±ï®kÓÞxÆ Œ‘AâÒÞ–é öeÒr̬]`2Ì¿eàwÉ#z:F¥ SGí©¤ñÐHÿ¡ šoÌ¥w ¦^"dwFÄ`Åd¿Å™qTˆŽÑˆŽƒÌç'6½Uô}K‡:V‚(Ø™(ÂRð9&VT›Q¨H5Ñô]”‡-í€8gQ™Qô¢• Ìîj=®&DûÁÜHP·@Œœèvâš™26ç™N#L A ŠGÔU5:;IŒF¯ÈÍ XØH F6§íx]Õe’ÔWv}õ4t­«¹îJš¼êÕZ|_ÿÚ«ÀŠf°„•a?ƒØÄ>j±œi¬c ÙÍHv²€ª¬f.‹Y=iö2œíl—>;™ÐŠöH¤•ŒiOÛ¡ÔFfµ¬kÛØÿfg¶‰©­m¡ƒ[Äèv·Ìéía~ \äW0Ä-®pŽë—ä*×7Ìí‹sŸ )‚úÉ Ôµ«u…Ýìîu»’ê®w ^N‰w¼…-¯o¦û¯’ $[{Ô®sŸFľèµHtùÂÞym!ßièBПôhQ"_ÌokÔ»›þ&$‡ ŒÁ´ÑïsA@„Ö1‰RÍeÿ]œÌ:ìÐ+4h¯‚%²ß½8!%@ R$F šS>Fšp,$ NyˆÓ?å$¾©b3p„ò“«õǽ+¾ƒ¡u^˜ø'CIó3ËÌ'Æ”Ô0‹ät"ÆM)Æñ)pccÉÉÿg2–OÑŠå(3¤Ådy1B&D0õÈxËo¤†§á!ÙøŸ=òO'C|"iÍè¹×ËèlçŠày,z>Hús¦ô˜óÓUúNÛ4 = %­IøKÏ’C,§IH“~§‘*=‘K‹%Óñ4—h*†ÑöçÕŒãÐuùA;ÆU7ý² h=-Šõ£ßFk)ϵÊ0Ù@œŒ%®ktºŽÖFzµ¦ÕgØ™/}eVVì hÚæŸe 6e;Û:,¸®vcîÝ”|ë1üfŠ¿ÿ-˜€/eà9P@ðš\)ç°ð† êÚ~¹¨(Îp‹»äáI‘À°ŽEò’“ܺÿâ¸ÇYr¤(`V·Š¹Ìcž+e= ã+GIËñ8[U;oЋÒsTTCz½ß…í¤ eé9ÏHÒ‡Rt§B=êR¿ú ›¾˜%}K7z+„‰E®ˆŠ;uq=!hZ=b²[¤îAã¦5Öȹsò!óQvãLÖ&®N¶íA9Õ~LÂj‹ü—ŸZ<C¾×õÆC$ §E¼˜Þ~d’ÒŽ ŨÈ6Qu +˜ësL¢‡WX¤êËžY0Ô¬~c²Oò®—±‘C|@£ô7Åë>5£Ò;@½ÁÏžBÅî]ôú̉Vó?éÔ3Cè7*2®> Û*ÿJÒ}¸ÅÐEqª÷#A }€zi£7¥¨þP¢‰>’ÿíàÆü´µçt:B4Lúq ʶNÔq;«TógÑ)a4Eýmç§4èÑVˆ nDØÃEf¢eó‡nD_¡# "‚e{ÒH¬D§ô -¢1‡$IÏs@ýg{ig‚¢AÇ*h*hv‰%=Ñ)1´7sR1IS?•$i'/9”Æ”Œ%”F©98¹”1Ñ”2ñ”PùRTY•ˆ‚”‘¥”Z¹o\iY^ù•–›5–dYpf Zh™–}q•0‘•nypùr9—¥±–¥Õ–/±vßôE_sY—.q— w6 f~xvu„ÙÇDJÔŠVb‡Ø&„0Ö1'&Qñ#aõ1áR¶F¡ÉRƒrm•s‘Éþ†rÖ{Jvc‹y ¢=ó¡k‹&®–Ž˜ïA;¢ˆÄ×<»)B¾™eýa„ ÷š+‘oÁ”B?g;sl¤Iš‚ƒbZ³hsö5ø“H½ÿ3k‹i`zñODRwP&ª·fÜÉeÎùœz©Z|™¦7ƒF$$âkD‚>èA`݉%úɳf÷ÙŸq Æél¦—ez`ð©Ð©ùc55ª9H–˜.Bš.²i ‰ý‰–Ÿ¤Yš;›Ö@ƒô ¡9¡ŽQŸ!"zC¦HV!}æM/ÚI±FM:Ö9&xà„lBƒMRB.*D;fw'£(1pPs1óÅ!ßoð5de4%@8ñÆ>–ñ3–_ì˜Øñ—d%4ee¦ì_X'¥'a˜x)rjtZ§ q§˜A£zº|JyŠ ‡sú0E¹Wq‡ÿêZU~Z*רµ1Ÿ‘!r&·©œº(§*•j©ru$/7s¦zªtQsºrs¢:ª32¨¥+ú]‰JG³º.¹ °zOתw†©´©3ñÀjm7I¬Çª‘š[ʺ¬Y«± 3PZd@s­᜶˜ѦlÔ6yÇÓ¬²e®Ãu’Ý3"Á‚á®ñQ3,I ÁA!Uq&¬¸v޹FÿXW»ú‹bJJãHkÓ6ú3•$Uyƒ7èù?×Ñ&!À/=5 Ó4»£ jÔTìS3?#vP7)ð7–á6f¢U!{nè†+wô^»²fb8éC²íÿw„èŠ\"F¡Ø;ÔOÁ3áþàü¡+>È^àþá â"á , ë ­N þ'žâ~¼â|Óâ0Žâý]ßgã¡ ãÜÌãIÊ( ã;þ×åͬJnQH1Ü0±™A‚­EãÔñvq·}!wÁå-x5©xwÎߪ|UNäHq#‹W¼}yQfUÛ L¯aD@¢WV®$¿aŸ—z¢ç¸¥g»Dz«wM®ÿ·{_.{1µ‚Èw…¹W}ÔñõñAˆPãx:BÃø±JÃg>}+Ø#ïQs ENDçclVg6³çH…ˆ_ZLß'?âç´Üè}ç7Cq'5qƒ€î®Ã>lX™D’'?D‚Òô;Já´ô!ìòWì´™Ž~¤´€Ò^;¦äêëMW<ÔdÕ~P³¾ mÒÏK~$(€ú‹‚2„îÊjƒ»Šˆ¨†‚iG¸Ã/ôULÁ»õNEmXC¬è´¡„”3ƒúB³;õ§©æ<×tKÈ=V…q"…!dEM“HW8‰ÿT3÷¸":Ò9bÊ&«(Dd¸‡4hÔŸÿ£Aud?CõFæƒ0³IV" p(†/Ï~[æ‰:’|>IÁ8èA9VñC„È!†x¢‰¸ˆ0øŽ¾xŒD”ŒËøÓorLÚS‹ÒX0záŽ? ÃÍÈ?©N Ò&þò[Õ"mô&j‚ÎÞ(ަ¿F!“úW®­/‚jbMöánŸCà>¤ížŠ¨j¶ NÛµc`ÙÙ¤»½h'zquÌöÿhç‚aÀ7áw:NNT›vL%†"Uý„¦5]f1á‰d3!îá’‘°7‘ç8V `ÄÀ2¨@Á ‡+ ŽˆñaB‰|àÁƒŽ$YÒäI”)O.¡ÒåK˜1eΤY“ä6uîäÙÓçO A…®(0aE %tXq¢À†¥N‰ð¢À®°°uDŠ¡¼u9–ñcÈ#qF¦\Ùò哞5ØWlØ0ºtŠÏ+B‡ˆXB¡ë¡G†ÎÐóÿ@Ç·u¼Û÷oà•ZèPÀB𗹑/Ù›ùsèÑkÎU`TzIå×£;×ÞÝû÷îÙu·ŽRàˆ]. ˜¨@Œ&Û+xP"ïÖ’Q×rßßÿÆ.Àìlë $üLª 5°ÖÀ…ªí½“SÈ=ÙLÒO-þôðC}I¼šœêª´¨ûà0JP „ ¬³@¤ è³/ƒHz 4ŒJx@Ñ xH5Hiê$Üê‡D’È}ê0D,³Ô%º,‘@iZ脊&( 3Jh¢ à,¡…ÐdˆG‡>ø&ø##G*j£…>Hs£äŽ(:Pÿ Çž®ÜòÑ9À`RJ+µôRL3ÕtSN;­T€.½Ä@w )/Z2n Î𚈨 Š#SB( 4ê¼ó=¿:a.Dýœ ª6Hl„*ꪠ–^m4-H£ýP… <µöZl³ÅÔP@à€Rmò«=¹(ÉÕ©ÉB…pU!<7x0Â`›‚“¡®,Y†*ZèUgyrTZ‚ Ž.€Pð`…0e2sˆÍ´è„6…LïU¿R]¤ <Çw)LH©Ò&8ÎÈZéú¸ß‡@ôV2×}`„ŽBÖi`ƒsÖY7ºTøÄpk*j¶§(ì¸6ÓK¯¡#É<ú¾ù¨+”‰šÿ¯¥—‹º5*3´¯8ãÚË6û² ~&©á3(­Pûž={nº#a¥ Ï^”®#å®ûoÀßb{gˆmÞ çÀW\¬¼¿™lÇ#—|¦Á'orË/¡„‡‰Åhã줘r)„Ñ«<ó”gÝìDJJ'Šx²`Ín…(õ>=¥Ž{lõ×Mr½xàL½Fˆ»Á£²Y!éG²o„Ô±Oz¢FÊÀôì+á„Í “hô棇2â‘— s÷ÍÁ(2WP4“iè5"ïò±%@H'ÁLÆŠdà#¥2`êî²> G4`WìG¥#%È-í‹ßñâ'ÿ­´d~£!ˆ`šò!„$,Áb <ëôK=nÊOQ8C½Û5„+1¬Ÿj¶¢Á¶pÐ}Üó~R‚ÂAÌ}[ÑW>ÀîáÎ~OìÛúhöžPFç2`R¥¾ð„Þ¯T8<Ï}°$D¼ ß~²¨n&ÔÛÙVhe¬1EÉaÀ‚¦‘èoiõÛ šj7E’$ˆ!?Ü|‚¦ïµ¨4‡T]Õø>í¬êSbM "1ÒXÅZZWZr˜@é3‚Ïh6£#"±ÂHjn‚_%=[|!/‰ã”ü‹+¦«ä%/wüE Õˆžƒl„jg‚H‚ÐsÊ[ÿVDéšH:Ÿœ1„—P Á@º`v s)(M8ãš ”Àœ.4ç P£¨hޤ·3ibÓ{Ò,®±•=«(8K“—AR’ì©6I"øz´‘¡QoQí }˜Ô/£ËH'ˆË²âÐ)/’gÁ#k€ò£Ñ„4¡e"òz©1mC¯JÖ_BXÍÂÙ§MNÉ€S$˜&ŒLä“eÔ’8ô‘¸ùDH”1ÑhL—ÜÔ2|^”ž„ÄYP5T«¦|Ò¤¢ÂQH©%VwVÓâiµ21“f–¢Ü¯{rSQ~Õ/8),‰Y’C^©Vƒu¦nÍ\_'WÊÀ”ÿ+a”ª3»HP$–%“êäû°Æ6SªÏÆJ##û éwÑZæN&¤“ Diµ)y-\‚¸ØB–±ÝQ;wR¥›ïWmM pg+¶8–uºÝ­t4£nÆ~#1çÇj{F¨ô“b „ÊÇV¨ž0Ž&.´nÜ é6êf@»P!Hy΢ÜÌ1:'0c43(¥2‹d"“+ ÕÚÙéW¥©ÎpgÉš*^¬€ÜE^´GÕîvð<Sò½¸í üB¤‚L ¾—ÔßúJ‚æÍ‰)!D±D¶Ù™ã$xE-XBÆý O"FrˆHð(‘˜ÎmdìáC%"9ÅÆçÿ9(M9ÿ ïÌ^lý˜+9Rœ$ƒ¦r†ä#szÊ|𪾖“/t4Э*»zÿ2CÀƒý±b§ šw¯¸%ùð¢WO¸øšÈÒ©?AïQZ&ÖloÙ‹¡ÕÌTBlî­|)¾XÔç_s÷¦}iˆ0E¬ö2 ”Ä¿9jÒ*Ô!ÓA„½•ù9 sÂ;#™<Åá¹²7~Û7õA"Þ©‹ˆù/’hž¸0 ü·å±À2  $õ`@ | z¸ ”1ña´ër¾Ñi=—´†x“¼ °Øi°_©@ès´Q2)G’ Ò8dùŠÈ³[YJÒ°†°3=$z¨h"Që!}ù±l:$ j á[.â“ åiºç[´¸yˆÉ‘˜ƒú˜––z ÿ}¢’ÅÀú “ù¾š,ÐY)É–* ÿ‘ººÐ2:(à -;’êXyª%Ƴ ”³ªX¾î٢РºÀr(=´¾¡ù1‰M !Ei°;j>¡£ç"0+(Ž˜Óq´a õÀ°N£fCèë¡ÜÂøêB˜à%r!ZA3Ró-Q³aD–¢J½¢£†‹¿CD!±k‹¡c ±øëa [A¢8sR:À ©–Ð:Â0—z¡BkD¡YB?ˆ¡3û1 AÄfyˆÖÓ'£¸68;Ô°2)¿þÛ±aë´a¿³+•i» Ý1È*©ï ½Cc,¨ÿ䫱Ñ8ŽNÛEŸ«8öêž+ªŠîº/,2‘dˆÐ Ž#£G‚Do2©ÌƒÄcsI„L+ õ£6ƒ’Ò½ô"$úeÔ!:rFŸ`ˆmlˆTÊ£8)|ŠØ¢”G’Зú‰™iËF;Q!Ey ‚»' =úp“£ˆ{¤:9ˆ­7Š`ñÉ `:ÌJˉÀ¯ûH_| ê©Azˆ\j ÉZ¾¿2Á`¶Á±ÞÙ‘ØJ^28j$ Ò ³°%)_¹¯¨§Ø²ÉöBÌ!°ƒ¨LÛIçû à ]¼@“à•Ž„‰Ð1칊£ê)W6¢X"´ x"ŠÿÝ|¥Ð£%YšÏ&Eá [ Û#_b äL%¥Î´0£RÚ= ›Ë÷€¾Þl «CìGÓá¶ÿÈ3Š ’Äæ° LœÛ\¦SryÚŸÔÙ ¨'xÊϼ茸);ѳ%— ¨Î U3|$)/Û€Šbé ôBÅc‘¢J¯~ˆÎé ñºžpMïÁ°è$™ ј˜ÏÀ©8 5oû»±‹ žC=5&wœQ=ãE>ÛK Rݨѿ9Ò‰l½âØ_’XJ›¨ÕÛú})!¤8Š9;Š=Ô+­›€ªrjŠ%©‘¶…½ÖÃ<ò½O´;|ù„U‰”ú/Àl2ðÑ\¤¸óKVAOúE^ú_àyˆúÙ&‹X éªwY©mê“ é¬Ú¹ÇÑ3¨³»/Z!ÓQU.Àm 5£®Ô# =™F:¤Øt[GHF6‘øJ±ÊL6 óë#ú˜‹/*ÞØXìx1©<¡!ÉböbFUa½ Êʼ`d¥¦ð©K*±™q⻤a]nQ^F ÿAöU1.˜£Í0Žhh” IÓ’ØÒèŸp/æè"õè“ 7H¡Î°PQrFé(Uéï5¦rï­i-¹éßÈiÆžö Ÿþi““é+¥i¢vŸ Þ¡Nj»5ê.Ej§~¥Ö¦žêþ¨êÛ¸j¬þ­Æ ®îêÆU[±»¯¾Œ°.kÂ…ê1•jµvœ³¶Œ´~ëã%kº>U¶NS·¾ë½Íë;Ýk¾þ›¸®Œ¹làlÊ(lÃö ÄŽ Å^ì!õk>lÈ6›Æ†ŒÇ®ì“µkÍÎ9ÉTÊî윹ìÇÈlѦÑÏ6ÔЖÚˆáƒiµ&mÆ0m›à‘÷µ ÿYlÙ~‹ìu¸ÿÑÄ ¤™V•ˆ¸|kò1n³SA{Áè»Þm·È^óº ¡ë^š¤Òˆ\é÷ͨ¥H«¡•ï6Š…  ¶â¨5lén êîÇ›®ý¿ó0ºH+aó ×ø‹ö0º6Ùd[WQ•‹Àå²no¶ îòC û>Œªo“J¦¡Y:€ ±±/³,‚ ;*pÈFðýXm¡Z§™­ŒÈ ˆiž’ªˆhºp×7:©èÝNíEñ  ñŒ¨•HŒ' 76Šyø˜˜¥,$9yQ¶•ašj2iºqÑq ˜öbv!³… ñÊ€¸ÑŒ mívÙsÿæôÆ·©¾À¦ò³ í’@Ú=í´µM+¯  ˜s:¯S‡Ô;¯Œ€Øó>Ò?¯Ô@§ õ&tC?tŸps³pÐK¿tLÇȵBçsH—ÏD—¨ôL/uS¿–Žèµùtô²€óüH˜…auÆáì,io™uZ¯u;H]ßu^Ç9X OöaŸ9žó• xаÞRA-P”àà,Ðò$®ˆZW'‹Š Ž„íŸPÌp§Í¬0®µá*Âù]Õm‹ŠsðGºPÛ8¦0оP©§Î1 è)/Õ… zÚ.;„ž‘¼ø=Š–ÈãôJFÿ’ø§¦8á¯ÅL0O»À%)ÿÕwŠ>£º-š°¹<$ÜÉ/Ž ’g:[ù¢þr=»¾°Î*°a9»3´ßT ùé!·1¤h£yUI"ê<Ü™0½C=ß!CsRBfýx¡è³*¡:‡³ft>  æ{Ãؘ̋0“Ì›0á2oõZ_[2jó“¿…ØG·¡Š-ñé´`BÏ ï+²uÉG«„zõOõè7N*¿{βÜnÍZ&!QˆgJ°C^Ÿ!™|òMˆ©¢-ê—þäg‘Bò¨ËÿÒr}Œ³É×% ¥¶<ÓW©ç ÂoמŸ¢ClÖÕº}ÿR) ³_!ÎH’"»› U!¤Ä£q$Ms“mRaÊâþÙÂýN«C ¡Còdp} è3F‚6䤡^#!é:\`Azv’*9Ï#iNªš·–qöj; : iˆ+X(haE œQ à +P¬xbE†Z˜ c†WŒ(b¤È”*W²léò%̘2gÒ¬ió&N• Næìéó'Р8EHòãŠ#’ŠLQ"å‰'R¤`štéÓ)6f%©µêÕIÁ®ˆšµkÖ¥T­nyöƒØ%Ö’\*Ò¬Èz÷6íZ·iJ»#RlYô0âÄŠÿ¿ÜÉø1äÈC‹N1aCäÌš¦x°ù3èÐ?‹.m:åä %6`>íô‡×²gk&Mû¶âÔ¸wóîíû·LÛÀ‡ËÔMü8òäÊ _žÜ¸óèÒ§;oNý7ôëÚ·s?m½ûíìàÇ“/ô»ùÓâÓ³oï^$ú÷Ÿ×˯oŸzüûéëïïÿw~ÿ%ÆŸ€hZ€E ‚ :¸X‚âÄ „ZxS„ÎD¡†z¨OöÄ¡ˆ%V˜¡‰+‘˜"‹¢Øâ +Â8ã}/¶(#9ºg#‹8êøcy<¦è#Er'¤‰D¹ätH–¨$“Q*礈PJyåpT~h%–]ò¦¥‡\z9ÿæl`v(&™i"¢”hò¦W`ƒÁ”‚]2ѹ—œjšg¦†nâ6œTB †­ôDÑ”A j¢zfÉf”~ÞhB+lP¦TÀGQ- @{‘e¨’Çç…–Ö‘L0A<ÕA­ ,õ€gepB¬ôjA­ú@!±Âb芮Ðl¯²Öê£u„Ô![€@ÑZÀŒЫª_Rʤ«4Åz‚lpÂC!`Á´N„ÔC)eA ¸†PR©òjôP¿àŽ Àô*P‚¢•Ê0B Å;£µÖºB”@o´ž°é ŒÎ ªÃ~¥{«¶;ÿEÏ.•p^,Ìoä­ˆ hIÙ>3Fɦª(ÑŠ>D’ÍŒ– 'GJ'Ü´1§º²º]¾,SÌÙú*­½7‹´ôÈÈKë^JÙ¬¯D[qÑûŠôöÒ@{­± Hª©Ut5Ö¸µ\áÖ1um³¯ôNðAÌÈ"Ú)­è¼ÁòâZ0ÆçúÚq¸î]@aÉrLg®Ï'Ñëñ´ä[r²r×ÚZà´ .aá0ͪéÃaE 'EÑ`æ‘aDQH%<ìü1ÝþàûñÛÏÒüÖÿ?ÿ+äßàþ^sôÏAÿSP_C°€.jŸ‘èš ŠÐ$ÁÓl Q°àõ“Ay°„&4 Ks@é‡=ô!‹DÑ ˆGa´DМ`‡OìÏÿ3Å+v)‹þÙ"¯äÅþ¸©T”ËLq¦3*à ã¾÷F™,Eya Nu„¦¤§ZÌì”@ª¤c!P ‚'œ8OS¹£üò˜#4!Å0TÃL xr„ÀgbÉ%µÒš T%!ˆYJ–§„`#¦ÔTΰ7²œrÿd±@´Ü«²ø,+†)ÁIB‰½XND[™¼‹@„‚€­2é˜D “1êGL8H#;2‚â-,|`Üt†· lÓ3qÈR¢€ØÜeŒ‰HÔ¹…DoùÊ@ Ö©˜/Zpžä,‘d`!Ë—DøIO„à‰NH™À5É9ž=àÙ‹)»)ÍÆH’FbêÝ5½°œÓ3s‰Jìò’”üm • ™QPóH|å $0]A¹èUŸÅôS'ð ¢|ö€GÔ2ñÜfïÍr•ä{õ\Á)ªϘä(yŠF7ÚjÞGL±ƒèDüoÄ#AJ<Å:Dk!QÿA+BxÕ­‘t[rÝÀ)Eò½Àµ‘ÉRgIdjÖÄŽ¥žéÖ]7Í}$›’ëÞ†Ó¼ju«‘Wã ±íÕ3ÑhìZ½ÖS¦Œ–nQVó\&±ÓÈÑÅ #×'ÊRf•åcå+›(ËïÙ2—Eäe÷€9Ìs{Êlf ¡™=j^³…0€.þÎ+;Á& ç=ó¹Ï~þ3 -èAºÐ†>t Ð;Q@4¤#-éISÒ `4¦3­éMsºÓžþ4¨C-êQ“ºÔa;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveLabel1#.gif0000644000000000000000000002046310520670125020573 0ustar GIF89aË&÷  $$$(((000888<<<@@@DDDHHHPPPUUUYYY]]]aaaeeeiiimmmqqquuuyyy}}}………•••™™™¡¡¡¥¥¥®®®²²²¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Ë&ÿ_H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]*S‡ P£JJµªÕ«X³jÝʵkU*˜ŠK6b‡¼ª]˶­[¯p(K·n]VØuÉ¢€‹½€Uq@0Ëa +^Œ“0c”ˆKžÜÒ1å‘‘/kÞ Ò2g™?‹=Ñ3錡O«^mÐ4kŠ©_Ë&íz6ÄØ¶s_®­›!îÞÀóŽð7ñãu‡#'hüòйH—>Wâóåƒ cOØœ2/8ÿÈÀ¡|‰‰ß·U¾½;Ê@H!‚|ú(p`á'¼Añ‘  ÿUñU·ß|/x÷yúà@P áÝá„^è¡z@±‡{'ýÂ/0€ ðÜx2BzÒ…@%€~dðBBt>"Þ;BP‚tˆ÷Ÿ|Úxdy4ù$QN‰€(¦¨]™Ì%öÒ @¾Ð lž·etp0ŒE 4#Œ/dàdžlúà”%Ð#xé‰G^yzz°ã ÿ@¨¡x‚‡¦O*.ÇbIºYç†3ÒÉæˆV·§¥tÎø)uæQŠ(xâmÿÈá*…:yè‘–^ÊS¦ÈmZ†-Ôx¤‡æZ'©¼®!DW¤µª(´€àsºVº$´'„ûf ´‰­¶ p+·¾þz¦¯Â’´c/0tNž *Õʈa}Ò1@Ÿµœ©tFʯ€,8uëZzpž ׊m­íêìqñæ¤jÆÈmL\Ç8} 2q"GòM'¼y2Êï^º²P+üõòi)7sP*ÐÍ7–so;µ>ôn1£Y4P”‹ôÏK3 2¼¥õÖ^9 u¹IW-Ùк5×h§MU_ ÀbÝt™Oÿu¹oÇ=Ù¹ÕÿíSní÷Þs£è7O(ä=8e|ÛvøN,,®Yã³=.ùå Q.[ÇôÑwT¸3­îèyŽyAš¿o!)ÆÁ.Ø'ëJÐw%­…‚€§·V¸zÂ’PÝH'È~Qò­P°@%ôº’®ZV`Ÿ·Ÿ:kÂZš®€ñ)1xȧ<¿ü/à\>º8íŸp¢àëž„ü¥à~}ÇÃù‹ñÑ !œ‡öÁXù§ ØÇRèûÝ #lQ ºô£,ðDÂÖ ~T+Fo Û[ͦèw¤ðü®…–¢ Jàºë „/tÒ p§@àv×+Áÿ½7B2µ<éó€nW½DO è–ºÔ'(Q@…: e)'QÀˆ°êb„Ø÷+0@Qdá|ô éï†ýÓÞðÚ£&…lNàY°#IaŒj¢ùHä…ôËà ¦Tžý´Q·Bô<¤ÈL³ã¡‘ µ®˜0/â`y §R2F¥ÄbŸúC:F!Q? òd WE8ž…s\Qr½ò8Ï@$(¡uç´ ƒ¿¬W %¤¿tqr 4  4D<†+Ho¬â3‚Óédžäùá"1æ$qƃ®„èŸkhµúž ßG2,\¿“’ž^€ÿIUÞò)Tͦ®'%%‘} <Ò›Êç?ƒò0<<g÷ýµR²O3ŠÃÅÏRÚÏ›(Ô§¹èë™ ÓUuHTþ/]¨²'GQjO=•`trÉ$¡Â)ž’Þ zš¶Q/ÒJ!à²C"ÒC ¬]J+б ¾R!HÁ‰EèDÊ\P„¼Z+¬jšÿk郱 .2’ЉàÃÀ¸Î­Á«]ëÃV @jw ”|j'Œ…€L ŠÖ?BTÒl*Óª`„¸ÉÊd›²«ý3Õœôg±ŒÍ¥¦v ÚÒ:¤±£±œi%‡ZѨvµƒkíg^ Û¸ÿÉ–3´­mÕn»™Üê6h¼ÕŒoû²à^f¸Ä™q)ƒÜä¶k¹“i®s/]ÉHwºeªîc®‹]õh—1Üí.v¾»˜ðŠ7d¢ iÏ»Xò*Æ¼ì Ž{ ßøöf¾‚©¯}sƒßÀèw¿³é/`þ à×x/.ðjl—+géåØz¼8×ÅÁÖ1XFp : ÃÄÂtÁ0Dœ÷/Œ àk•|H!=¬—Eĉ“F¾ƒÓ‰ÄŠÅq1Y`Ü}]ˆšûPÀÔ>†}g`ÒÓ×y0X‚y‘³F ;Òq|…Ç yV> h/\ ˜üq›BЂ ¼óBÃRœç#R2ÿ]ÐPœ_HåŠXY,XfH§>– EºŠÄÒ Å•%çáp< ú“I5tã:Û9Â#›0Nö\CêŠKêxZФ~C6Ò2é¬Åh 9úј•4ËL]£hA+PÂ…<£Y1ʬ2! ¯Š¡èQrÑ'xV\vêˆÜ™)y^ˆþ<·@2Õ+­…åO‡B$½ÄçJ‹žœ”Ð UT`5]±rì¥${Ü€)·RÎn»¨;)ìæ ²×n—¼)ñÞ `ÎzÛÒ*SõRP®~û[%÷>J¾7‚¯üà&I¸Q°€XüâϸÆ7ÎñŽ{üã ßø‰Û&¥A|$ÿ/ŠDP‚–»üå0¹ÌgNóšÛüæ2ŸÀ×€ž¼$)'ÊÂ5"rñÜç?:Àu&p¥àèIOIЇ2tŒ˜ çQGøÒ‰Öô¬Ëw뺩º×…2u¡ˆ}ìfJuGHÀi£T©‘ĦÈÛËã숴 ršnÙƒ¢Z¦’ îÙ&F?'ZäV…(cÔݽÅr8¬èû6d:Ïu¸ Þ1’‚CÆ]tž3݆.O {þ}’½<œ(?Ë^¨•Ÿ¬t‚Î1À@Ê#®ãb9ï}HôÉó=Îk<{hyj—÷íçЛ)`$!R?[̇¦ëÒ™†Æ¨ûHÔ‹ÿä§ðl]Âÿ¾÷x@UóLîî}ò¸Z2Óû„lSàÕyâ†Á&VHDoâCŒwNúÄx´Oñ‡-÷¢-ÕQSct$hÔ0}rðvõ!)Þ.!ˆ]ó×#N”åT0R%œ”<ü¢H*H>þ DQÂ/l~Õ0/ØGW%Iñ<Ü48OW¤O!B8,ø*èãIÕ+QHoºU‚<ñ8½Äô&ô#?wô<Û´…ÿã!€äW0’MPä:ø—R ÐÙ´Ð7†h¸OAÈMðÁy¨'´4R@H^xÙE>ÈI ˜b¿e…;…mT{CƒzÿBNÓ@tŽø~‚fRmØsñK¡´H|æуi–JþqwšXâ…üdE·Hžr¢/yGÒV…D}–Tb?¾Øx`×7]××si8Ôr7ÄAK2‰<õ&ÆÊØÎv<¸BÐãKÁ‰ñ¸â&^ÕfáQØ$‘FLøáÁ´ESU(·('옎/älÊh<‚tò7ŒŽSŒ á(OT&Š%Œj—ÏñpËÁâ…ˆ:qvh‡)üX9þø²Á9ṉ™‘9±‘7Ñ‘y i"9’5Q’5q’(9*I,Ù’1ñ’3“2ù4ÿ)6y“•‘›3‘<É9;”ZWFiC E™”'±”/Ñ”N©tH9•¬•.!•V)XÙZ¹•ᓪ”`¹]ydY–†q–+ñ•jÉl©nù–-&–Ü“–e‰A]²„c—)“êØœx‹€7ÑÑ2wbá——2a2z†fÒ‘{Yfˆšñ@^µV#B!óñ~ }ô‘„ 2m2‰ü!0ÜæUi—*ä˜1¡*)0z£záb'~è9¢#{ï³zë—›Ñjkb#â& #D3(äbœ:ÔEÀ&üA.)Õ&«Y•B1#Z#h,¹È&¬”QÝOÿ ð™lr!£‘'W%cs¢iõ)†B'|’œmâ'"x~6Á˜'“ 3$YrwcB.%k7%™# ú~jE¶i,2B&Ó)í1ï(ñÙœzòœ¦†-T˜)Éšåš01rs‘$/X-×·,@Æb¢Ó)òi™”ñ´ÔMÿ’,®R¡B.%ÚIvÒ)ïg0]¥1 ZT"ú¤+-Q€b›ñ~ªR~pÒ0ªC2:þdö1S¡Ïã'ä$_Z#Ï)„H™4¡Ÿ&ÁŸwrAò#âûÿ¡‡"³üA­!±r8÷³@´B[s:'5Û..ð"»´ m`$qbÒž|¢º%üÄ;Jw ›N3â Þ®ʳ !rj»¶lÛ¶7r×±oÙRstÁ%j´$~Òrc‚-¢*äÒ&CêC€úÇd$|$#7U$ƒÛUf;¬ôºð5 w³ú#PP(k|òˆFV+Tªµ»RX“¬“h Æ02A¥ËFó $[¹úúöŠuÉš1ûû&»³«»ú¨¹ÖI’Ò»™³¹®¹Ä›Á{j”ÈyѺ¯ aŽ ¡Œ !Ž¿‹ÏAkŠ Ó²­ÿZ­ÈksáW"±y!n2}«ju%¾:­õb¹a€¤›½œ4B  ‘€QI{tXcŒL1Aàk¼³5¾ «Ï;cá¿GB;b±× £Ó½Ê–G²êV¥Ló›záyw{¥a>臲’.·“yÒC#ÑR¼Éyp"~Ïcyã?ÛØPëi:–Eá¾¥XmçÊAÊX%tF%î8&×kBtÖfÞè9Å4Uïw~NB!TÅ‹$'ABwá,‹dBÚR(lW>Á¸.ðXDâC[&Ìx²‚¶¢Ä'h)ª~àazˆyÓç!ÖW~~ÒQßÿ·GâcKÿJ<¯–”c Œ[ ¼.î)ÓÔM&SVôEA@òóÉïWnu ÒS×)šŒ ¼&E"8{eÚ·çÊ4´.X5:±C!€ ´X+/RÀ^$Ž[z ÃôCYõrDG¥¨ÌÑrEœ×~TqÌOòCgÒœN¥äA'²ÅFJ #!À<”~ˆƒNÒYÆ ÒþásÛL‰½"0«¼Ïç”AébB%ÿM&7¸0“ŒA ¹ÕÉÎÂ~NÂIàA;‡‰zCMÑr{Øz<¸0ÑBYM-0¸OMX®œ‹è30GTQ)†|ÚÔñd{“\̇÷!ßYÒ^¥…C=ÔrE!­„9µÔˆp­HÎã2ÇtEÎcIôó=RÆ: Sâƒö‡Û\e•Ü[—LÓ µH]„IñzL¡l ”Í+}‚H9ýL…òSò¤ÅâƒoÝTXdò=¡ý}6{Ó÷ƒÙhIQtEÊ|Ѽ„β‹ýц4mXâHEw‰ˆ‚Ûü„ÛJ$½å‚¿Üþ‘U¥¸ÜÕÖ¤#¾HI‚MŸ¸xuÙÎÁ(Jÿf4º4œ8ÞÜI1]D&L% ÔwÇê¹ûÝÿ#>F²E}Íy%É/Þdz%¤…ÕÞ»lÍJÆOôËfªšÂ…¸ˆ+ÿ7-Õx‹•Rî÷?K2Å‘§ŒÔ;†úwU€„©áxw*ŽQ´©~t†½nòÃ@¼ØÂuÉUBÏp’ÃEl  w§›¬ç&ÌXz“ç‡!Â4ì& ¡7䜇ÂüäU±Ycn"n—ÇŒ³ã†ÀŠLÅÊqG쌻—ìCÑÓ¾LACW>Yþ3´\¥àz¶Ä”ÌÝ-n>ÝÍ»_; ¹ÉË80~\—Üç?±ç è‚Þ„ÿ~±†~èùç̵èŒ^`éféèÑ锞Ÿ–n]˜žémºéÛÕéžÞ ^¢>êVêåuê¨þorÞêJ‘è‘»­.ëAë¨në룮ë¨Áê°¾¾Ž¼îéÃ~ÅžéÇnÉNéË^ÍéÏÀìR§êïUíÖþ”ØN_Ú¾íT9éàÞ—Ýž_ß>î\Yîþuî41wå¡Á‚‰vÓ>ÑιjÁ !Vc7ïqvHžSL~yOªÃO~›½‰y.Ó¼¢óã ÿ?ãïÇïqveô™þ‚µÓñ·Àf%é¡—ÿ"#º,QGâ(ßAE«+Bt!\oìŸ-ÿ²fR*Ÿò @ä¢?’YB[ü' £¥EŸ+Ïòê>`/ð—/Â'©l;b"¶ò‚RIÎó"t!ñÑMó©¡Eßn-ÿ'LŸ<ºb,,¥!3AMRÚÙ¬Š{$›ÔFÎùµ^ö1öo¯œ ó#d_>¡kf!)°;ôA.1T$éÑõ¶¿þ†÷ qvß8ã™Záàäå±$#µù®îž˜7”wUâl´6úctà''ù¾‘ô$!·Î~ôæú#‘8‚û¯®€ƒ¬‡Îú Aëw8Œîû a6L{ükÁ6%{ûÄKü 5Èý\á5_6ÉëüÅAû#üÖÿßçØ´~4Ý/èßo¹Û3Tƒûâ^5Óë²ß`‘ËvÖ?qwçeüõÊv‹¢/$X`ƒ .dØÐáCˆ%N¤¨PÅŠ5näØQà_àð‚È…ŠTI0‚`räÃM-&®`ð‚C ”A…%JñbQ¤I‹‚ÙóE )N¬¨3ê‹' Ì µ…ÕQS0 QðDØVÓê”JõéÓ°cËdÀm‰ºÏÜê¶ëÀ½%¨êßµY†€ÐâD¥‘%Ožx”òeÌ ™vä€0d 8=qÒgg(@"õêÇ/BÌdàAÿIº2ôäàA „¡GSea´Û¸"hù‚hçº{|ïè’Åw/Wû¢´À›®G—ÕBcJœpšÙýû¢–áÏŸ¼™ãL•-|Ÿv޵ç~öЮžòº)Ànˆë #A=ÓB( °lï)$|ÁƒÝN€î•z[Î' °ò@ÁLZ̰?žœÓi…“jó®À°¤oG+èG …²O£±ƒ $ & ÊÉâ\‚2à(Œ7å^@€(µ*p+¡äAõP\ŒÁ[€i&=°ë)§(¸MK.!°‹1ƒ˜ a6$‘Ôr1ÈfÒ1HB }A>CÿhÈŒ„ ‚ý Ž„“<(1Å•6¼´Iç Ó8“ãN HO4i.ßP”8‚(ðÍ&RXs dý°¢«|µ ²*e©â ¡HþU–>D—uV!F+ 0@HÃOIMO°í„J²T[ µ,‘ÚŠ5EWl&×N-TÁœ3ª7·”í¤jCÓòÆBXN¨54!{§œ@Äö_\[CÁ²b@'IŸµø²f/¾8ZŠ„ø´p+a¿ òà«ýNY§sK˜‹¤ {íl D•p¿•r…ùdŸH…ªÂ8\‰$HЩ„›‚žù4„y ¤9 ª„­pûÿ‰:³N*c­—嘢žXíúÙ‰Ç6%®Ï.ô뉞dMíD=@ nºú±nCÙÆ{o¾û^(m¿ßÓ;p WpÃ){î5–^øí»Ùï|ô -Ÿ÷óÓwŸÇõwoÿ}ú?ÇÞýùëן²øqÏní~éû_ (”þÕ®€d`GH»6P‚y`ì"8A B¤‚®»`=øÿ·¢¯ƒô!»Z47‚„Ì'ljH ]”¥ˆ¨ðƒ“Ù`ëF8a‘Ób/¤A$‡ÆIZEì5CÉÔu7lˆh¬´'.EÅN›º¤RT«q *äŠ àC`qC,r•i˜šßÔ9œ[ ld’’ŒPñ¤´è2"12JL€ QMºÍ¿l’—¼h©7sÒ ríæ_x< É´èD0±¤h˜£¥ }19¬Kíô‚À‘!“OɧL"€dzŒOÇçÇ…ȇ·!—Óv˜ÈÛà±8@©‹u”D.È’B¿tÊKè´Bç4sM9Á‡ˆTÿ VЦ1)˜ž‘–Há£ép©]†…—‚bærJÂ`6¼ü ¹ÔTÌvBÓ^½Ld/çTMwù Ì‘%(qòÍh>sœä´¥øÎ™t*2•¾i% õ<©ÿª ¯Â2˜0£%W xr’-’J:©"½cMyž…[®œ‰LZðÑ^&4¥ ­¥þj?‘KqtQY’‰9q`,-’OZ™^¾ä,á’ÓNeb“™T•Pù'…\Ø¢’üëRNýdNýtUž¥œ¥ûiZ¸VÒµÕ­úƒkèä:WúÕÕswÍŒ Ü‚WÂéµs|ÅÌ €¿–o‚åa1óÿ±Š]lC»çØË`@‡‘,eéÆØÌ ` miM{ZÔ¦Vµ«emk]›Úxn–³.ðìõôgM·»åmo}û[àW¸Ãýmd  °¶]­å0KAê0¹Ë…[s+÷Üú W¹Ô›u)‡ÝȘ`ºÜý¬e¹^ò Ï»‘Cozy·^ÇÐh½j*ªÅÒêãÈöTj¬ÍBù,ÑòÄ©¬Õ–yíˆÙêDi· ~›`¸ä¦;Q­¨µ:Â…7†´#F`'PÖצ,Ð&BG6$ßÀHTï [ª»»¥µZð ö‚4B¼Œ!‚öUß Û!T£C$Å _İh£bpŸ`¨bË 3wÂ*ÎKósb÷AÂ3Þ7*9PÁ¨ØW k>páŠ1¯‰Ÿ}ñ[–pô 7kpaÑD}o^!T`uA1|ó}H½t[.qÉÚ¨7.0[¦ a×øuÿ½Àqv41àwç5äš´<ôÊ[¹&ÞC¨Ýz¯ÀÁ…9ývo¼f|÷ÙÂß/^¾åÄ’w …a?÷8Ž­9z )ø;yw^.Pàp›lîzš†°†Ú©©áœ†7B¾½|ór^þ7„þTãØìö ˆ=„›ÉœÏ>:€ÂC×µ »ýÀžnlw×üJ@ €ø®i8yàk€½#쪶»ŽõŽ"r¦œö±T œÃÊ.$ª½ˆ8ÔÐݧY¬hËKF¸=:ÕCÛ2±÷aHGÒa° N|w²Û\h±{‘°eZSzÿRH={Uï€I`gðFü‚Ø`—'ŠircÛ—nX¾‡%.OWãPž.ä¸0äEËÐ}¸—ºÈ%¯Šl#†þS€‚ÅÇ ¸Úð„º2R1ŽHDàï¢ÃÄTÀp*Š"ŽÆ$V `.l¤ÒF# AtȃÈJÒFË$…úÂ6Q¾hOýê"åd¹â¬®,_ ñÄŸiñEöú@í&J¾iQeLâ —£)5µQP'xX0×5Lêp+"J#Ù±Þ¶Lˆ(Q3£*õ¯jFäš™A—7{N̈sœ%+geΉNu©S2ìl'¹Þ™xʳZô„Œ=ïYÿ¬|6fŸüL•?ЀZj ‰)¨A…PÄ(t¡‡j(a Ñ@I0­(™.ú—ŒjôGõ‹G?:¢êe¤$]Ií‚Ò”.g¥ui©K‡SºÈt¦¿©é\nŠÓÜè´,<íiršéžg ‰?%KP *¢2ȨL…[RDzԨ–ëXP]Êx$‚½®nÓª*™ªXªJ¯˜dŠ)®zø‚#bm Y/â%ƒ`O"ýñêD0€¯¾õ›N5QV]RË´¬–Ë ËWpP@„¤úƒ%ù\èEþÁ,A2$ ä.EEZlÁÔjÿ «7a[ €–ŸÂCÐ@}üÕŸÿä1Uªõôñ'¥‘ýpd ù°‰E¢‹j×8eé] Ÿi%W¦Ì•;}ÍÜ‘@t·‘uïFy¼ÕĨÇ$¼±”ÙÅ/»C¡=‚è)š†VÇ]¾úuº ©îR®Ë±÷â§»åë+g¿ä¥… ?ãýŽÌÛUm¦·® Û ttuÁý½[zñ XÔÚ¤?œ£mâç]±(³èë¦x Þ¶È>Ü-RFܼÔÇ~ ht¸{žôp¸ÃOâ/ÄÄÁ§í0ÅÏQÍh˜8š( –¦7ÍéN«*¨´K.=HcDÒÈ@¨EÝR ÅÔ™VªWÍêVúL‡VŠf]kKßúO¹FÊ TÝ똸:(°.6RŽ ”d+Û(Ìþ‰¤0€[Å…„š¡&ÂT„m„ÜW™ á^–0&ˆôå{‚h´}Â( V= q¡FäÍ'c­Ýô˜4³SΫðvÈǦ¦Ñu÷ÄPÉŒ]g™‚=à>jê·@"1TvÖ³˜È›0€´éÀyrwgOÀJŒŸ5ÝÀÿd‚R€nw§–´D~BÀræ)Nåa9´¶£†kü>8ÇÏ~8þò=¨à¿.T°É†§úOþƒ¢éFäT€y$áݤÎqï]¾Øî¸u<嘄âÝÓ Â9ªS˜ÜºdŽ^ŽuHBîê2Õ Æ¹Z{Ú”ºÞ“ ´`êÇa+? ÎCIw}y ûÆ1ˆEPp–×á—ªv¿Ÿùl„Z_“òãGvà¦1A𽻩!HC+ÝÓY#!È:÷sEGÌCEc#C‚iW€7ÔyùçaqCruæ;¬×e VfSe0DJ[S7„'ýÒ/>3EV4m£1Ô„@ƒ@Ø/ß$ÀÅ[³qáÁ<…ƒb¢#›5&¥ç&k’”‚<†\µV“…áÁWDa0Yæ@a¹X&ÖH¬ Zä*]õ¡…øÆW9¦%U‚^®Cm_Zo CoR–ti fUiZ‰U¥E‡#ÃÓ5þå%œe˜âYæ¡þ&v^á1$^ò’Y¦:HCk’–ßUlƒy…¹#«³$1Ƙóõz¡‰] ¶`¢"96`˜‰†NB×>Žõ üRbF“ ©@\Y1;X#£7”]¬i}YÔ"þ5†,š§÷™»3šNIçñR¶9š½Vš&ÿQU…!º$þ²š8_s#+r+ðR^z30Öù%·¢˜¶DIG2ŸòQŸ+æXá9œKTœñ^wWDÂ1Ø¡ f‡“Hˆ¨Ê ƒƒÈ1^¡,4‡Û±Uš•ŠMÚ©é‘¢á4¢,q'&:âé*Ú¢cñ¢$Á’‘L÷%£ A£#a£ÁŽ•£:Š<*>:+|3¤ù…¢˜t`R:¥TZ¥Vz¥Xš¥Zº¥V𤏲¤LšE ` p¦hš¦jº¦lÚ¦nú¦p§lz¹@kajcj1z+vŠŠyJ{úG $¨ƒº…ÿꇪ@‚º¨Ѩq¨(0©”Z©NºN}º©Ca©q¨ Ú¤ÿ¨ïrt"1/Q/dÓž¨®º"¶$%Ð2±ŠN¢êü÷0ݶ\T1òG'¹z1$¤ 8ð«Õ´«$ÀÄ2.ó0ó33S3q3ÐÁqXÃ3þ!]@ãEC3­G“4kÓ4fuI*‚9U£"É´0B¤§">Ó®id4c®Â6!ó3Öz6@b5CDãŠÞä¬$us7y³7}A ƒ ±vƒ<‡ƒ7ÖF!ŒCEs:’C9¹#~ž4õ5y±:;Är]cCµs«Ó² #±ƒ:·S9ºÿs„“|C ³S;'³s#Õ×N‹'"<âS<œe±ÊÃ<#Ë1Nk[4=o$ë¥=Ùç=¨#@2$]l…/õ+$'Zó5Fw1ìÓzZ >>Óµ.sBb8Éä?$Duí³ 3´ºÚ©ðl ´„w'AºSAf1„{AÔA÷·e!dH?dB¯CDÇT$ÿ²&¼£5ºCEï3\0›Û¶ë4’»Bga´`B´ZmkHŒ$]DË·õä·MôD@beLÒYV„»YÔ6hH1÷EyDIÇQ¶~ÔCÔIS„as7T~ÌK=Êc{n$FÄ;÷Çz¡[»ó{m¤BÛqD÷ÿT´q"NsH’H¯ÇHŽdw̱¾E‚8ƒI³I˜ƒK÷J3¿¤@Ê´I£[öVd¬DC8!8W°¤e½´¿õaKL•»DJ G!ƒ´%¾¦lÆ$fF‘owÁ:!ì§˜Š°«OKM‰¡·4Ñ"Ÿxªƒ¬sQÂ5Á¬ã¤ÁAª¥Ê¨)üOŸÚÃ?¡ÃÁÃBL¤?LPA|ÄÏ(ÃLlD<FüÄ„šÄ µÄTŒQ,SœÅ+°Å®Å^\` ]œÅeÜVb<Æ3‘ÆqÆTìÆ ÇO,Ƕ±ÆlllVìPxœÇù¸ÇÕÇ~ìä8ÈtaÇ AÇLÿŒÈ ¡ÈGÌÈ áÈB ɽ!ȆV€ŒQ–쎲êEAÉ!É÷´"Ï¡x¶˜ÉµÉãœA«CÃÁ8ÜÚ1Ê ×!EÛ3±?‹ìUyÚ¡$Jƨ,Rª,20Ëá'dà Q%°\Yr+M40[’!þ"âXœí‰aõU\ÂÊìÄ8Q ÈEeŠÓe&É~rÄÎE6™¶B܃'Ä3ESe–Ê,‚!#h!¢&‹I^[·"´ã%ô%`ï…[¢7» lÉ–!ïó…%pcü1BÙÕ˜]£…ûœesÍ{¯Z&V#!èá̪c°I™%Fb ÿ†™;&`G2›¤ÜÆÅ|RÇ\«#ÐK2`¾üÑìùcÂÌúcHóÕ8#äYH’aöõ1²2]nÂ"ßù%œµ"EÒ=M„Ó÷²].ÉæŒA 62`ÊcÔnK^"Ï${ ú#w©77­aÑ,þA°û ×[gŸë!ßì°$ÖÃ6)–±å\È@±:rG˜²UG 2wþÁ=÷‘—™uaûÊ$× 6Â<£!iƒ4 '"*‡’ -?M«S#ó1Öµ5ίõ…Ƶ¯¶Ôüá3çIG;fCÞ¼×?’!b#Ô»xÖƒü• M6»}É.ÿ¢o‚Û1e,*v´Ú AÞ!ÙÝ%( Ä€§³¢Óœü‘E4¬E1¢û:` Ó6éÞ$©ß j¼6×Ôþ¥qšY•—ˆÈF$9¦r²§Ø¸1]•^ ‹ÚÏfLà5 pà› "°àJ”º”0Ë­˜Â]¯u¾ÞüK{Cdõ!'Çc$N’bÙ¬|¯ Õçq²â—°&>j*)Žàyª¸2kJäÕ7®eÂS;ÔWù1B â™]Î"_Ø[ÖÉWxR[Nb_|Ù^%›b´aÑðv~ç_¹òäH„ài€è‚®+0Ã9[xÿ[ö|[®|tÔ+¢áú‘^½´ÞcÜ5Eù…0àáuŽç¢>êU±Í°Biy:,!@U’e ½%%0Dž'Å=Eß+E –~ q}åÕÌ1ƒò1ŸÙm´K¾ª§.hƒJ°Â{’@hU%a£%“™%йòdVÂzYÒ>оëöÙ%\^G)vIa¹Ïâ=¾Ç 0iʾ¨UâìU¼˜nõn9S™¯ÔFm78ɈçÍ<ª «]'Ö{7Ç‘6Ö&rê=ªëþ( ïN©€ÛÛMïôÇ=ÍRïÝqñ?óñ ï;Ö-÷áÉ®ÒÌ!'+ÇQÚÿ‘Ì6˜jÝìü.a3“%óK‘½Ãš:„0#¾¡ô3¦òiuBbC!aðÙ5"|#ÊÌ9áQ;é^ÕÇõWÿõguÐÍvQÏàSŠ´´Ãj=p/Âq¿‡Øó´êás‡€h¿õfWâr?Ìn”½ƒ ‰ðŠ!d/“?ƒ7>£ƒJãÛ;7z@r­\û/ Ç5G³…›#°¬Ím@r5,ÓHh³®Rˆ}ü!fØ;säªïJC!ŽEpg³4¤§±~¼áÊÅÊ©'ÿ'l?5~ÀwtÔ/Ýtüþ¢Ô7°Tn}·øGB ÿ…}³…3Hn™“äÿK»“ÑÐëFJ“—ø|·×ýuó›¶µ:.L2÷1gØôÓ2óó°ïó²þr‚qun”Q€ÃŠ#TX¡áƒ>xâÄ#VH8X€a S¬ )‘äÉ$¬PØ0aŠ+><Ä€ábŠ 0”À˜’ƒ†!R<8¨aeK”IO0¡ÔéS¨Q¥N¥ZÕêU¨6`…Ê“ä‚JŒY!DJ %>|ÕHR-Ûš'(®x¢&Ê#å"üZ¢î×”+Wļ{òAÄ0Hé³°†Á$5„, QÃÐÄ0šE[Xˆ="-ÌÕ)X’DW„nÈð$jÂÁ>Ð0bÄÿçÒ'c²Uâaä݃}ë|‚%íÏ#8ìÜACN”¹É¾¡:òÝ Çfäàz jž¶«³ì)•©iôéÕ¯g¿qkûÉÓ%>X€q2ôêƒ׿C .¡“¤h®ì8à„Œ‰@èÔ­­éHª( ‘úë¢ƪ,©û0ÒŒ¢„ è0éÔÛ-„ûÃà â¼²«»Ájú/…ÅPÊ®¼Iº‹'èÈ+ ÈžjZ¨&³dk¸“r4 ©ÈPk‰À˜‚È£éŠ|ÀFÈ”œê¼öÂsÌõ´ ó.í IÉÛ$8ëà ÉÒ?úr3²“4pM¬œËË«ÂÂSÉýð$Ž,¿ÜZÿ®±N¸Ì%COjóÍ‘Ê(PŒþº4ÌÝ‚"ιÕÂHIžD;«%Û’ ‚ âëRY$‰#/c2!VH!¯ §Ë-ÕYYíÉÕæ(á³€ºT W™”`-,¿lŠLj«µÖ)3Û»«¦*»ˆÑß ø :û<·Î8hpGÀ1Pq9@ÅÆÐ 4±zp00HÊÔj“`% j[àƒÿF`và*ÈÆÉúáUñ a¥`,¯½˜L¢.'úFè¶;È+ùƒ% °>×*`÷¡ñð¼P%ú\#‘!P#9cºÆJ¨þ+I³…,|ù¸ÔF€n¸Ð(ZÉeÚ0¸Í0–£ÿ Ìk³Ö:ÌlÙÃî,„9á¬>[!è´ {íJn,-É.+Ù. Ì~—¤j:Ë"ÉFÒ²BX Ä}%Àì¸Jž 2ºmDÜì†"¶t5°C’<Ì©Ýî* µÞ«J޶ª —vkÔS7­ëõJ&Õc—]©½Æ¬€ÂÙ*4÷©<’ s©Fpíêiy7^uÖË´îxæ«mŒÌJ›wKú©lÃêóÓ©×~Ìä·÷þ{ðÃß)¬Ç7?ªîÏW}öÛ_¯|÷ÕO?~úë·}øï~ýû÷ÿÙå€Òãß x@¢G€ Ì]ø@BpL)xA Þo‚¼–9øÿAŠoƒ!äÞ{HxB‚o„),“ YøBÎn…1äŠixC*°x9l!}øÃô̈YqáxĤ‰(±áøB%>±‰O¤" £èÄ)VQ‹¼â³¸E0Jp‡aLÊÉxÆv‰fDcõ§Æ#²ÑsŒ(G:æQ}v"õøÇðñˆ~d!µ'Èòx‡³ Ž V2C‘>T¤ñc• 3¿ÁJ€"ÉÁIò°’¼»$AÜÒSêÊ6xÞÙ2DëÁ’%mYÀ‡>yÁPæp”¹S Ե͠¾‹*€ÛY/@Æ©Àƒƒ‘LÖÙ€&o‰Ë1ÿ¶q—³kV’®µÌÅ#ƒ¹&£‘qzDj‚ImX L„ìîš Ì%·)»T3$»j Ì€ ïd¢Aõ€i†šýræ<)XÏÞ3v`L£B€Sç¢õa AO’.v¥d7îÊ$CãéÐB”†UÝ%€±…Œs0€L&‰öÒ¯ü²[À¸`Ò L¥Ti Yš:FÚ'50ãH.‘Ä.'¡ÛÞü埳¥h¨,* Ú<5h«Gìê ¿Ê<žth¬F,+ ϺV¸Oomž ŠW¶5…tmžpW¼²P¯(ä+ó,PÍ¿6†ƒ=aaÇÏj ÿ±ŠM!cI¸€ÈfV³›ålg=ûYІV´šeeQhÙ:ÖxE,`MËÅl¢Qµ¼;¬d]ûZØÎõ¶ôënq‹AÔ‚p¶³³ëo¡Û3׸ î•»Ük6—ƒ_õׂ<7¦Ïé o0ÝSrRŸú@“2!tÛ#Ý Õ&}Òš¦ÚãÞÔÔ S xÜu=Œ¸Î¼aB/Yº—Àh2 ÙÆ¶‚åˆ×p)ââ&S¼q ÁyòÛz’7µA8#¡![ÞvB9©~ W(ijà c»| .; ðökšþ^¥wнn3™z@% ã$B&°>Å$' ¡PN>p‘KEÈ`ÿöHAlÓ9“ÙÒÈHwrÂñx¨$ÏJˆ«ä¥”Åw$ò|1VbLA–îæNžÔV‚¦³É %lÉ”®$¶Gëv«‹—Âö›„0 –ýd̬`t;¯h÷¦:Aˆqò2À:JÛ!s™­ræJ)`QÈ–*¡¯liK’b>D 97-¢Ï07‘—ѦW×i¥²dVCZMùÝn˜s ‡@Ú+Á©´¥åšGM÷äAkÝ`°$4º”÷`ºÚfR¢(£&G¡q¢õ:yÊ´ñÆž*˜…t©Ç>rÙ±°º=!EÐÆæ ¦!˜lòf1êÉ·Œ)²‡¨dßdÁ™ÿhr'F2¥×V²íNÂ|]tÂ3ºèkÑk)Èàî2‚ôÄM9Ëè cä’Q¢^)ŒõP=Sng;.Ÿž®ÌvlŽ ÃÎeN’è%ç²<É F²ó“<ë”ö•Ôœ‹\sw%êä(×­µ‚iVyÝï…ÜÔ¯bï²aÝEàTÉTìy½*`gàsÕÞF¶'Ðío?cÜ8wº‡ÑîÄ{Þ·¸wöÝïUü?ø'€‡Güÿ?Æ7ž¬)cä%/IʃÑò—ÿáãý·yÎóÐóý}èq8zý•ÞôyÍüU¿z¢þ~¯‡½`[¯EÚ×þ´·¯bîuÿoEÞSÑ÷¿¡ìí7|âƒ2øRômò™»|,6ßùÑ…¾¥?ýO¿~ÈÇ~J«¿Æëw¿Ú§÷ÅÏ@òÇÏüÕú—}£wþÔ¥ß}ë§4ÛJ«|@0ð7ó÷ãþ²?,³÷³ kã¿þ«ºõñÄŠl&±ª–ð–İÄ8û٧Ø/ú¨%°°?¡BÀKó¿;@æ«Z _Rƒè4 ,)ŽZŽmk”uÊsB xZ&cr”FYÁ€ªÍH;„ ùkŸás©˜Á"©’(© ÒŒŽP S[u³Á(q¢Bƒà( <À"<6:JÂø'&´'\Ÿb (ÿÍYC¼8ŒŽ wñÂKÃ04ì#<%ì(å`¥y8Qù©úhj&kû ½A0k©Fü.² ŒP°=$Ÿ>¤?4r“€‡à‰±Š¢A°ú´û@Ñ©µ0Eð*™Q›WÜÁ 7—Ù¿M|Š#dúÛÅúéÅõùE«8(/`4a”ŸOŒŸ€cLFeìÄDjF÷AhDFiŒ?jô!0‹± GqGr,Gs1–2ˆ}r™Ûh ‰™ìÈG‘ÎÈÁù²LŒÈ‹@ ¶š:O6ãÍ·óÍíQ¤Ýè• ¸™ÈÀ’ùðB ±ÏG«‰º˜ q;ß!©¹¼¨’“¸ÂP³K*Púx‘­‹ Zaµ‡€8†)÷T;øÔùd £04„˜‰³QÛ¿݈u¡Ql ”PÑɱ—à.ɨίp”Â,ºpŽn1a" x©ŽÁŒ³| Õ.™9C­êM—´§¬Ä“˜0Іùf:‹noy-]'8Œ < ¡Šñÿˆ+‘L!›aÁ¹k3 Úhˆ¸˜—‚&7µž©³`ÝQ… Ô°Ê*¨+ @™Œx”I=‰°#œI‰9ÍÔ  J°<)¯+  ƒŒO=°·‹™Ôa›³¨ª’Ȉ)ŒJ•ª¸XíhŒÃQÌË Qêμ)Ì6BÏ_mÔ•ºRýÛº3ªÐVºR–d=œÖºCV£’Vk=®jÝV0‚ÖæAIo•peqWæ)×ã9WtÆnm×ÄÃV¯ÒVx->y5+z­Wå{W}<~íWÌûW€í¼{u«|XïX„Í!u5v]Ø–TXˆ¥Vd;Øÿ‰E †å‡½ØjÉØ²XŽM£‚Ý+ ÙÿñØÙÙX“”••]ÙóYÂ*Y˜Õ ™m,š­Ù`¼YÚØ‚€ÄÀ¿œ45§ÌŒK⊼!Á–ŸÕ'Iô¨Åœ”ŠGtÓÐÃó[ZäÉÙ¬XŒŒ‘—ß𠜲ŀوúhŒ‹˜¶Lª“ß¹¤´Ý'M*˜ßxÛÔxJFË@&Œúìv)EÚè[~¢(ÔÚ âÚ§¨%ñ¦Â-á(QÜa‘L\žM-Ã=YC.”*DT6çè'Îh¦ÿ'+' zñÂ¥´6¢5Þ*aˆ’ªÚÕ€eJD± ~ŒM>ÂEåâ(¼Í]A|\; u9 .aB'ôB¢EÞiÂü)¼e¢Ó *<¢E¹^âËÞ­ÙÞÛE§Ã¡)xª¥Ða¥úÄ Å S¹ð)áé'Õ±Þ ! ©KjÞ+$@5Ä(ºP“‹È›êBٕج™ Sóß CŒµ@ŠR žx&ãè@˜© z‘@ca…ªßÖµ'¬ SËŒz鉜@ œÙ ‰@øÓ_­yY ¢Ù®Ú]büibçzb(>$Î%> •¬âìC*æI.6B)ž®/ÖXŒãÿ1N¢2N¯3·¬¦Œ\c’¸âk¡Ç€Ìc=Þc>öÇ̬‚T:¶ckùÆuÓ>a5ýŒŠ9)TT˜7 ¡™S*•‰Œ›!Ô>•äÔ¨Tx)T°pRNCÏEJ`–±G=›a9J…¤K ÅAoNe¶’ùÔG‰œ¦º—É1ÒTESÉ`U²qU·ÒXD£ÕZ•*H¢ÚU]üe}– j†¶92VFð¨XÖr$Or%_òqÄr èc*¯r+¿r,ÏG XI(ïr/ÿr0s1s2/s3×£€;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActivePanel1.gif0000644000000000000000000002320310520670125020543 0ustar GIF89aË^÷  $$$(((,,,000<<<@@@DDDHHHLLLPPPUUUYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Ë^ÿWH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]:ÓÃ…§P£JJµªÕ«X³jÝʵ* ¦`ÊxâÀƒ®hÓª]Ëí cãÊkÃÜ— FÜÝË×è‚}WJظ°aŸ¬¸±c—‰‹d,¹²å‘/w¤¬¹³gŠ™?cä,º´éƒ¡OO$­ºµèÔ®²ŽM»2ìÚ gãÞmø6™¦Ðq„ñã¿/ûNN0¸Ðp b0 р먯&Î<éòî+œÿ5 àà îÉGÿöà‰~ï.¾%ø?¬¡?‡ÓIŸ{ÿ} ,C$Dø®'»C½—ä±nZËw^«’+¤@æ ÿq€ÁéY_e d:ïa… ‹Á!D¸B¨rbp9ŽÏËiøÁ;ô6^›Â6~‚½€i/P¨÷ËßÿÚ$ûq@ˆ"ˆô8÷Ÿúý¯Ö+Áþäw'äDy¥9*Ô;Ó%Kü™×%0#†Iˆ„>JÖ‚Úõ§?…Op€®!R„À¸ƒ/ƒøjF®2îÿ£ý¡PAûò•å¨ã°®ÀWÀ¬F€ª;I€Mì×>p,"J;$Es2=±BzAËé‚ÜÄ~XžN]±Í SŒ—6q :˜’Õ&<ÎïZÙ•Œw-fì¾²Rx¹ÈøMRD¥³ dFI‚j?u´Ã(1~ædÚ¹"0½”‡v `%+ ËDÙåÖƒay8= A% ˜$×õK ò£B$€à ÆbëvjÉJaš±`¾ü¥•"T‚QZr_Ýü¥6µÓ>0z3Œ¦ô *ãw ý¤`šyZæ¿p…ðÑNCÀ¥•Ðÿ¡èEgDÿ¹â¼RÀKf¡‡UñQïΧíq—ö UŒ*ÌóÙE;ú2ˆâYQ9s_Î4$)K©:úì "Ú¡Nr( L'BˆÔÕ°šŠKXü*ô$mTaj«Z“§d’€Mï¤DýÉ™OÊP‘lŠ¡6A0€½P¥° •N?/ý—VyÄËòH5<%M\:;³NgÆŠ8)Ȫ$&‹ÍÕ®4ßyèZטOb²;^ëÚ®7¤Gè®Ìg±ê®|eìí¸3.T­§€›‹Uôn'ÇÒt¤‘K+¥N*›H{L{À_A»VÍœ¬G¨Z 6ÇZÑÿž‹´ Í­BZ{Çé–i¼µŒo«³àVf¸ÄM™q%ƒÜäŽl¹i®s;]ÇHwº«nc®‹Ý\iW1Üín¤¾{˜ðŠWLä5ŒyÏŸôf½ìíŽ{ßø&g¾}©¯}yƒ_¾èw¿¸éï^þ à§Ùd¸-ðêl²+X­ f™ƒÌ7ß…À>…ç‚á —fÃré°‡eašMxÄCq\D¼À¨tÇCŠw[bÚ°8'jy6‘ ͘Æ»ñ@¬7¥™ ÃªÒó ¦hE1¡Ð““å¢,¾yôzçô¡Ó²]m²²±üNoý55Û‰S⥺ ÿ2ªàì¥+áÇJzôó YÉ—à@޲*,÷\ÉI4âS¬µ¿”b)Aœ•%nèÌhòšQâgêqéŸÈ¬‘§†”RÓíÎPJéž6µ»NiHÇ ¦8@(!©:¬¿:'¦W â±YV½¤áŸj¥!R½ÉMij£ôüË+ËSMR¦ š-¨<;{šuÔ5¦{-–_‡ÈaRÐ;IHì]2k\Â¥¨_ªì=ÒÖñƒ“Y¹œ½ìüg:ï~vv¼4ÛmÓ'‘†t‡­©ØçÆœ?E§ µ»Ìø÷›ðj…‡ˆZ´¸Ä;åmÿ˜Ûaùua¹s5uÖ`ÃÿyÓyþj»6v\šM¹Ä &Øý¬Çå‰9qfÛÙÐ}Üß8OšÅïr}rBßI“‹ƒEäLï‹Ó™u¸ËçQOÉÔ—Ru@ ™YÉÖ•Òõ\;`ûJÆž”T Tp»ÜçN÷ºÛýîxÏ{Ýϵ´«]eG?M°€ÂþðˆO¼âÏøÆ;þñŠG€Ô@½ý$lGJÙ=’ìP~µ—Ç|à——ô£(ëó¡×úè3Xú¢¨€}êK’yÓ·ž((ýìi¿z2Þ~÷±©½Q6üõþ”¥W£$E"í‹|€¶ŠåKžÿ)‹K¤ú1!ä„_t)Œ¶q¦ÿF¼iºi?%)Å:C\Xit_I‡žå¶Åð Kø¥´ó?Ëñ5 bý&ó¢Mö÷/ô÷Fmò¢(ÇOó#1¿>WôKîC“4K óKa2 “(`'$‰²€#’#fr'À¨/ " ‚eÄ}DQ)L5*pñN‚¢mÄâB¥;8*UÂqyr9ÿòÚa-pBÇâXÂL G9¢§%+±t?È„!Z‚}>¸…ÝôOLø'6¸AYf-`×Fø’Zr_¸OÅKȃCq&¦%"Ñ.‚eý¤XÓ‘Y6"gϳA>XGu ÇÁIÁ'™ÿòJaBÕK‘@ ÔMì”>$p,Ýs=ÑÁ# b¨‡eKÖ Aè. ”,3Št¸}ïÇVBG@ôv‘d#fH/L2J¾˜!û‘(ÝD@£„ŠX¶Gð‚†ÛJ•ÔKÕ&<ˆ@fÈ%óÔSûFû2‰R-ô‡¡d%<ËŽââr:“X‡µèZ·hU£lGädV~–cqdHË('ˆn›˜„e&Ñ‘!T¯óÎTC ‰ˆRI!$çèRÉ% ÷bñ!dFIýô‚ïØ[ñ¸ŽVòK9$"ìKù$(€¡T ¨0 7K_8 ó.àÿ“!c/Òg“ÿ¢|Â0ïâB/T‚Âd”ô> ¢¾â @Ù!vÁ“nt“@ùhw'Æ"º³”ؘ>Óv>1F‹šÖÖGzÃsâ§@3¡Z¤d‡BQ) G1‹6-#—AQ)s¥iià'–äB|ÅWz „Y˜Cq˜?‘˜ŠÙt#)\¿÷˜™Ç5™”Ibc™™òe™Ì…™œ©ŒéŽš;1š=Qš¦™¨Éª¹š7Ñš;ñš°Y²©´Y›3q›9‘›ºé1ž] ù›tœÖ5œÄ¹6›™œ­Á›8á›ÌI2ƹ]È|áœ7Ö©z˹¯1àUÞÿ)ØiÚ9ž¼×è)šàY^â‰Ñ—Šbqê‡E’™åY¹ù>)ý†É;ôö˜ùI´©gY)0XS[R0É ì²o«bFó’["(‰²Qᑱ|:´9û2!à%°-÷±GµÂ!2’Ux†0HØG ¢K12kz&$ÒžØõ¡2±Ÿ>£´¢‹’ §óŸmR%>ægï3#‹‚Fïmø©£ïõž'á-f¤œó-+tö¢!>Œ³µhmòN¥ª˜<>*(2T„‚#2’-Z",FécÈ‚ '"}#iJE‡ ³×¦0ñ¦©ægRpÿƒ -5!RR} Ç”³¦• ÷Þ’!@iflJ¥ôe¥ëɆú窘á©ùª8(`ª1ª.QªñzЪ®º°Ú²êÊ2µz« ‘«,±« Ñy×á«¶ ¬b„ª|Á„yЭÒ:­Œ'yQƒ¬ÊZo§wÞú­à®vÇwØ!¬„c®*A¬ A €®çʬ¦ª8Ñí ¯aç®ð)¯6qøª8ýjêš­ñ¯%° öÊaúz°£žqoFñ<Œæ|hØ| (¸£ b úv3!™!‹'©xMåŒQÿq~ÉE°$8yè†=GX4‹*²ÿ§YrÕsQÈ9TD³rdsñH¢“·C—@;YTY3«‡‡´K+G=ÛN²±üEµ¾f¥nÙS'[CSô"0Dh%N5,z>s‰=PdÚÑF’'ÒFZ¥RåçRÌ$¶ö²Sw«²z¨€>¶–ÑXG%ÊT9DˆÞb—cÁ¦Ã²·â°±P‚}ñ£F€Ñ‰¿3CA{9a8%Ú´/³èƒíÂIìd;å±Rz8‹ó)%))!DÖ!•$MzQDbq^:¹;/Š5ƒÎd¸bñŸò¢.;€Ó>Øh“¿DÏSQâôI•¼¥² ÂIÜqâ„DàòhÌkTu„'B‰œØ„‰äP5ÿÅ.UHÇ+oÍ–L–ÄKºËσ¶.xeJ¦e62@0€APÒ£>vQe4ñ»“ñž4‘z!LÉÒSóŒ"2ÀfÕ VÒS£´‰ c0×ムu‚]ùG]ɽ,gßÇ$w‚KE$'Ù[ %ã„ ì’‘+ ègÑWl“æ$$2¸ “gp&+Ž’ªiŠœŒ;dŒÌÈÀéö/ äc`00ÄåQv’ LPí²Ä¾beYjL0´Pz{"iè·SÀDÄÌø'Ò9GD²%{qô’, –VTBáÄ r<ÅÏÓjudno8¼,â&œ þ€C@´#$I|:Eÿf‘Ã"'u==âRb1MV¹õc>RÌ9…=ë(Kg÷YÖedò<3•UBPh¨ÈUˆ¬{>€ñeQ}Â¥$‹mgl®¨nÂl –aµÝöžÆcƒeâ.C‘#Q¹Ã hú¦Ç‘¶#8 ËâRèæ21È 80’±ña±¤ g‡"!p"ÏÜ¥WYmRÍÑ£q»)Ì!·°©‡*r¥suM(§ÒÍòV{˜sõɃ)ÏÛI#Y•-‹;Ð KDæÍF÷à }Úüѯ ÏOGÐ –§­#!Í ÁJ Î9Wp*ø¿ð«ËJIã74¢Oÿ¶MÂJ^Ì At„¬Ñ+Ý ØJR$KçSJ'<0‰¢•>è0(¥¹ÌcÒ”—£T¡h´QÑ?-(€غ\„²A§v$Ê(uüK„r=5Ò${äûb,4"-@ug â0œ¤Õ›áÓ©·mØ‚p­ ?“ARÚ,Llš´ÃdMŠ*ªp C=^¢Cëö¤N:qÀë×—§0Ø¢=ÚU1R³ à™Q’œýÇŽýDïà à¸eʤ;WÄ(kˆfš†<½ÍžÝÕ)5‰a\¯b4ò: Â*MöÄfF!îãW[$ÕÖ,=G’Û‹ò§œ­ÒÀÍM ÿ <"ó© Ýô×iÿ‚nȬ’ M¥©+Dp•šÒ=½ÝLaKÞóÛøM"i ýßq1Ñ[íß.йÂÕ NÔÞà`aà}uL¢•Šû³žPƒÍQÓó,‘ô¢{!Þ{Î Þ¯3ý˜½S¹ ¡UÆ1Dþ¹9‡ ºÒÈa<qâ‘âªQAyb;é£?ü*XDâӵܱp®,'I¦ÉØ Œˆ”‡MÞ!S>ix:Çk×Â=r2¿þcIä!ä¦qï$>ñBâ†Æ"¥-¦/1«e1+×YqÅYAëW¥–iÄW2+1|OWß.´vX'J³2‹rC{ùwr‹Ðu•áAòaì×a4Kû& F2gÒ& 1ïËuJÓç¦yý ‹ŽØá–ðÑ=1"/E(iep6oÒæÄÒçcû1DºÇGÁsw!> &ü¯ÿàCá-[â $*" k<†gÿÑMô²gÖMΔï¡_Ÿ¥ÿòi(>¨Þ›ž¤´*›Œ¿%1ëÛ©°uÔ+mù!äá–ú+ÿ¡æÿÿ6¬ XÐàA„ .dØÐ!BN¤XÑâEŒ5n䨱â‚EŽ$ÙQ`I”"˜ÒåK˜1eÂ9ÓæÍŠ'qî,h–<…%Z”bM£IaêT SÃÏŸA›N¥ZU$R«Y1*€ÚÕëW°aÅŽ%[Ö¬×ZÕ®eKk[¸™ÆÍøªTºyõÞ|»·í\¿}mØða}[¼XáÊÂŽ%On¨˜rÒÆ—WDÔÜÙ³ÛŸ1G]Ú4b˧mfVÝÚµÚÔ¯_²‰!…ÿ„1KÜ]PC‚'|hxBÁñã.ŽXñ!´ìα¡£¤Ýq 1<ï¸Ý å# ppBÁô#RX,¡`E Ó£s—?›´Há+R_¡ùB;<0Pî ÿÈ+!´ìúÓÀà : v㯿õü#®¿ •{0B‚Î3O@ w !´>¨ Á‚.Ì. JÁ¹ëR¨@Ü«2évô¨º$É¿Ð`ðFÐQ*` 0ÈH$ŒV0NIæ‚SàƒÜ;OK1ÄñÅCoÌ‚ x°KãÀt/„0ŽƒôvËr$J)90òƒ,Á[oOëÿ1Ñ ïóhO!W`n„‹\!)™+APƒ&]QÉ"ÝcÓïø«`„ÿVØ®O‚>øOÊ"G µ P@‚™$èÔöúÎäÈÎÎ"SP 7QÌòX‚eô°EŸÅÈŒ@-ò%À’9÷¼S@[miýv[U üÒ½Û|`Ýc $õo×ýíÀ,Ó%H÷ÐÌÍ€uáÕÓØ÷œ%èÉùí·ÈÝzET`i÷жáœåÈÚe‰KaOa¯ŒÐ»-ÞØ*x€<6CÌí6IáÍM×$0VS1»$è1ˆX”‹¬@9`5ƒÉ$ÆöüÍÚY!öëa¥¢#PAuÒæ=±Ìÿ-LªG(AÊ©%ø8 tT¸HÛ?‡6ƒâÛ³I[É€ÞŠ„QXøƒwW`‘#N¼ Û¾±k…/¤H›v˜>Å3zú¢^ÓEORë&ü=‚z›¼ËÞRÈMKM "üsÊ%Ô:s×ÃóÒƒ[oô‚üÌ<½É ’YR™?×<…­_ÜwŽ¿Gf?£Óç‘ x¸˜f^.‰9ruCãY©„ºŸoËyíc¾{ðeã|áÃ7ÿ³ñ»/ÿ|öyd¼}èá—_µôµ_~üõªÿùûó÷û÷å¯ÿ#`VöǼPM9 ð¸@¥¾{`-ˆ“ 6®‚ä`L2¨ÿ¸ vP„(ù`ÓB8B&&€ø;a ]˜‘*­…/¤áQV8¿ÖP‡ ‰!Är¸C ¤‡ ûa8Diш@Dâ³”¸D6‘QO„" ¥˜(*VÑ…WôQµˆB.îÈ‹_aë3F2rÐŒòA#[R@;õ¤ñw lãZ0àëQäñ‘£PÖ8:ªåŽxBÏz.²>òäÐ äF d7)‘€$¬Ö&)Œ€PÜ$ÉsÇÛ¥­hÀy€'W€%¯ÀU?A^"g²HÙ4R#ü*’BÀ j<Ù*Zvj¥$÷è68Áƒ&HB²eYâ1½VLbÞQh²°²çJ™ÿÀò5²ÌÈ%%)©\‡ Xê%8)…̼mmX*©)`JJ¤ÐxȪ¢é›6Ѧk¸‰ofé—â Y–.‚\J*l(°Ò“Pä[ãÉçCï)NDîó•7”ß?9,æ—ÿ1€ÛÎÃ`B‰¡”TQ4°" …—{b)%'„1÷@ò@õ GáçQ‹Ð¬eRjÏnð56‚*oÇÚZrvâ9 ×S¿ÔXI >7â#OiâÓöÕ«áëgkÄ*“”u¬%QëiÎ*“ ­kíÈ\KóÖ˜Üñ'v¥+Føú8àƒ%la {XÄ&V±‹elcû´€µÿ¯Sù«g XÇfV³›å¬b!à•\“Ke;ƒW˜d*¡-iK+Ùó¡v6`­kóbZÍÈ6%* €hm«?ØšO·(AAk{Ûà†¯…Ø;QL )’çêÇ6?‹.FJ@!ìV—"Ò(n/sÂüTàš%ÙãHÊ[„ÊìŽãµÛ°;ÝŠç”É ¢w)sBå•[ínœÓ±®s6Êcíž›‚×@wïa&,}w´*ˆêÌàÏáè ÏÝÍ~S·:>=à Ú§}'ÂÄG¾‚²Ù©`U"a­EN¾2©ª@è¹c šf–b\klaÓ@Ž+°c› ,h<ÿÛ81`³µ,ÈûŠî^ü¼§[–€ˆÛku—¾êûÞD¼“âþØNLBû@oœu P겚çÏr%+àìqV*sb$°Lº§=ÂÕ®ð«9'¹˜{®2“I2¡)@uR2’¤bfi¯šX2!¤©rD¯_µŒ@ìÒgÈØUccQh;aÎ'»´&¦H ^Â*˜K-ß,mg;ˆÚYº uIY³ëU)šÙ¯:ó)Ԙ橦ÃéA‰ºúQ °VÝkÚ$cRŸ¤ôƒ\û^!"ÒpÆ.;»ERÚŽÛÐÔ¦ö0'Ç)Pš¬¼!Oç±Høv„Ú\8ôê”úN¤ÿ³í¢õçIo*hHªIaATáPºq)1 ]Š8ZERÞvž°á8D§NŠB–g¾›fHº€Œ¦ˆgS ®²Ûp-©RPŬ¶$}­LÙ~e~H–îŸh`=I/ˆ«\zßëÉJ׸~tÝ…&A¾yNÄŸ¨c½¹Ó¬zÔ}ÅŸëj`A—ŠiR}<ð÷m§0Â@nBЛ=ÍA‡`•—qþœït$ºCöØJÿi­GÌpë#ÆÆñ¯Oä 3yÊOÇòÁ|æÅ'tþÞóܼ_:?úÖ”~/§GýiT¯Ö·¾4¯ÏKìe>Ð#Pô·/ íéÿb{ÞkÆ÷q~ðÝ×÷Ý?ÇKñ•¯¨Ü;0ùÏ—óÿ2}ê·Ïúlq~ö ³ýµtßûK‹>±?~²–_ƒçG÷À¯ñ·Ÿ.ï×Jüåß<õƒý÷ý³bþ[ ÿcŒýS‹ÚÁí2ˆ7šˆ7¢ À¬ LˆZ‰§÷ø ‚+¯{r½‚ ‚3¼®j½¤Š DˆZI›‚ã@wz(€*5ÔÁ©à¦¶‘$­‚$ ¤1Y—f©;I¢¥‚J›Z±¸u¹$J¢%½Òšª¤fI%)‰¨‚ØUéSB%HZ%@¼Ì£Á¦à&I: €iZ„:¯Á§^¯ÿf³]"CbZ›uÚ¥o¡¦ëª;œ';CTq4eÂ¥@“>!&c’&jÂÃÛóB¥CtI¨:´pÒ‘µÙ$óšzz’\Z›M !'!'‚E_Ê¥AJfYƒªÃÁ©|â=F¡§ˆŠÄK™ÄÔ’(!C¯É“R¦µ!(JzEQÔ‘a¼¤_’‚ ¤[©¨Bº¨œ’ÁÑ‹E£pÄS‚ĺ+©0±Â=RA¯7ù2l&<1Å-쥑j&·qrJÇ’*§d|)ì 4a¨‚j©› ‘œr“EÌ?*@Ъþ`¡2;|ä*YCªS:Žì(ªöP¡:ªáª(¹—ÿãØå(*©r*)‹¨ÂªÙªf”=j,Š @«8I¢HI•¤ – —|IòGȶ8 I~²IÂI¶à- ØIžü*ä; ø‰¡,J—ˆI¡˜É…P-¨XJ¦$ §T¤X­ÜJ®ìJ¯üJ° K±K²üJøŠ¬JŽ¸Êˆ€ 8¸ŒK¹œKº¬K»¼K¼Ì˺¼¯ Jµ¬+Ÿ$" d ¾TJ¢üK:JÓXðKÄLLÂ3 pÌÇ„L‚ÊÊìIÅÌL÷ Ì$LæòL$‰è‚¨è‚/¸®÷z@‡à®Í)Êðb/óJË8¯¡I¨q²Çp¯›‹/tÍÿbKœÀ¯Ü€“ã0ÿB°Ô©”Né’K°»+ˆ(Ó ;@™±0ËQ°¡ålN±ž±Á»LœD³£1+s²A“±¤¢1K±7Ó±‚`²S¢* ›Ü2#12$›¶%Û²&8(»Ä)+š*»2»ª-s/3i,8áì"œ<³ø€³5“¯6kƒàЄë2:K8ì¼3:i!>»±?;ˆ@CHBk 8´™A+2m´d¢¨|“I+’ð¸4VÃ&â¼ „ÛSµ5x)µOC*I¶±µp›µW»–`ƒ ¨5VÃ5Ûµeôe`›µaƒQQ;¶ÿƒy›e+RW:ÒÕÀIŒ‘¶!~ lë* ض"é¶.ó•p3¤1’ì0·4C7ž3ˆžÁ1w[˜x»”k«·LBÔ|CˆjÔæ œ% ¸Oü@9’Ó™@¸,éSŠcJr¸L‰3U†³¸Ã!¹ªã8 ð¸ùD•n t)9-C9bR9+i¹—S%™\ýÓÕÄ9˜Û9u³%Ybi¶ #:EH©Kº¥Û)§;³C:ª39³;­K•{麷»´±³;‹9ß@;Y;º ¯s²¸»”¹£»Ã»q:ÛŒÓi=£ ûÁ“ÖͼÍ@U Å+Q• ÌäÌžJX‰í¿h€e£Á¬ØÅ¼X@ÊX‡‰ˆýXâXFòX’ŠMYˆ‰€€ –m` ½¼YœÍYÝYžÍY 8˜Yš•€²,Z£=Z¤MZ¥=ÚºZ§}Z¨Z©Zª­Z«½Z¬%Ù€;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveScrollbar1.gif0000644000000000000000000002332510520670125021434 0ustar GIF89aÓ^÷  $$$(((000888<<<@@@DDDHHHPPPUUUYYY]]]aaaeeeiiimmmqqquuuyyy}}}………•••™™™¡¡¡¥¥¥®®®²²²¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Ó^ÿ_H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]ÊÔã ¢JJµªÕ«X³jÝʵ«W«D4K¶lE F”X˶­Û·pãÊK·®Ý»xáŽx€Á¬ß¿€ºà"0KX^Ìø¨ŠUP¹²å/›œ¬¹³ç—™?‡ä,º´i‘¡Os$­ºµëŠ©__d-»¶m„±oK¤­»wíܾòNÜ4ðâ ‡#_~ù8sƒÊE·xþ2õä”[Càpýµóî/¢'ÿ=‘âE‹OL_qb…À)Ø» Ãtð§¿wo4‚ÿ¬€@/”@ ! ÀÀ€/,¸ %@ÜágœuÄ_Q0Pà¾"¼À "Ђ€œ@…Цßuõ àA‚' ˜Â„"¾@¡‹0ÆèÙŒÔÕ8‘¡gä‚‘ø{ yä‹Jʈ¡’N åA}9º—D‰ fY%wÿyÐå’_ƦP!pÀ{Wî9Èù‚‚rP †ÎÙ“ÏÝ©è£61Êœ£V“¤ËQjé¦,aŠœ¦B™°bœV§(¨A!6À¨¥zWg†¨ÿ%¬Jj«*j€yõêë¯xM@+­¶âZš§Å °ÀWÌ6ë¬W ;,·«²ÄÅ ”Ò6p¨µŸaœ¶?I€·àûª…äöÄB覫î©Ùùu·òÎ;g»ùöû¸¾ñëïÀ Ü›À=qÁA+¬˜$ÁM¬Â;Aа ¡Ø ÄeI|Å9åY` -P$˜¨cƒ|r̔ǶŒS‘”€¢”Ç€”./sm2ÛtÂÂSP!ŠúsÐ/¯‹_Ñ5éy¥‡ ”7dƒRf µÐRƒG5MVGh¤@”¨ñÙ_+5´lcÏdµž'IÁ¡+‹ÜvRo¿ÿ·L€¾PÞ•ï½çóÞn‡½_½f­€´B(#ηâ42n •,ùäônîyB}»ö÷畆ÞÚè¤?jºj¨§>ç꧵°›&ûìÖ^Úí¸ã§»h¼÷ÞÝïŸ/Ìò„‘`\$ô iEOÿÓc“Ñ£4%_¸äÊfÀt&xÍrr²HBÜš/=Íkwá,ßÎåtG‹?W@4““6àF2½k’“xP(Npl*MN)€À}<ýiµ˜‹9°{ ‚R’HÙ Émq'g4¾ZÙپ˫IÁåAZÏ ”ƒ.Yÿq ²»wjCxðjÊ{€Dh÷š½G€DZä„Í'ZÑÔTHJðnÆT:'÷5ò¢'ÆÛÁS¸2BÌI£>ú·¸½‘:Ph ûžÈþ'´¯=fZ³×ëÞTûûýunï“Ü ÿ&Äï‰ñ_“äódùÌŸ‰ówýè_Š÷Dó½õõ×¥êoß%Ó׉ÿ÷¿ß)ìÃMûä§SæÓo>óû ýìoŽûEÿøW&ü9¿ýƒ»þý·ÿ8¡þ7x8€!Q€6q€ø X Ø€ñ€4¸8x‘2‘{ ÂvAPEe÷{´ç"!pñtty 1&FT\)´5$!Tu§v$ðbƒ¢wiRww_ö5T PW!ÛÑ!W¶ƒºwƒ/A[-p&öaGp&$ ­F"•5/òƒpÂg#I½D:3†ž"õá‚68§S,QKV’%óăõ#qÔd¢C×TIwcF¶JbLÉ…pÈ:r¸tX!Dÿ2Oîñ…©- z,r cBoV£P†ØNˆØ:QK²Pd(€mÂt".¥ ?ˆǤSR’#™tŠ!¦6åLcb°'….±‚…6$Òbÿ‘5Âg “#ÿ7$¨1 ‚9v¤ è¡P¨DF5ˆ[¼ØÈq,‘Ú‰;‹è+U߈áh;ãØ+P,ç8EÁˆåŽïXܸÞX0,ôX•Ž¥1Ëò,Y-ÒÒçx*Q¼,‘Y‰/þÈ)‘1Zçqõˆ‘(¡‘‘VéFÀ³Žë2'`YÜÛ½ÞXæÿ2Wà~Bx“]„"t¸#7Gi"„Ñr2ƒ‡ÊVQÀä¼%tNØõ".┑½3ß;À\YX@ BPhb±Û©¾í4a`¤•pT}¨1‘¨1ódN›¿ˆ™¼À»³K»,Ñðo³&:µ&Y‚l^špíd p(9R2ÖEcfd ¨¸ö+'0Œ¿Ò#ô¦"2ÂÀ&ÙE*Ì'o£³CÔÃR"À‰J…æ&WCµ4-uøŒY3O*ó‰yŒÇ¨ mEÂäš=2·áÄõˆ+L“=»SWÂ&œ, _mK¶ã£Ç{ ¤Q[\ÐB'ÿc{gþëè”[i;U‘#ƒ Ñ4#x¸×K¡G€€Œ>‚=Žcõj–œÇD‡âB­‰.êJ˜'ƒ“'0ä‚:öÊ+eš39ìÉ€¢v1te~ŒŸÜ>¡Ì<Ž88ƒaH M+ cªºQ(ÒŠ:biGs©Š«Ás’fC2‡˜ bÅ*¦©XÎ\˜2ù)Ì“\TãhèqpVj&w3#•I+Òo"W7‡&˜5g$‡2f(¢dI´œ°ÐLö8眀Ã,?Å,<øÉ ¦Š&`M#Øb»‰jHY!%°ÉÍÊž³©`82ARŸ ÝŸ`©o’\ȧåfN–2-pGw›à‰žnÿfª4C‘§‹ê{ÓVãp!–šòÒ~†9pgÑeµÎ7!U A©1蟯1fc&c‘Ö§Ü™.ŒÌñA!.FGÐMAß„L**IMI!\4DA&ji½6[_ Þ·T á"$¨· ¬•±54ôS5EË&gFëS Ôé!8ç! Y.è–>58íAnHC—ÑÕÉž¬Ô6áK,u—†é´Ž”ƒƒ%œíq̵ püIx° ‘ªçÉÉšúÈ5dW }? Bò ¨zGYVÏà ÂtÃøKD¢Q.2!–‘Dè*ôzáš9ËÍ*ÂôÀÀé±1tÃ?bqõ5ÿ«„7|Ý/ÝÃ\RÄH]{qýsM+ £Q9F§)ÁÃG0,!qÚÛèÁHTb}éísí›Í¬1C{"VòÙƒxRµ¤ßçý³ÌQÑ1ŒÖWÉ~׳ @µýÁÙ3qÔE)c¼Lk³@8Pîág åÖNŒt&x]{wÚ áÓ±owáî· aÙÑßá}‰r29ÊÔ%äÔI‰6ã¢âzÈð*8[ µ*8%’uiCÊ–2’6¢ÛɃ8’2™&I„·‰œÍí[>i&‚#R‚v`®'´‰Ò—=ÝK±Ñ´ø#*lü(Üqg"¬÷e›iòÒƒò3†ÿNavDØ$çWF ìCÁ-Ã"ó¾ášf&»š+ÑÈ,¯$XLßôNÿôPõR?õRß¾!%¡´,¡ãHðùäò*áó´ô& ä$0Oö.iöM ö(ð _âU¿ ¡¢ Œ\îwÑx̨ áb£Xç5l¯måâµ “§d!6F8’]ý TXûƒrï†GemÆGi§l_NåKc †lmžoa>çömvm×i&6b’D͹nø^ÿQ¥o,©Ç׎hnÿfÎGÃÊOGò9ÓO“e8¢F“úr\3AçAèæé$#Sn*žc&Ò†Þmzòƒ(·REB¤@à¡„/ä̔퇆r€`vê‹âŒ-¶fßÞ=FÊí³¾h‘p…Ù¡%Ž–êa¸DÿJ,­ü+("Ü´¢M¡îã'îóÉ3N!¨Ð3+&þj"·ˆZ k…„¬)…¬ØÊ`,èܳ‹Å Ï+©:Œ.[` … kd‹5¨¤ƒN·°¢ ;”NZ.8Ú¸Jϯì:ë¡âXô€)¼¤âR%›šé…Wjì=4ÓÔ,>öèòO'¤ R+£ðà | îÎ<ñ” K;)À)(¼¨Ô½:I ÿ©*”îª.š‹Îà\T)Áê Á´˜ünÑ ¥¶D ¸éZ{(Åî:A'ð"(0=D4VÚbÝɾ®„‹’§W½Û4ƒØë  8ðS*ÁæÚI±c{!¯†ú*.Ì¥bc(ZÿZDj'Á.3s=5Ë5·$65£–º§EŒ¡³€:D¹¦å-»P¢õ©¿¤J(­ïÊ+cO" Æ€_X5œB€'œTÊ«µîrh(|qJU³'Ùt#Ô*;ª¤ôlØ£_:ó\˜cÎ(ÝÊÎºŽ«d…n®òD“««·€Bˆ.Ô0ØŠ%“ƒ0“Ž5… j-+"d 5ÿ®ØŒÐ鉘J‹ b«l¨[Î>®l`™Óþ¨Â…Cbm\µã–™fÉlæÎ¥ê ¸hú¦ãûGã˜"6¡éÒÃmÚXÅR©†ºTn4ãp‚€ªÅ‰ŒšÌVƒã€!Õ¥+-&v¯d¹KrHWÏtÖѤ;²x¹ä-Ö»pL–R…NÊàv»*ôÒ8Ÿ p Ù=Œh¢ ßÊ©æ¨k"‚¼L¾Z'扦·Ž"~-›™’n(ñZüÈ^&ÿ|¢^‡¬[›Oˆ '¶ä’—>Ô®š¶!œÚ5,&Èí¯úWá¯!-pÉ €¿ˆÀ/€b¢‰aL㿌 ‚ÿ;A3‡> fð"æÓ`EBÿö¬ -ó QJ@,öˆ«„+DYÈBõA&+ |aHךŒ¬†;Œ› y¨ÁþPˆC$bÉUD ‰Kdb!ãC'–N‰Q¤b­(^1fSÔb½øÃ,~QM\cÍØÂ#ž±\dTcÝ(³0¾±2l”cíØš8ÞÑ1tÔcý’<þ1$|d! ‰Å4ò%„Td#õHGÎ „‘¤¤#!YI‰0“›üâ%9ùM~R”Tô$'C9JT.±”›mY5âY#Rè®/ŠoæVÄxÑæ;\¡R¨„4,áC œòh†¬ËZ‹¥ ¨s²i±†Ð½ŠÉTbUæ]1IÏ)ò(s •©¤«±¥‹Q–ä.™È /^[• žT&¤ è$‡IÏy[ÕǬKËæÄd"èpÀ)àEöME1¤§N@ Só²Ó`ÏšÖi†Œ¸â<{/'!y ‘zÇ*%kyZU,4˜d‘RH9aÿy´í9… bêKãtòð]£»8‡ñ ¤ÍÒ—Ò4*øI-Sìh»ÈZÝ á³gɤ‡ì.&» S@å0ê¾ür¶‰µWæÓÐfHƒÙVR–)+kDÉÀóºc$̆L@2(V¦&‘–KeI'ˆS´£6¥¼äg<9S”C“ЈÉÐÚž–Ï€BöG9Ä+Ù;Tütk¨¬ª¤0ÕiØCç’.ML)\Êså‚à=/ÂØ4¾0íH'X!R§>G–‘“¼Ö¢ì:™BVím±Ù\£[A¡„& wØQß§-ˆ$+õ±y.’·ez¤ˆ)!ðIsYC,Þ´šó†Aý·xÿ¢˜Ât56£o WtÒØ j}òŸ¼µ¾Œy“ÈGdëfÌelèLË,G_úË7¥šµ?Þé—ñÇ߯døÅ8~òGÒü_Dú¹~/¶ßý‡„å?ÿBÖ_‹÷ÇÿõEþë¿>ú?+ @¼#¬"<À:J@*Z@|#Œ"ŒÀ6š@'ª@ <# l" ÜÀ2ê@&ú@ì$îc%ï+AoÁ%"A 1v{ÁbA$rA¬","¼Á;AYJAd¦$¢ B&Â!*B#D"$"%\B"jÂzB(„%Ä% Ü¡·°‹Ð𙉸?ñˆ-ä(ºê0äA)ä!*Ĉ„,ÿJ¬Í`Š<Ûˆ„á üX ½CÃ+ô¥,lÛ!+JÃ}“èò‰äÒ ¢¾0“¬E©…P©*Ù’›ðIÔÔ™‚ª… Ør«|- )•±È)Üy‹iR¤:…±ÅE+¯rªœ‘ÆjÄ €ßû¥X+ZÜ‹U„^¤®LÃ:¯|ÑDžê²Àâ*ž"ÅæŠ0À L+Ñ-á¦ðª¾â§Øª:4d´2.Á‹EÇÚqˆëAi¬!jLGÁ2«3ǯb•ëBóÇùFô*½SGº`ÈžÂ)8¬ ¿ò‰‰:Èÿ.Ë—<¼Á}|¡~”Šd0D»ÓRÔ6áiòКE¹»S(w GXÁÇ Ù ™Ü)¬rGè¹ I»ˆ·hÉŒô8’ÁŽ„¡>L¡µó¬CšØ¨ÏZ©Ã˜(£Ð‰‰r ¯ò««ðJ™˜˜ˆ·žªŒ‰œ1¼Hôø¬†°Jßé2iKS¼«*\Á=$¦¤œKW:ÊZC¼´¥ºT¦»ü¡p¾4½,!¾ä(€ ÌÂt¦¿„¦Àü¡ÆtÌÇ„™Ãô Ää ЧËÌLjŠLE"€ ØÔLMÕ\MÖlM×|MØŒMÙlMð°ÐÍ4ÙÌ*€ÓœMßüMà Îÿ×lS€ÀM5ÑM šLúÌ|2Nä,åÌ Î܈èŒNé$MnbÎBìÔÎí…(>DA>òØÖi¾›Ó%èËS} ë3¦Õ>™eêdOÃÔS˜âS¡E@¢½-£=ÚLÚîZZ¦•@§5/¨Ú œZ÷ªZ«å@¬µ£ ÝÚ˜Y`¦@5°Å¤à̬%è€8[QR «[»½[¼Í[½Ý[¾í[¿ý[È1­…[Â-\Ã=\ÄM\Å]\Æm\Ç}\™ ;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveTextField1.gif0000644000000000000000000002463710520670125021410 0ustar GIF89aù^÷ $$$(((,,,000888<<<@@@HHHPPPUUUYYYaaaiiiqqquuuyyy}}}………‰‰‰•••™™™¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,ù^ÿWH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§-Q`¨@µªÕ«X³jÝʵ«×¯`ÃfÍ€ªÙ³h_v A¬Û·pãÊAˆ´xóêõ(àÄÞ”#üL¸pB › ¸±ã¼ˆ‹d,¹²å¤‘/w¤¬¹³gž™?cä,º´é—¡OO$­ºµk‘©_;d-»¶íбo'¤­»·o„¹ä-¼xïàÆ‰×.a¼8òâÊ]Ÿ(`¡¹ðç£ï a!ÊBÿÌðawï+2·Àa… Ä[?žxþ@íy?€ @Á  ¬0úñçŸ4Ð@@èÙgv¿á‡W+”PÀpÂü矆# (u#P„·Qè›…i` ´G]¬ £‚5b¨£)®Èbm.ö#Zž°"2ú•du>¢¨âÖ'á‘g…P‚þeŸ@Zr)â‰ÕÉ($•­©–g0ÂÂ@n™!s+È™¡žhº¦æmlö)(^Úè ˆBUhm‡&êèR‹ÊÖh› Øù¨q‘¾6éY Àg饾eêÚ¦fUÀ©•‚ª•ö«°Æÿ*무Öjë­¸æªk®¦žŠê§ª¾&jk,`ì±È&«ì²Ì6ëì³ÐF í¾ž€*K$«ó‘ ¾^ë—¶ÛéíSŠKn‹ÜZwnS*°5îºUš« óÒ[/‹ïêë¯KêÖï¿§ði·4BŽ]N|5°#žgþ—/B<ÔÁ¦%ÌRÆxN¤ÀÅA€^ZP1°A²Æ?q\šÇ*±—^y(XAp Vb ò¼ÂÃ42Gtd,Pè¥A‡ ”`rVÝtÆ@3cw0%³h4§Ô¥#XÀs !¦B¥ ̉ö@%þçeæˆ÷ sÓÿHP B·Ž€g†í¡ýAÜ|W§rØ@ýYÙ'…`tˆ)phAˆ`œ'w„üø›9g ¡@ÝM€Þãq €#†¸B¥]uÕÍÍ:ä=Iîå&=ø„àºyìåŒ ûÓ*A‰ÚN½@XšÁœ¹ðö 䨣Ö'ŽŸ;öíñÞ{»Í_Òã Ö}tu€w){ ÿgwž!ª^>ÕqA& >¶•àqhßþܺ)@<øËÉÔwßuÆ}$A wÔž=üiÀŸºN„mSZ€øÖAÿX@|4êO{ðG4¿|ï~Õ yf9 ®Ï^Fá”ÿ^ö‘5è DdˆÔÐ7» ú°&Ô I"Âü¤ƒð\FpÄŸô¤ï‰:‰âe¦8’° $oêH3Fа/9mŒ£JÄh2ÊñŽt¬ŒïÇ%ÀF°EHj`§¶B÷rbƒÝDËÄKž0N\‹$]Ö°O8L‡\Ö ±ˆÃøà5@Z0ޱŒgLãcQ«Z×ÊÖŠ+Øb#‰`W@²‡LdXõÊW©Ú1+l™#'YÉKæWg:õd(GùJš1¨t­<ÅÄ\.Œ—…æ0fÌA^{Ö%…Gÿ&­'›•¾^¢(”+Þ Œ-fÄÏà“žë¾¸ÏVÎIàììÜã5¤‡)àÞC†§5dÒ©´ó^æ&<…ÌN–n _6=ÒIvfW•ê<ÅÉRpJ.Ý,%jþ1ç¾”ˆ¥c­´‰ºb©¼óOÊÖ¿< p/<ž„7@zdoîâÛ²!×µ<²{²!£·q»ÒÓ ²< 2§¡›#àò¦óíÜðl ݶ»EpOÏŠ¸Ó`³˜»x—@ªŽ›3$…íš ÏbÀSÿÄ£ºtnqx÷TfPrçLƒ3¨þŸóMàrî9Ó}ÁÇ5žM5Ü–ÿûžÖ<¸‚šÚn×ßÇË÷8û¢óC ßì’¼w¶7uiwÁn4 >²Ùòm C›]à„Oº1=DÜIàmqðÍh½Õó©‚r §VÝ|IÑäó¶¥—¯å›¡–¢:Öìê\‡ÝþLV¤ûgK_ÿ»Ð UÄ€“hq+’¯Žfê7Ó é#bÐ2¶!ð¨p [Ô‰\ÑÍ_‘Mgº¼ôd/‚nyÿ²ÇíÙM¯ûÙæ™ôt˜ð.a­r~Æ–‡ø¥ÿ?鳢‘Çu\¸ð*¨£jÝñoé1'd:«3x¢K„<=vBâf⑵=é±=÷Eáƒé#€R8ôE”—>è!€ø8'«3/›…‚`"Âå„tü§VÃ6…qD9¡qŒ¶ƒãFä¡§I€Çeff{Ñ„;ñ„P»Ç(UÈHW()YÈ;R¨TØ…gñ…9†b¨([¨)ghIi8*k¨1dˆfø†L‡71‡t¨vhx˜‡H±‡5ч~h€H‚8ˆDQˆ3qˆˆ(Šÿ(ŒØˆ‘Ó†Ä"‰äòˆ1‰–øCR¶‰´D‰㉟H„¢ˆL ˆ0¥˜K§Ø1©ø(˜šØŠ6ñŠ/Áˆ ˜:§WÁ=¥H‹.ÁˆÜõg‚N[¦?ÕŠ¾Ø‡è<…£kŸò&ãb'™ãŒËFXÓ¨ksâ&Ñ(vvÂÆÅ‹ž˜Œ,qˆð @‚NgƒN¸5[j%1:Å0s•\âV%@5`#ÙÕ6昊â¸À%Â6ÌÃ\&óXj• %€[ÿ1Œòå7~#V Þø&Õ‹«83hÁUEY„eýSŽ\e"Ñ!ÎÃ%ð 4:\uVŸÅI6Y&—5S¥:Å$yÿ[ø$’Š%’bå&?2O¹„ƒØ*ñî±ÓÑP*Ò” "[TP…;°؃#ò´’³ÕT.IŠKñf¥2xâfé#\EUnf.ÙãaOoo l›h”)‹²Hz‰|Ù—2ñ—'˜‚ „¹Y†:v˜‘˜%a˜aÀ˜Ž¹I’Ùp*•Ù˜—‰/99Q¾ò™¡)šæ"ÕÒš®ùš°›²9›´Y›¶)› š©ù™9›É¦y*à»I½9!ÂIœÅiœ£ù;AÃÙœqœ!ñ› qÌIªÙ‰Ü‰)ÏyAßÿNá)E/QN'ޱžCý‘D‘EP•žÁ|vRÖ ™Tl#g÷Åè5‚\zWl…µŸAIBdⱂ&ø–9¸‚€€«³9>öôE9Ä:È8!¥¦›Pn¦\òá+vQ¡+:JâRõ59Nê”Ô%•Â73:sãuç!@ºi6ã7 R;!óqˆW&1 ‹3(hä"L:jƒ\rso¤6u4ò‘S`Sn‚6ȵ?|¦þ1ÇõWpâw:ZžcÄf§?)0jh“¤âkx3yš'{]42þ3V]’Tç$)ÿoþÁrýÓ¡W)=µ£k”>禧:â̱9õ‰ƒ·Ç<q\MÓ=*'§Û´£›Á¤ç®oú=%òS‹£è"ió0÷¨~Úsu<“=fyuT×kûÃXùq ’ogGz-5;9(D7ÄtUs¨œ³"‡Š*Ú¡ªñHsCsbjÈç$å჌®žõ:BV#i4o–lŒ§­÷c1sLã9p\gc9̱8:BDãj1ßÁ«r v¢¬hÁ^meܺÞpÄ“3ö#>§6!ò0ë7Ó! õA³³W×%ÎPXT5ò£±&Ú)ðr|ݧ6æ¦!ð TjÿcWÉ|âc³5Ây “#B8f2v¼v°U”ºv Æ'p’9J+kF§uÄEq²Vi¯æjŸ¦4ºq™Ö@³'[;V`{'®¨ñ3”Fk±qR‹ qû7Àu¶‘& p¢±C‘•BeuÁè©å˜3¨¢V‚ŽAyVï!#…;~S+–#\ÚHÓá8à¦n%DÌ%OÒŽ…Ç6w@oõ! ¨þaTòy«z8Ö‘£?ñXº6[?2\Û[câ•i#;;"1ª‡T«GÔy’3t8Ê7›eWYèu"¡ >£«¼_ë«›ØI0Â$¢•Eœ#½·ëV†ÿ‹ Y½ãa\“a‰¼ôi7:®+¢ˆ<`r@‡ã–Ú£׸Þ9žê„#">†Q½£Àa ù)fêKH|ÏÙ¬%ÊÎã^‘Û:·æ^*  K_ûÀ¯ €—¾##úqS²¿ a8fB”éñ•£õ*löÁðuÀ"ìP,#9Þ˜•žF#Xã ‚2:Ä|#ü‘Ÿò$ P'Ð8:ExùS¥…5óÕr U`q½9,(Ó)94"‚å:” £#<ÓŽõ:Î &Gå*l³uŠú(ü:jµ9.5_<õ)L^¬IEVȆ|ȶr­ÿ‰ð’•Û¼)Róä8ÉÆ„C¥ÏÓÄ âsÝv*âñhµ%z,YÞs[jå#\lƒ I#Pc®üʰÜ,К Y‰N òXsòYjU¹@Rô¤2ÜÓÄSOœZŽŸü•ùs3|Ê“Â_¬.66 ‚\] )À$'Y8êÕÄŒ›3ŒÕ%¿\"‚tÊ×ĨÓ6…·8J’±sÅÎ8<ͦ¡œû1.2£%_"õˆN6’Y®wN ÐŒå4#_þ¬!.##Γž¿œ]_cW["|Ökϧ!`aÀ]ŒÑ¥q]­Ê -%]«Ü'€ ü ÅÿG1M'/)-È¥˜5w;¥Gt—T,©[7 E œH¥È >ã:s4âöQACß³4µ5N¬ áóžQS;ò@PƒPZ Õ&S ËbŽK‡*Ç9k#•¨$ƒSu37xƒ8v³8yJY8ˆš!Ò¨ÉEÐh3s6'¹§ÓKíH¢¨hÓ9B”S%PzÞ³9!37¤5•Ê@ŽÊ2'><³ÙXj;§sv‰½a‹=I¢87”G<ÆãÇ%¥GÃ<ÄXVJ=¢:>ÏSżXØÞ¡±Ã“Û¢ygƒ¾]–Ú˜´ÚyÛ<]âA(Ã|ãÑ0^k’-¨ÿAùC@a'¤ˆíGÿ„;%2sR~AMaÿ›PsŸ“šÓ ‘ i17¸³C:Ø "GtB b>E§CEs{OUía^îç8tÅ=k3#†Ü´‹ÕÞOÕì½ûÝÙ£ñ€¹]G=Á¸Åö¹;½^ò›ovƒÈÓ’N¼Pnéf~ø»žfÒÜQ~#ÁEIý±%BGÓá³Èà¢TâL‚Ø€%SF%4’WÄœäGóvä!)ÒP[RR!>fd––E+ b#ä§äà:å‘üä– !)"ʸøÒVRÒûÍ“‚9â˜ ÙÆV)Ä-wR^‘íÜŽðA#§¶e^[@ÿ¾[Þ‰nì©ÔkÝì*)BQå1òÅâcõ·…çÅEèÿ‘ÁhÁTEGÎ = œ0l!ð»~ æ¬Tâ³ãîHÐ ÙiŽN³ è^ŸîÇ2A[17/´Ý qìqåƒ)ë±´zrÐØ3Ï#·xrÎH7F»í¡±=”Eæ¥àÌsB ;2³šà(X‚Êtór„²ªêpbî”î ¤êk¶îâ#ê¨í¶T€£•½QzÝ1¹v¡€£¨q­XGkÌfÝsÓ!= Udåð/×Úq÷=î@9"?ü0þ¾K•°^]½?/t¾uÓq›%1_dvÂ%èæÿc9@x§'‚\Ü„lœ>ÔÃTõä1ÿ±÷‡á±郡›µÁ:9•4ž;áî2 ¤¥0¥hw}:·ð`Ò0:Ä::qxSOÙ33Eõ Wà«ØFÿ(Û™ôôswsÂo¡N®V÷ÌQ)Éî]@X5:Ô²ÍשaÏ~ßÓ¨û:ßZ–ð|“6¿!{ϧ~e­Ò ÆmïðÃ3[„,·tLS_ÞÑë?å2I¸hD½ßòk …:P!t÷¨Õ³úÿf²çƒöç-ﱜ²1¹àîì#aO¨m.S1ÆüÈŸ R-ÓéGÈ Í>¥ã.ÐH¥¼TºMû”P+i\+Ë-[U©KóZ«P•h6û.rO¤%KºÐ.lL«8ò»¦‚íHê$ªÙ4?à‹@¦šäs'QOø WS¨<×fT¯ï°ãÀ·-(—\¦à \fÿl46V]µ$Xw;ht—‹+1ª@\*.2ï43áøm*SSÆóÜ Êßv”‰a‡Cn â FQ ð*ØÇÏ#ø¯úÜO¾¿jÌH‚.öκ¥RR«©’å´P#?Xް fŒn®–÷œR¿~jÀ»º©ïªCL.K(ÿõG FœQuåºñ„±S\’Wíê^´9ÊW7K³>Î@ ¼ z®r?Ój§ï(QÔé¨jà˹6õ6kÅH, :#(¶»ü¦¬äÞŠd¤J*É«=ïÉ_ߺ®=ÖPdü5i ¬Å‚UH¸¸ÿÔŒÆ 2H¡Îf[Ú 6ÜÚéØTréB j¦ü¢‘ƒÐ²y¹ÀÕM*„Ó-xHzÚêMûz‰Ö¶MîæcR¨±Ÿ’Žë=½¯©„ƒºº9qá'›܉(4››S~“)wrßÇ]C{ŠTtŠâÆÙäNdi ör³+ýhFÕ;›-ÈíÕ^ó_˜Óÿ›h.pVãÁäø$'!‹Ù…2¢hç]#@^ÃBŽ¥É]C« € X7ׄj)u Áu¤)oñí+¼»`mìó7¨Ž^lb3H›ïHÉ:w‘ÎzR¿Âý8×A”e^b™­¬^^’¸få$‚–â–`Öx«Õ +)nlNÛT4ÀåPEH3ÜÌš%Å*&R‘ÖS$ö®›ï€è/=ÁKa¢Â|i’îÂÙu®& ìð}H°Ó¾*) 4¡Ã¢2ÊßÔG {lЗ!¸ø1iê`M¦Fӌ潛ఘIÒ†V’5ì!ÚHÂD²öÿ€ì1Ø¡fC`ƒ¿ës™­:æZ5N‰ qd))8íeë R#$IÎp¢¹3Y¤TXç½Ä‰Î• M$ŒrH…@ou¸ƒ&¦øµâË(Óyì\ã°àˆç 39(&zlE )H–ÿIPÞ¥+½^rþD#8% Eª*‘Šø8ƈð7lR’©"J ‰qpC”O_Z“(FI=Ò˜¶“²Ô6*•jU·ÔEØÐ(%ýÉ\Šå)­‘0YÜ_2à mF8 šrf™¬‡0æ)Àô'­ºªÞU¯º)×~…ÆÒ8§9>Ñåt̳žÐ(ð’^Ì ²Kõ)ÿ(“:+i˜RÀaÚu¯µÉëf=«– n1ÒÁÓu8Ôÿ” MåBÏ®ÎS0¡,'G|Ic,•0Íäô›%í ªÙϪ¥³Á%®W¿µ6‰)"Ïe>–#¡i<ÃiŽÅ2Y™þ1ªW3ÊÌwªS/r·t¢½E¿¸Ñ¦´½"íâI¯4’ƒH†Zé»^zÅ™F© 9ßbÄM Þ«¨?LêÜåc!¶Ýk ›…¢«k¨©c3Æeà:‰“pÞ÷<¥šÕ(uµ‡amMG=@&q¤ýð/HVª“S¬Ç&¦¦LßX€«„{Õ¦–Q¸3<-ÛªÍÞð³kƒà4fÜ*ÈJ£}/ÅÛ ´ ÿ‹Þwj7½Q'6p ~4 Eæ•·ŸUŒe{ÓÆÛùÞöR˜‚Fm}8utµ_?æ™6Á@îpAU¼ªôvpÆc³qÅuÜßlT y|mbp{Õ@ª· âï4F/_uäd.Uš7ØækÁ¹¾¹]“]§çöNíôDÎé¦ÎÑÆKа<*nÜÊÚŸÎì‹Oyê e|Åø”ãýî‰9 aìBÒ C‚ `>³"Íæíp·óÜÑ&àÅ;9îRv<Úð¿Èÿ8ê ®ü½"€†ñ)ó5Þüz;o/ €ô˜ýŒK¯^0`³§}ím{Üç^÷»ç}ï}ÿÏû¨^õHKë]üzôr;Ëg~óÿ|èG_úÓ§~õ­O}¯«>è¦ñÁ<ù&ŸÞUýö»ïýï7þÅ 0?úI~&‹K'à¾ûmŒüâÊßþîÇ?q§þ.a3‹OK‰Oƒ"‘ –7‰°‹¡ý ‹þ .›k,ä)‹õI‰ º¡ò·ó›§ <Ž~zÀ¯ˆÀϲ¹£¨ËaœH¨]shšfaåCŽ ñ(¾P(~ ùœ © ‘ŸÔÈ94Ô`¨:éÁyˆ`A…8ˆb“¨5*Ž()Ü ô¬ŒãŽ©á Mq¦j™úC ;AªÁ°ÿ¥Žš˜™ô„Ø¢!¹)¤ ŠB˜©˜’¥X–À#©1ä:<%£ÊBÌB-„¿#Ë8æðB¯ZŽ4| ±R ‚˜DÅBޤ–Á¡ä*顊¤1Öø‰¢‘‰— ÿ™ž @—=Ù4Q’¤·P—È©¥Jô–·)«ï`ާbD‘ØÂÍʸ.ú%‚©óÀ•’c<ôÙ ¿ŠE.ÁŠ EyÅE© èÛª LîˆO”󔞈÷¸”Öš”Ù:$SÁ,`L aÜ+blŽñ:-à ³2N©Ÿdt¸ )º-Ab!© °öȉ¥¡²R(™‹åФ=9HÜJµÿñøªx ÖºB¦ §x”GGT2Ý ­·ÈH!‰¸§‘.£XE”t›PŒ™ ¯ù.ù€9…á 0™‹@¡Iy”†c¯ó –#Š ;t8É™É4ŠŽ”QȘ,+Š I˜G½ªÇr‘/Îx ûB ¿àJåq ÒøŒ IŒ ¹£–P¼þ꯹˱LÔø€ ) ü2¼›`ËÀ3¼ ¡‹¿£‹§˜y²JŽÀʻʸäx5Ã0 Ƒ„2ݰeË2kL0L«Ò?Ë”7̬*ÍÜLVëL©úLЬ4Ñd)Ò,ÍG;Í•JMÕL4ÖD)×|ÍA‹M‚šMÚì3Û(ÜÌÍ;ÛM€êMÿߌ3àD'áÎ5+Îq:Nä,3å\&ælÎ/{ÎbŠNéÌ2ê&ë¼Î)ËÎ`ÚNîl2ïl$ð Ï#OE*Oó”<õ[ÏáDÏDRO÷ô1ø´¢ùôÍúl"ù¼ÏËÏ ÚOþ|¿ö ÐÒôO P}1u •ÈÛiL†`¢ÀŒp¦µˆu¤Û·lÑÁÔ“—Ó xË •=ÙPŒèÐëÎK|ŠÇ@ËÔ0ŒÁËÖØ¶xC£ËÑÄ)ÈÃKÁ³»”£ ¿0¶$©Éxæ`Q}L+» 7¹E’»†Á‘_ª–×»¤»¶mó7àð7˜Ê‘ƒk¦#SAÉ‘¢›!ÿGi’¿É‘;؉ÕsÒ'PìÉ9S3"é€x‚-E#º Ù9’Ñòýá6tó6,ǘ¹F‹èP8n#;5 (žL•TL¯L9§³S®ÀÓëY7£ó¶— ¸U3 ñ€·¶ØºžÐ‘€Ã™ð¶U¹±³­û·Ž+Ò!™ ²J¨aº‰ÕQ3á4U¢Éš4 º•YÉL²ok¸¿ )~Ãê7²Z»óè"^ 8_m)´ª¶ UcmM›d·SuÈ¡Ðì™Sró:cÁ†Ùn{·ÙÚRä˜Ó|›‘Æ»€uH€«T„sqL£w³ a;ÅIÇtˆÿuEጇ:E\Û‰:Á[;{([Ë5`«[ÚHšWT•ñÙ’E Ð?©‘%UÑX–­X†¸XcâY`ôY{iP %.¡u¢-ÚÏ:Zrr1úë@¥Õ¦Ý’¤] ö«¿¨µ4(å²#?h¿¬Ý’©Õ ë;[´M[µ][æË¾òÃÚ°]± ¨ø=»½[¼Í[½¥½à¾ØC¸•Û­³{7Õ[ Üܘ[©Z•ÐC\ÅÆ]ÇM ÜÉ¥ÜÁE3§MÜͱÎu³Ð½ÊUË-]t:Ý”â h§~ÚŠí) £Ô‘¸‘²½‹øI¨mNÿÖÅ«ÝÐXôŠ+‰+¹2 ªzšLŒˆ$çÞÑ¥³ÝhA¥ñZŸë‰Ê|¢5rœA”&} Jú“Ñ‘–žà¥HÉ ñ}Œ©P¸¡ò=•M ïEŒôµŒmÊ^~9,Fù©Øñ@7n™ÏàÕŒƒ¦¼QˆªiáȉÑ"ˆRªÆ@q‘à1Ž$ÂÏpsÊù€)g‚þ!ы̕ÿاq”ï)Š×ôØ¡]é‰PªÊÙGž^=c›™øÂØ”ÚjœÃ;ˆ– bP²­ÿ€(èXšºø£—÷è!£Ž¬ñœò‘ùÙ´Ñ‘ž4ÉŒŠ“)¦![„ᙨà’‹ÿº¨­™¨£6®Jä<àܨÇduçŠü Ä"¼cA<± x4 ùa£@ŠùéDª‹AîEÌ‘‹di Dd4wÊcž(Šü8‡ì›û”ã©*IûñGÁè €CÕ1e‘ þPÈæÈªjégi&)ªäøžù Û²¹à¢‘fÚ¡‚@e~é$ÌRãB e4Rîñ@ÁšÁBu±ÄAYz‰o”ÅúÙ©¸° Rª‰“"ôù“ÌÐå/ŠI›À&Á(ކ,GF1gùPœ²›I§ˆ‹Éi¨Æ`‘_âOQN¯Üd‡A) ͨèg64Ý@ÊÊô2 ЄfÝÈ$8+^ó¬èØH]Õ]&Ž^ þhBkhF#é· iáBé§Si³i–N$—. ˜Žé&ši²¨i›¶ €â+³€–·h`[¤Nj¥^ê´õ €¡^6ØÙÛ[«¾j¬Îê»m€ˆj¯þj°k±k².k³>k´Nëð ;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveTextArea1.gif0000644000000000000000000002451310520670125021226 0ustar GIF89aÓ^÷  $$$(((,,,000<<<@@@DDDHHHLLLPPPUUUYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Ó^ÿWH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Êô£‡ P£JJµªÕ«X³jÝʵ«UMÊ[ñÄ^Óª]˶mÚÈÊK—  u[&‘·¯_¤ BüM)aÃàÈyN\²0ãÇa.Ž Ò1å˘GNμÑ2çÏ -nmÑ3éÓ¨ŽNÑ4ëרWÃnèz¶í̲o'¬­»7ãܾ òN¼/ðâ+†CÆ€9èãÅ•3 ¹sÎЉK7úÀ€+ Tÿ(~E÷ïæ(0 àĬ_¿œ=øv¢ œÐ ?ÿ ýéÇß ë…ðAuPA óá&XƒÝ7”wÌ}W!<ð@xñaðzäa@|BVŸo ÅÞ,2¨@wà­Ø"ˆá‰X]‰ô=XbŠAU`À>žð|ù¤~4Æw‚èˆãoN6ÈcP¨÷Á@XW¥WJ—y¤æ“ØÛ”d¦i“™º¡©æ›1±y››pÖÉ’œ¶ÑÔ ØÉž³éT ôé'i€Â&(P@¡‡>å|‹þ¤£ŽB)f‰¾¶¦ †*ꨤ–jꩨ¦j*lJY§¬UÿêÓ¥˜A«®Fkj²öd£¶âš«®“^×+O;,§Å:w¬N'ܺ¬ƒO>;íµ íŠšµØv‹¶§q»^R„A³i žuQJ äB_z'ºÑfÓ'¤0æD ”P”P‚—+h0A$"„¯¼óVk/Mà‚`!0'$xi ÌEi@Æ`¬Á~Öi€Çq)P M> ¾#` oÁYs à…̰dôj÷ðL ôÀ(@ôÇF¯@ Œ`€¿´Œ A˜ H`5^T‡@£@Ä7P *¿øÁKVàô%pÉx1·óKà’&îE#”t ;ÿ½‚ÎMn¼‚Ô|e<_#Tp² 2g°@<Ð ù5÷ñ’ Jzç}å &÷Ü-ÕÚÝÉM`r TPAÐgø_Ö¤¹ÔY0‚ìæ^¤ŽP+ý´Ô+„ðe{ŒùñǽBò¤—Þ³}?Ç$w†Äÿ}øí…Ç ×)3½B þñà‘ÿnrƒsÜÊ»¿BÛá óýFçô(V“Ü‹Ïë,w°Öa€{ÉÌÇ* €!/«»_ºS0¼”À tÙß@6yZ÷"¥•K*1hPW“Éï#ȃG¶Íï†8d ƒçA~`C)˜áàÿ4<¾@MpGdÀJ=Í¡p%*ü )âž°‘¤k¡ËÈ’>ð¶âIî‰(‰"g¦H‘ˆ/$;×F*v²ÿ€Šü;“ÿÞHG‚ˆ13d¬#œîˆ™<êQM|¼ŒÿH¦@Rf„Ä‘!#ƒÈDBh‘i¤#çÉÇHr’Ω$c.‰Éâh21œìdp>‰˜Pв7¤<Œ)Oy›Tf•¬œ+ÿËXz*Žmš£-½5K¿Ôr—±Áåœt Ìkõ²/¿,fhŽ™—d*ó3̬‹3ŸI-M“š9r6y)Ì<s›‘Š&]®IÁ´M=ê‰WD Î…ˆs.ä” ˆ¨ÃžtNÄGídÈ;åâÿ̈µ±xßÉ0&“ùKˆÝ@L&2 |@gJ hÅb¦û j7AÁ†—4ÚOD%ŸØò©šnê›(Á¶4$õ ­ƒi~ àJëYO\ÖcS,ÉeúQiÖVz) R'KÌI>Ãã.&å‡c2]ékJÒ’j3&TZŒ¾Ä$ê(0hµ[y¨¦Ÿ!µyBk…„"ö >è,Á’8” v5ò[§Æ¼ªdŸdIæHCÔ<£€/n «óÖÅ<êHÍyñy†h‡¿ ¹uDÑ%˽Vt}õkA;Án¨hm¢Q°"qáA†þ†$ÈÿV¨qwýìe3:¡ÇC¸Å+ˆÄ*ZƒV,Éw‚¶åµ‰}­wžfö(t¶©wr[XÐÕ”žÓ-—w¢Ý§ ¬D*®Mª(”¢†ì„ï@ gÃðE=0\‹ &°¨ÍP‡ã+\aèAíweg°}5vªwÇ K<#òµû$ÂM™0Dja `˜)îðX>¼”kÄ=±ô®:—O MÅ.!±RL¬‘ `êÅ0N!{_ LìÇ@²‡Lä"ùÈH&²A…ã›DÆIiÀ@å*[ùÊXβ–·Ìå.{9ËU( ,'kfDZroR2€©1¯ÏÿÌ$2Rhœ ÀÍp#šy¥æ£¨€xsžK"ç£Ðù"(ô  ½çmõyѲlt¸ é[²˜!‰ÝHf‘œ19ì9!K<]Ýé†Ö!%¸’¨õWh£ð¨\ŸîHö4rjªelÕ)AkŠ)Ì—€±ÕEI‘κÁt)B'øa– ¢ì¸ùë_âz"¤!ÄkC|ñ]8žîÄ `›Ÿ†&Îá‹{]:`s”±rW»ØFdκÁ% Ùì¶¶¹Aí}±ZÒvëóbcòõ®xCS€‹Ø)µ…oDÌ‘Àç„ Ä…yÌ7ñÔ5ƒ‡ Ô%È’z&±½(?ÿ\[‹Ä~]~wóïAFëk“ȧé}ôSó×Ûòøñ„~A´_à˜hox€ŸNÍrã€Öœ×Àù%)cÎKzÁ‚æ´R?ú·ö•4ðnØ>ãx95ÿÁ׌…®àÉ^{þ©9i´,ƒ¾úÖŸ~ çlž`Hù]ýׯ·BȇÐó".c9Ã÷"äz¬3oâå/Ëöry#4êq0N5¯SBxpFuBÜ£F„Này”tâÁ=|ñ6 Øz.”²/Vo¦æVá1&aƒ‚,H.‚txi 1‚—‚&D1kA„/±0=hM}6oØç…w EG‡')R»ÖHh±öo>XiÄQ…TBi`L_X†¨€RD†h¸Lj8Fl؆Ðô†x‡rXM;b‡w˜ML¸‡¾!†@qh~x€ø‚8ˆ5Qˆ>qˆˆ8Šÿ،؈ Ó‡’È‘X‰1F‡}¤‡š8—¸™ø‰pt†¤ˆœ(HžxŠyŠ:1Ьx®˜°‹ŒfжH,¸˜‹e’Ї´Š¼8b¾ÈHÀH4xç1]YÈÐ…ƒ6‹8ÁˆâáŒz2#—²Œy7qˆïqQc%`cOmsP§¥$H\á5þB ‚Q%Ñv@pã]¥†Üh‡è!Mâ#®sSKRnâáX´[y³S0eOYU;èVBÞÁ9võ ‚†÷XÒ~7ÌãA¬U;ÞÑwÍza‚OYü‡sX*¥p6‘4Q‘5RXxåty9¯ãVê(Kÿ¢RSSG>xáX)Ù†,9.É='psu52]³ø´V8ÝYqq@/éX—Ò>ö8Œ‘TŒ(!6g•Uϳ\ºçþá#RjÊøÓÖ\è!6ksAº#‘^iI`ŒL1”2Q‹zù|~Ù(€é ƒÉv†y˜ ‘˜/±˜ agà˜ù-w¹Iy©læ(—ù˜™9’é 0e_–šª¹š¬¹ea*¡9šQš->–d¸™›º¹›E¶d˜B›sœ+A™ ¡RŽ"œÁ¹™ Ô™9Ñ€œ¤(Aœ qÒÊYJÌ)›Bq&AÜ)ÞÿÙÛž?1ž$Á-9c&Ó“ñPz' •˜„ž#a->F9#Ñ=ÁŸ!’qa@èg¬dŸ"ñ,HD ¶2ø·21dÆC r8iC8DCƒÃN=D~Eô„ZCö !*}$šC 78þÒ6W¢F¢„ !ñ, ãD´~P4^2B:ŠÓjT%÷:ûò6:ÚzÒ6cs.ƒOBªQ_Ä£¯Ó<®ã~ƒv®ó1F„šÖ:Q :žUü7C÷G0Z`I?W—jÍ“8‚‘<3#tø÷91w2ÕÖ$Q¨p&¤i‚×$Íó<\§XbjÓè7:%2µW0ú2ƒ'ÿàcÏÓžÖ¶;—=Q8IeúÇâBw—7ò1&tšåuóª…~^·uì šµ!C£|?Õ©/45V—¦7nÇpÎçEC‚WSŸjY8§}::•ú3¦Ý™ª–róAD}^"ùäñ¬ƒƒ@Y£@ñ8+@j¥phšl­§|­W«eG,³2þDû1²ZVãD°U0±Ê€þwÝ‘;Kq©q,~Mƒ@±%4UƒOD»7sâÕqõ#oc?#…Ežæ<Z—2“¥}¯ÉQ5\91ƒ£ZÃ}y5 LbmZ#¾·Ž;e~L…ÁC`ä…8+ªrÿÅp>çAÿ`0Ô 4Á¯á¯äbN¦³>ƒ3?E;&Íq°£1cÂFï’Ö‘F‚r3a"1;j8íc2b1cb2abµ8ç´ëÃP³Ž‚ñPCŸFQ0u#Ê•ìaÕñ<ù1t¹\Y‰’ð!] º‰»cpóáK‘“Ú“6ų°*õUØ5ÝDn%—‚‹Š¹þF7ÊúJy)vwÈ*5¬•WŸqH³X–õ“(É<œu²2´žÑs!‡¼+<&Óº®U]cõ’ 3̳T爡KKå g:u²ÝQ“Y¹®¹ÓÅW¯3»+ƒAvöµ†ÿK‰i¶ •T•1UQÍQ1^³7ÌqW)P1¼×1?Û¼¾ô¼±è!¦ú¤çi¿È„¿±¸%ê¸Ûlž2Qf¤©†ù!·¼§j¸&¡3xjÑŒá”-¡»\€™ëÅ€{¢´Ÿ{hK!§[0«{!׿Á›³€ B·PS4Y“ðaqš“?îÈ:êtŒ:Ü%çè50å/ùáÎ÷:Ã=Í1B;lÀ0L(€)±©BÜC>qñ¢85Õ¾Le¹\RBŹ…!uå#¬ª ‚Au•~0å{÷ƒP KŲ¹nÑÇ~œ›°{ḄWÉ5Aÿ#’§6%yÆ>v"ÃZÇ;°^¹’¤'B¼…/ŒB*€\ʦl* ÆG·Ó%¹Ì#“Š,<:y!Hu­%4 ©Â°” 0¸ðñ\|q)ŠÃa)ü¡\Å ²¦ÓU,ÂIùS² 4R•äq•'DƒüCÆvAÞ¦Â>G£6¬u!a¢²ÀUWÉì˼ÁÔñ( °Àq?íã#Ld–’m —íc»¥¶u3g!Þ$¬;´ª–FcQÜÿñÎlšBÏâ[ÅM!å¿ÍtÀ]¿‡kfÀDÜAWF.µngă Á%}f!cFÌÿ8ÀA B>þrj ºŒ«c1 c¹*ntWë(B²£ÐÓlLËmã2ÄÖ½3DDÞÆD^0U%í–%îR®zÔ"¶Q¤ÇŠƒ¦vZp¡e4 ç>4·@q6æ#Öñqê¹çÃAE:P‰V¥xÑÖ=.Ä"t¨äj_Kw®O÷4v·<æ*rùÑ%#ôSVyÃ;ÙCÁ·è׋F»ç±÷õŒ×E+#²’‡4Ng4ÎsÒoÚ­¹§§hã<ñ „'ýÕš=høC ˆC»Ë–=Í×Ï+;}­@™óE§G²ø£o¼c4œ3>YD®@]Û?ᢠ¶W¯Á×o3o}Ø@ÿHvUâ€0È#Ä=1ÒÏõ$^)+wÕzá]VJ˜¬µ8X˜6¸9ŽÁ11Í£hŠÆ#£4ÌÑ™‡F!–Öà3‹Yø—¢%JC&•Ñ£àÛ77o1BEjÓ²ÈÑÒäÑ" ù±8cW Fj£C"$Q ¸Ô¡ßå(˜ýýE2»X($[HÛ ^L²RósSæ±!åø]—Kž<ŒC>…þq“w8ßuFâ!¡·7r)/"VmW!ß¡µ;43 Z‰±¢ÑÓa_*inþ4ÍXÊZ¤WuµösoE"RBÊk_inå}ÿ¡6¬7M&òåu.4q~þíw~õÍ5ÖÇäÁ”oUOSüË’í½7%µC·•Np{9îo÷C Ñê ¡6 !µ¨F³1ÌÑ>O%Pi»ŽìB¿Vû=T¬t±XB2YÝö.Èc€";&Ýq%È@ ÷.r“_¢í>;›ÝùÓwÓ¨0 ÝIaµÝÎ]>ó1ZS0>V@ì”!)P.š—3×<û²$èt•_¢9à–@tUïõ÷[bZëR’ç*‘Z‘¾-û群[>\9te20’=èÇŸõè5VÆØ>B#ÏvHuvÿï O) ÿGI@Wÿë‰óp#£¸kÊ@º¦tAý<Ö¡8}{L8ìÇ" T¾Ö/Üî›yé¥ñò+aRßIÓ$ÄC6 Y ¥|sw*³ßÁ&ϳ7."y#ãÍ=5‚ÑEžàöîÞî}ÚòÆRõ*q€÷I‘4Ý3A 4&|úB®£ŸœºÜ]=0&´¤ÉèD‚,3Å“ßÅÿ®!Tø²øq„vï,|¿{ùY¸Áøöš¨˜">N¡´â(¥LÄ~$ñ>´þd¯?¿¬*Â?üÄ_ü¨²á õû&1û¤Ïüê¥ü!Ñ+0úµ;nÔÅÉ8ÿg¾q6AµQ3KK!0àúôûüý$¡÷ì/?]]¾:úYœÙfìáŸãÑè”XQÐàAƒ 4|x€ÐáÃ#*@¤XpAˆŠ5näØÑãG%lYÒäÉ‚&H¢dÙÒ¥Á' 2T0Â`‰29¬ !2‡ Wœ€Z4ă0kæ|˜µÁÄ%‡^qZÂÿÓOUo•,áÁDÊ+G–¼zó ËãòeÞä]çÑ¥Ogù£ð­¶žž™¢¨‚0VÐ0œóÐɬUÀ®ä 8Œ6ó ²ì@ VDNÔŠZ¡«! @ µ‚ŒÌ¦ ,µÈâÀÈ#çCÍ <¨„’#¯(%¨o õN0* <›òÈ“óh9 ãdŽCº0ØL¾¼¬{IOƒ\ª¾Œ$J¨µ<*²þªÿË2§Eó8  ‹² ÃÈ€B_¬@>Wø€ XÔ‘A¡³p…N?} ?ðŒÂ´ .Iƒ-½Ëx“ *Ëd5­4›RE+À7g”sغ蔫½-¯¾®;¡>ÒthY«®ãT&2j0) Ò`­òŽÓÀLϰÕ°;‘ÛÚ® áƒMT¸ÚÌKAF;S #`ç‚JVØž• Ò LáÌ #8¡¡HûÀ±£Àƒ,"­b*8‡!^U"¨Þ-(´tëÛØ0Is«*--}€28ðk«\ x¸U/$öæbW¢‹1T S¨R ´´¿4x° ;«T¸kÒ½B]ҽȂÿŒ´‚É0-ä°mX3©Cм–%È2íB-º!Ç‚ª³µÜô×ÓQ]+Z@1x÷§½U-«ƒë[ƒ©Óàð=ÄPp¬3³]®nÃAfÅíɳÄE°Ò,£yW«ßŽàÄùt–Œ}É2žm’ÈçÚ*ËÔÿÂÚTKQÅä®O@ þÛ:ífRíÁšv÷ €÷äóc¤(3Ñ€ðY¦õ‹Œ3ùJûIn¹bB]ÎCSX1Äx¶ù{ôKR½%¡Á05²®×H  ôŠþøéËLê‘;r hqgeGBPЄ'TQ†4·úßÙ¼c1‡ Œ[TBÒc$U£¼È(}ªßê¦ÿ‘Ì $¦Û` 3²>–­4›é`´"mñ)2,Üe*@Ÿ©%D& ËÊd²<Îx§,,ãÚª òÂVñ02äÒÑ ‚Úø¨^§BÐŒgB,n„Yäbat&-i ?Z± bd*2"¥!c”ÀŽ&’ÀL„g™É  ²U&Õf—Ž/U•ÀбeI ÎS¢·™¥g1¡ÁIp³Œ˜¯‹“¼Ù)iB¢DRæùÊPRPœX(^qÝ(Õ‚•£ˆ(bñÊAܢʞŒ¦,­4ÊZ®Ò§ãàdPiáÚWNdÊ|Ò‰è#Ì0=¢7”dfIÚÒ¹*BE9Ç’—Ü`&QëÿQs#b3fuÈ÷½˜¤àE ÉfH¤W‚CMDhxÖCôä½èLS›ß³æI>`§yrD0tAg £93!s^ßê™O­þŒ«<~{LðÔÂ&t-‚3EÍ%ƒòEžùÄY=9úÑôç9ÑÌReýlA÷ËÍÀŒ™ÁG!–Üj"›îQm/ÝéH‹Ò?æl¤ròèP:,AF|“Áï0âºxÄD³Ï«Ó)(þ§_diUdRú–aåsªFÛyÔa­k•Îp|ä˜Ã@%€²Ã_ZxF¿ÔìΧCV]Y ´LéaÓ©Ž8 qõ¬lÍZûX½ ‡ÿ;¯’P[Åšê0«ó¡¨…p+¢`ègÁ y¤¸ÏBª 0#R,dÓúEׯ¶9ÃŽdêœ;¶”Œœ¹”§¤×Æ­Q­I7äÑý6%ìLfj‹|ÌohƒÜ Ås±²l©{ݺ,THHQe/KùðΔa9 CÔR(dŸÉhs„ºà–$Ãæ°\.ÜaõYÄ#&ñK>\âŽhÅ+f±ANÜ⊨Æ3ñ‹iAßXÇ,¶ñ޽èc ·¸Ç>–q Ù!ï¸ÈGÿf2Z“¬ã%7YÊ}ò£/y^1 /™‚]SÐ&4Š MI @Ò’F`G>ÍE_²Ñ%~ô$#Ý B…z™žç¦IÜi=Åun `$f)#øÀ«sû€W×'Ò\Ëíqm]ÛèÕ÷”t7IESÕrµ°Ä4ØïCެ£-ªh}(1Ø2lý6¹&¦'àv¤Ç=Ò”óØ`>3“—½:Ÿ¡ìڤŕµ%âíA¾z0Àþô ¬€Ó4D߈‰–ÿeDÕêuO2Ù ~·Kœy¨õ®M´Ã’¤§&„Ú5B€ì ê`§ ÂÎn87¼%wvX¢ mÕØ(ä ˜wÑ2þx%&Ò› è¼ý1™=ÅL$GΪOÞÅ…wXåÕñŒo¬ò wH,r :W&ΰh3QoQì—uÖ Ø0¹yÏÑQþç›]íƒn÷‘—ž¡$}í””û†ßž¡ îsGvÛ|wêDZÒ{ç{ú¯`8à‹g|ãÿxÈG^ò“§|å!ÿ€IÞï…êáÜÅ[^ô£'}é%Ì`@ç¯ëyý~:˜ôê[ïú×oȲßêYÿ{ûÂ>¿¼wŽ ð{à_÷DN»QQpûä+?åÍÿ:C°ü ·%Ú?˜ö=¤ÉÁ„_û©pô)"|û޹=p°\.ý’÷WÔâGÌx2S#þø™æßú±;fïiîR ° ®‰/ð2¥žˆªÿð$ƒˆ¥[¥PÒ¢#Xi9¬X‘%Pb%{@°x¥žH¥&B´ã?ˆð¿ëê2¿ ̸¤ŠC"`yAàü.ôš ÊÎ2ŒÌ žãÒLˆâŒçR®ë‰ ±@ l•Wù²R éa §ÀžXŒX'éÁ‰ð˜x7YÞpÃpÿ“rŒ¦b™ÃÀ¿|ÄÁ™!·±‰˜µèªwtH”-I|:©Ò‚ ¹'— qjI˜œ(êÎi–렩„º XÁÅÁˆq)HµH¨š± ÏÁÁ¹Ž Œð“˜¬(Ç© ¾9¢ëô“„Ç`ô¦Í*3ýèJ”ŒG.›G¸4c›² !ˇHÉØ">·l2¸t-¹œË#«KȺK¼ 2½|,¾ìKûKÆ LÁÔ1Âd+óÍ|ÂMÿß”>´εÎyNã¤.äÔ&å\ÎØjNjzNèD²Ý¤³Þ¬N5“ÎK¢Níd+î¤$ïüN'»N=ËN.z¯P£DãDÛ¥ñ#Ï`ùÊ£IÓGJ{ˆ÷C ޼I«4Žˆ?í ÏIOò¶‰ÀБ¥þPS409è$Ð.’½Åp6Ãx5)yµ¢P'Y‘W{US'À5+y8UkÁƒ ƒ5äh#Xë8˜)Êøµ`“Qb;Ñï´P.’=g 87½€‚i#âˆ5ÄÀ ö›’-œ¶!M 'q‚{Ÿtë4™6 ù!m*B|µ!É8ÒÐŽmÓ¹!M·+íQó,4ÿôt Qé8*µ û”¸X«5è!Œ6Ú·‰6'áSe:"\éÁÒ ·js9/PÙ\‰Ó‚Œ’kÄáôÑ,Ò´¸8Å£y‹µÑ0š!.¡À‰kS'WkPþ$UÜx¸9¥Qƒ0$˜Ù¸`âÏ$¥Ðå”T,¢Tá°Ô±‘P¹Q™‘€m£¨YµÒ)ih‹4S˜Y5þ„9g-ÔU5ÒðÃÒ¨?œ:Y=8£Ð5u´6Ͱ­‚0"šòžCQ#Â)©S&ΈCñ #Š:m Îx{MÌ®s‘ÂPwݺ„Ù |USú”OA³ULW…¥Ëpå4‡}ؼŒØÿS›X.: XœaØ2Ð0> ØXŽ•3‹U6Œå¢ ´‘-Y ñØjJÙ,¢½IkY—•˜5¼XžíYŸýY  Z¡Z¢-Z£ ZH=àʛՋœEŸë›Zª­Z«½Z¬ÍZ­ÝZ®½Ú H=›mZ?S3ýˆ¯eY’[ ;Y†“Yd[Ú´UÛµMXÆ2°•[+N¼-³§¥'·Ý[ë[ÔI3ëc[| îû¾'ŠÏê›Jʼnò;IÁ=õ[£öƒ?¦- ­¸´ˆ´Ëíˆú™JÆ­ý3ÜL›ÜŽrÛDÀ ¦ä@Sú‰¬4_B/d¥³° Ì é¹@9å%ÿ|%«ð@aA¯©ÀŠ0AÁDÝ›aÁ­x«ß*˜)œAÚàŠé½rä¬lÙAåòAëxB!Ì "ì^#,Æ$¼^ÒÒ›*ÄS׸í‹ÁÁ0ŽÜp ßH-äB·t^bé²1,W–R Ê@CÃB•5äŒ6¸7,Œ8ôÆx:´‰;Dˆ<œA­y?Œ^"„àAü6CL)öHDÏXÄIi^Óµ;™ÄÜ’^\ž¸ºƒàDàðŽOäBè R”Q”žTEW*9ÎzÅVÅ4ÌÓ¬;ÅŠ ûÐE$áÅSÑ_²äßׯ%aFû˜!d|•à‘ªbtF€FTq¦(d•…ò ©ÂFÿðÐÆ®ßn¬pl’š$G46àsŒtÔ–OYÇvdPÉMa [I !F€´‰ÜG4òGBöšùHŒÈ*9ȱQÈä,È€ä͈ÈĘȤ©È—ÁH¦ÐH8JÈŒYã‘4¯Baº- ¨(™ò¸ÉÚˆIÕ¸¾šìYö˜[ÞÉëkÉJ”šäe£” ]VJ@éÂqÊž» t\ª|Ñ ¬Ž­0|ÎçJÚçØû[V°è8kè&Ø€®}hˆŽh‰žh0ŠŽh 8Pè…–€£íhþhi‘þè¾Ñh“>i”Ni•^i–ni—~i˜Žé ;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveCanvas1.gif0000644000000000000000000002427710520670125020733 0ustar GIF89aâ&÷ $$$(((000444888<<<@@@HHHPPPUUUYYY]]]aaaeeeiiiqqquuuyyy}}}………‘‘‘•••¡¡¡¥¥¥®®®²²²¶¶¶ººº¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,â&ÿ]H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´iÏ$¢JJµªÕ«X³jÝʵ«×«+œŠK䊨]˶­Û·pãÊK·®Ý»p d(Ë·¯ß‡.ü]Ù‰Áˆ÷=pB1J KžŒ´@ Ê$!cÞÌ™§åÎ 5ƒMúåçÒE£^ÍZäéÖUÞM»âëÚeãÞÍáíÞ u¾û7q„Â+gm|9Áä£MH—ŽÂyïæÖ]@nj ‡ÿ_0±{vÇØ­o§¼ÀÀw¦W—Øþ¼âôÎןDÑÞ€àßwH  JàB€íyç‚,p˜ ´·€ .X à&ø·!xÞ^Q yØaŠñ…çž}ƒá·œ~&Q¨¨ !x°   ºÐ^T’Ÿ id€ zž,è¤t! (¢  ‚LYå•Yº×Þa0þ%£r4–ä#As)!‡EèBj’g'ŸgB…ùh`|J èžjºät…Z衉. h}mºyY¦ÚEÓ€,à€v.ªç¥~V¨ Jê§¡"Rÿgi£ï‘8† (h |³:É©_o'Iz`  zVâ9*y—FÉA”cJ¡„ŽšAp€`³‡Mê#x š.Œ¦ ÜzKf¯‡þÊW°Ä K’† ¢Ë_u(Èwâû«:€¡ .ˆnªºð¯ ³»€üUX°@ ñ{M\ñµÊ;½ÃÙ‹S¶&·ìÛ¦™ª|“%»ló@('óÍ<ë”so; Õ‚¨=g÷3oA …D­ÜÑ»%Ô²0íôqPã&5P ˆWuÓWs›€×Ùh§}W^‡ÇÀØaÏ–umDðÕÝxçíÕ´^[ÿ7nsÓ¶õOˆç÷ßI·›1. ó„ ’ølƒû$Á׈Wdˆ.ù@‹džA¥ ÄrAå’àçH—Ö9O-4vçô9ºd5“ަ¥n§ä9ŽêåpÛ7;îG¥Hæwr∪£èeJç¡ /º ä8ü Æ/ǯ‡{kqšÀ ‡ä8Fó?±K*°¡Æ—çBÃG)Оö’«ÿ‘gMäÊ€à“%É‚B“–ÁqMÇ–®ذU¹&yç¡Q–Xu»Žðg#'$ÃÄ$ø­äE °¤"âQ) ) Q ÇT® ê.B  ÿø€;q)\´z¾¢´(AUˆ‡8VHð¢þŠFôGDaèxÙ‹ u».fCèb—¨Tà~MYè •@ØÈ*D Êšœâš9ˆÛ £ iGŠu‘hcÌ@uX‚.꫎$b¤#…®* Œ£¢æÃ1¢ Gÿ‘RR†8$î)®>Ô à“±:ëRîÁ‘Æô#ˆªUO4ežH„ ä]ÑS QÁ«,f‚ê’&ö ¹kSMš“ŒµÅ[)J?òÓ4Y1 8  ª©º.à‚  ÆU &½Ïè‘ ø‚k±ñœÆä¦w<€ÿÏXJƒšÎa$”® ¥óZéâ^¬ZÈ¢T‹I}2‰•Ê@u«GF„—øN&ñZ}*•‰ È(_rJ?ç*¨Ä(×!#ah, ô79ð©i°€0¹º`„ä!ÁæCž'A§t2&Ñ>JY4Ö¾Æsa³PH5ÒÿHä < ˆýe §¹/8ÕH&jmU”kUHTݹXuHÆŸ4_ØÄ˜èDæ’édØäÏÇÓ±¸bŒb~ ˜IcÌßFª;Ÿ¢ìÈOlZ2²Ð”ëÈjIÑL±ä©á:?ëò˜IªD oPª#!XÅiÿŠNb¢3i‘zB‚:“—Ì€ZuK3Ñy«…<®ËÆÍzd}¬ÑA½ Û=…ò|£ââ몛P‘PÕEfEX•Ö±º5 /€ìº¡í··åÀÁÔ$*U B“@äëÓ.¢V¾¨efðläÒŸ*ˆ ½eÓmm&©³Â„Ù‘î@M@K~í¥C\€¤&J‚ ±—Æ# Nç|…±x j¡è IžØAë”T -E½(‹G-ÄŽglưº8¿ªMQÁóYs© ¶cÔ¶ÑHÿÑóž aõ4ö D-øò§¿ïÄÕ ó)ÓÇŠtú‹œâð;º5wÙÿËßI3AH0˨@f–~Á×âÊI,•«œš'èÇUG `>³*)œç2ƒïÎý[ @pI#ä-0tW£p bŽpN†8e‚(”.È©SM @™ÆY•ós僄€­‰±N€[j „Õñ5€=„çÕ±Þ4j–WêÎ[<Äî´S­¯![Ù¥av³ÅR¸¶yûÛà·¸ÇMîð ÜÖ&À¬gTëm»{!J*€¡g‡gÞZAÛ ˆmÒhûÝNã¾"pz¤âɲ ú=š¼g8A"nðç@áa8hþp›µà~ÈÇC> ÔOãÿáxÇWžñuéÝ,¯ˆàÇëŽà:C@|äCÔªZ&$®¤:‰¤à'%ó!(çŒÊßýi=Ë/}Fb*Š’Ò”Y!ü!ÚUOAŸ„<žFºË…ó˜Ó@£YÚ›W\‡€f{Q$»F¡ç]²fïƒ_ǼÉö5,†4«Î?ÿ§ö=ÑL_¿µ3ºÞžx´ð·}ôŽã-ùÂ+ð› ¾ÀèÍp*‘ ;•¨ØivŒ¤¶‰G€–=ûª¦hM)¡e-‚´W©ím ÅBÞ!$Õ%!3¦^¦5|ÖbP×1ûr`at0Òc±åZX%‚QH|ú#)FFüT`-•*å… h,@&\"!1(!)47Vs ±„“Ñ„Sö"H!ÇC!jç2!¢‚/ÿ@y…0!ó.%C! P ÃC…”7c‡e·U\*ßw`ª(€‘¤#^Œá¤^R? ±GמCK7xTʈ_Ú{!¦AYljœY *G ?ìw†FúÂw£ÓŠEè"eÿc 5sy„uWwF3œyÿ#—|XŒ|÷84óŽÿ·/‚x£2:@4”¨F!x!¥{™¦?¡r‡…(ƒ¢?rZöE»÷uæó#ÞÑ$Båu{¢ ¨wîSö5OÎGaP·Qv4cNå[îC"²z¥u‘xº§šxK5*ÿ¡†°Ç £H#£‘X‡‘V|²©ÿs<ö‰¤C‚ïcPRCI8*T[²§#Ä$îówxäsb¬%O.ôîQ~«g$zÓÄÓ¡èSÐ –žêW]îÁ0V¢;%X-ÈGçP "%€—!v¯æRGOÆ«ABVÇ„~ÝE…$XÀ~;Ø9²¬³S d.Þòwiå 劦Ò5Ôÿ°µSWX(5d]ªÃ8uƒ§r{_jú`i$¢[¥x@Ž“xÍÈ1²¸ƒ˜M? µtÒ³ùû¿XÀÑ5À<üëþ›À>±À-ÑÀìÌi<Ábs¼Ü&ÌÛëgŠuüCR.¹ÁÑÁ+±½uÒàVèEb£wRüsÒtáÉ.$ÒE¥Ãs€T_ŠäEB²Â2¬‹ü°2P”–‹xqæ*iibò›ØSD’[wÄãHÃE!•XÅEeck VÕ!@ðx'<6š^\¼l5ìI)@ËBŠÞ¡!>z)²>âµE„ˆ½‚˜qü2Iìþÿ&O©/ñ”PrÙÃ,«Nœy…|Œ‡\(¬*¼·¡!v—C¯—†º@ïÊàRR˂əÜr‰Ü& ?:)“wUEˆ6³(=I“6Ù¥­¼É)!ÁÁÀÙÊ'ÌQÇ8ÁiÌ‹õ&†úÒŠ Ñ©¾«Ì;kÎlE!Q!© c aj•«Í:QÐÍê3Ça,IxyŽW Žvs<~J1>·xŸ%µjgÏÞb§Åxª™œ°ÎìÜ(w[/}¨=¸8F "LÂtsF›!{ñ<ØTѷ׆=x¡Î:ñâ±Ð ½7&Ò1c_ª}9ÿ„(dD¨ÓG-DDÓ3Dô[GšüF}ÔHÔJ½ÔLÝÔNýÔK½9^£Ò+}×cˆr>1}TmD†f.]T¯ö5Njø"ƒd‹dwm¨Dä°P×r=×tÝÔàmàο¬×…âgFGj€Ù"¦ÿäÒ—D…R‹ZgMœ/ÂO#ÄÑ!qÐ!má‘×U w²]H‹0 AÂ…œ}0nδx¶ŠM"\ˆˆEÂ/VÒYÙ|íÌ>:ÔÙì`Ù—­È|’m-Û ½Û&±t!ÀäiéHg'žc¬!G¬+Ü%¡r·¶ #ÁŒD \ju ÿ±dD/»Ô&m{yP•ófÕ>ç¨Þ?“†–NÁÃ&‘3ð­g…[Ð(!öe+nÖe,€*«J¾ãŽÎh0ä ÜJwÞat†=ÿbçdĦÕDµ§óR2öiFü$veç£,â:Øø"B%X-Ä*BÖUç‚AZÞ#Áqûç@ßI@*•FáeÜkÅ´ÐbµÏÍ1á(*^Ås.¢š>Œ9c¿÷?/mã£R’r(:=«UbxL,æË£ëàÞá)Š4cT ËcÅåBŸeTcÕ^INšÅ¬;刢äY¤’V„‹õ~úÅ:f•LÄÿ5A‡±S¬õ¥.Êã"ápë0±e$o§ÏƒI \éƒ,jøåOµ_ßÁ06TÎW>®`³uWµÑ£:O¦ÙNî'wæd6Ƈ þÊ[¨wA1¬!Z¤(8Ë{ë넨 «2cï³§L2_2û|¡E4t<ËÎZÌÅ0ÍŽ“aT.`Í*‚9©é”Bdlšë`ܰ%j^´ÃvÄ[dä4FûU<2™´_¢F~G—„_‹·ÕÄV$~˜ÔÝÊr‘ÂÌvÞŒ´_G‹.74Ýf~®U .Ôç.nîŒõ”'ŽNNd> o»ÙŸÛΫë*'ïÚ-8ÿÏ„)óØ;óXó6ß½8?:¿óâÛóøøó@¾,_ô aFÎ8Œ_×É—Goó †e]Ṟ:ÙC”BßDïÀkò8=¹,œ—#5ùh´¬“=ùD»ü­‹6òíõ-ß=›#>zR«L|^Bàq¹• ÌL‚2&^ÂÌET÷)ñòÑÛY`¢/|R›'rNËB1…‘´ùÞã$1•—S5„@nÿ†ïˆŸõ±*‚R÷Ý%„/9dÓ'ÆØµä* !òÂ%ú1úYœù aò›Î©úMöU2X@@PXÀ ž\aCª“`ÇKˆ„]Pa\8Ñ@ $°E0€ö¦sçLðí !…êBÁ„å€$ò $9D¨F„FìÐ…!‹„R…!_Ä²É ‡Ä2KòÀ'T0hÉ&-€ŽM„´tÑ„êðͧîÌ)<§LÀv;s% °ÀBðÿÓ7•\0À€ÏÂ}Z€ q4¾F)0AõèÏ¿+S<ÌÀÆWõI4\OF 4TÔ<àoüÖS?…&”@Õs]ÀX]`±Ö•$˜ïØb8t¥ p=HH¨oÕZ?$ÁPjÔÐ hô` çÛULÔôïÁ¯uTÁF =hCyë}”GG-0¿Ì€ÇB…ÏÐWÚð òüœµ6¬] ÂR=0Á€ãŠƒÑÅ2ä— \äŽ=h  b4À·ª#º‰‘e8AÈQßšÛöFŸd>ó ÍÏmæà×ãX˜¸L;ót×&>›’×zW"ÿï^;`t%n¤:½X R؃~Í$ÿ”Né2V=Hg&;ÃMgæ8¡út‹ÑNd1ÃY5<ˆ #5³¾…[L0Aß<ºé*'$WQ:ï5ˆïƒ´ 9·Rµ…\ kíû^v]`ði”¢fjêªs›øÛ üln¼ç+¸î ,]YÈ!uk›SKÛ. Î{­éÍË !¹kc/Ósãwâ)´±8Ìã,ÙNQÀ8׃ËV?è7Ç…ûŽã`â¹…füZ"~_Æ;ôÀæ3¶{6ïPO^¯\Ì7¢[‡ÆS·€mŠP¼)N •Þô&WÀ)˜<]m7sMÓ$ÿ @½ˆ&À~B0"°{#,˜Á ˜ ùp N0AßV7ï™`D)œ€çù [!+ {ò7%•‰F¤®–ø/ чv‘‡|3:§ù&ªÓbƒu§Õ,Ëã|ø6&}lŒÐ‘¡²¸‚â4!K”™ª4 bpŒ ¸Óœ–,e‚äQ‚RåÊüByÉ/ RYnZt(´ þyq$\Ô¤9à´o!Ô+гØr¿‡d²“ áä*ýW3ûPO¥\ZTØÓ¹(Í T©K`%—Á¼H+÷R€²S™Âüå2'bL½DE*Ítf5K2Lkÿª…—¢`’™Mpš›áLÈ Àt¦Sëdg;ÝùNxÆSžíL€`¾IN|jdœù´@òøO€T %hA zP„”)@òùP}R3ŸÐ¼ËæÒPˆf#ûÄ'EáB`T£#­GÉéQ·´%iK'bÒp¢´--piM%SpÊ4!ÿÊMMJ'’â ’ô‰…2=Œ©6í N³©S#ù„CeÉKB¶_…NW Éî„”¤‹`î’LõŠS­ UÅÈÉc®æè‚$²lqÑqPð±Éõ~üâjqØj¤åe€8;B‹f¹!ƒì5s¥â‘;g3$"„ÿ«Ícuަ?üàÊGdmªD;ºMx)7:¤¢Â|ó¢)ÊIJíÅiFsÕHŽA ‹C> Œè_>9%a=§…Õj Y…ª™ÐÙ±SˆVÅ;ß4 µ TPV2Fq³N1k5¡ª¿Å¡À=ËIà,}½Øë‰h¦¸»ýÈRËY€Òê$#èj¨0ª.­ª°ålްäºo¦6Ä)óšˆ&øã´58ín—)Ýu&T¥Årå*e¼EQ£$Ûᕘ`Uß‚žûNö¨úÀ‡†ñ^Þ,µ&‘±ë†$¼ŸtÄç>½‡‚-Λ£j)Ù ;*oZäÌlVd c…ÂËÿ´ð!U¦jaÉBËù^duœ¿…ÌRÚœd 4Èjõ7s·=®Èæ½ …FòË ™Ö7ƒ °LÉùÕB"E=ê…ë}Žƒ|“Ì]Ïž´ñàÉs£üJÌMJk‚]]ÄGKU‘U¦‹qGR7ZÒ©T&CÞúä[*SÁ‹ÂÜ¡CÓ ]¬Ú´·¨–)kÙ+Cèºû<€«c¹h–4Y¡7é2ÉIXÚéš®D$cûØX²kœØõl1Õ²:HºÒ°«#&ˆiIÊ^R’´Äèš HJb”Œt.5š×OY²2¡zŸßÚ”¡[wSÚML´Â¬-åj½íè˜ÚßOËÿ½ƒ‰V‚'\'&Âþðš0\—‡xÅY"qWRÜâ{ÙvH¸ôS‹ˆ;!àž0Às*ð×&:êwF$°L|"W{Ž(w‚ñUj<åoQ‰ñ0"ð(P%³ÍË&ó…›ü©(ß9kT¢£y5ì€óÑïðsAºèr»)Ñ}¢ß ðåô°nX¨F\égezÓEÂB ÐN¡„ÔB““¨•K€mûÑÚÆ£¨žLmg;Ú¨¦‚…6’Z‘þV 8á“༓:w{Z<|5y9ŠpXzbßæ!hma'³Ö<\¯â,ªQ£¿—޲'Ék’ò•ËåS€R(Ä_ÇÎÿ²2é4"æê9Oü=Ëh·Iì½8{Ú{ÅöX+ÐrÅ÷…y@mc÷ÓVtK%P>Á¼éW²P‚@WƵyä×îݶGŸ3õs¿*´¡…ÈC<¢’²|'åè?¹¾Q ž9ˆú3 »Â Aɹ‚ çë"è“?ÿñ0°˜@-ª@ | ü ôìÀè AÔAtŒÑ0Á§AÁ¼‹Ðˆ¿»pAwÁœ) ¤s ÔÜA°˜Á¿˜‹Ó l!$®#ŒyšB*¬B+d'Ø·–jB'ä @€À„C2,C3 (Æð5ìÂÖøÂÿ¹x?´XBöàB6ì 7¤*ÊÃï CŸ!ñ9…øÁ@„.-$8¨€„C&[C¶ðÜë±Ð® É¼‰pĹ :‹ˆ/2üæ ‰sqÀk«Nœˆ¡·kRDwcÄ´ð{Á·Yªy’Šðù*P-¬  $ûˆa÷2±Á¡ùù$”ÐCá CIÙÄÚ¦©†#¯£­ÝÀ?Ñ º´ûº±€”•"®c˜±ó ¾CFsr´•;E‹öà ù ˆù Z2$ÅJˆ¦a«& ,î¸=ºŽÜñÇT¹¶bù¨¬¹*mÑ;JFUÄ7V, ÿÚ³! y¹ä«F•X @ŸH»‹ ºå"ݳ˜ ù•Q= Ò²yé­qEÞ`0´ùЕl£ ÂsÉ€Ä×@®H›‰#Úµ•Эßê­ß FnDˆyŽéÈõ‰¤Ô²’­Äé2qªÈƒ»H’­Ñ<[”Ñ#rÀ—#ÒòË«Qµ„2«¹=!!Þa7iÝc¬ -âäò p“‰DÆ9„pñâ’fɯKbÄ/›TQ°ŽÄƒàÌ$ eÄ :4ËÚfdNfe^ffnfg~fhŽfižfj6‰€;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveApplet2.gif0000644000000000000000000002616210520670125020741 0ustar GIF89aŽ÷  $$$(((000888<<<@@@HHHPPPUUUYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶ººº¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,ŽÿUH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£JJµªÕ«X³jÝʵkNM`° Á«Ù³he6°à„ (PABˆ… ¤ÝË·¯B"îªÐ`XÞAB `11@YÄŒŠ@±YÁd¿ C£÷­‰ Xñ.âÔq! ÐCcR‹ðî·¤M¼8ÖÇL€à €­‚*P€ ¢¹ ?û]Û*Ìÿ5=¼^ãèÓ?­›º`ëªН¾ÀÝÆ$°µÝ³ëøæ©'à€G‘` d«Á'n TWVö5pž ªyç`xã± vØvTVpØA !Õ0k–f€rr‘+f(Peåy¨ãŽ3i`4*tðccÕ©¡ X°– ŽY€‚4y‘týÈã–\îD_—`†éT]·‰iæ™h¦©&š \špÆ9S জxæ™ÂÙù¦ž€ª¤\• j衈&ªè¢Œ6êè£F*©¡×çfú‘X,€p(°À¨¤–jꩨ¦ªêª¬¶êê«°’ÿZ€¥–F𧦸Z$ÖD€!˜­ æj,E%4Ð+–i~J›`ÇFëÐ ÀAœ&<+í¶ mp€·®™·ä"”Â@ (’ Vn '0°A¦ˆ`Â\MÐXŽïæYBÌêi¤BçáÛ/ž"$0‚¦øN€eˆ§‚„²Ùu°œ%  n ,¨@~øê5–|Ð^œf «)X꥖s5sÉ&Ÿ A¹Z¼nêžW3š,ˆ«ÅLp¯c¾G¿C‡™p¸™Z $ Á¾²±õ™ \kì#‚Ñ_ƒ)ÑbÍÚiwvÜtw¹vÝxó8wÞ|ÿh}.`Ñ‚nÜó®¸_)pÂâï‘W~–X®9Wˆoî9V ”ýùèO°0é¨?5Àã©·¾®Ç~|Òjûí¸ç®ûî¼÷îûïÀû>@¬Ë.fãœIíÆ›¹óhÒÙ¼˜„§ ûô`VæõØs©ý™ÜwÏã÷f†/¾Žä‹iþù¦æúìè>˜ðÇ?8ÜêÛ>þï3U&AàŸBê"ñ!4ûÜüºT?¡PhI< BRT@ &dE­[ —øüè2*Ëe0€#•;2 á D–,ñ  „ %‚Ë dHC äg†Òéÿ4¸%º.€ox3ó45K $T# 9Šj^DÁê¬åG(ˆ±,nñ= ØâÇr5Ï‘GFd‰d ¤Ìq6u9jªÃFBVôŒ@*¤Ç•…‚âiL 0–B^ƒ‚LÝwÇ•<† —|ÍnBvCÔ“nœD›¤ñK|,Èc.‰š'ž’?—Œ$ê&©£Jª„0DÒ".¯ó"Qî>YÛb 9ù°ø•Ö!…šXÌëàK±Ú-GœøÇA’P\²æK¶¼Å¼d(9Ä·<“?)jMyPC¤ràœw¹$v¤©@jR2'ÙX`ncÿ Í€å™`ÉÌ}ðs›ÍhZ Ì>‚Œ 1 ÌCGGKÙR ©h‡.ŠÑ¾h”C-Jñ:ª‘(¤D™œèHJ“¥D™UèXz— ¦Cy€¥fJÓ‰ØT=¨€P‡JÔ¢õ¨HMªR—ÊT¤Æ…V<íéC~šž 6õªXͪV•úTKgRª=ki ç«aUуS¡hM«ZÇjѪˆ ®r«šÚ ”åU¯Öû«hÖjœ¶²«@öÂÈÿ¢ÐÀ¸+"a‹ƒS ``i"Ñ×F4B˜r è¬BÚ8˜¬=„5T€o"¬VZ“%LOczÿ^Äb -C_„@ÒJt=ˆÖÉ­ØŠ¦^›@Y@ûÄë\œ}ÎÇ¢éb-žÐ¹Åâʲ¸G>&m=; ™ ‰9Ò¿$ÝxNQúvcʲ| b¢ìîu@;ÅΊ`A£ït-ðÞøêÖ¶¹2nhPŠÙÀ´vñ]€‚òh‰¡þ‘sæÝ‘ ¾A‡¿£Ü5à™Ÿ±K]¸+ZÜ,f.ðELÌîBó œƒTˆ£cÓÂ¥€JÃÐ,æ³ðdmgÅâÙ¶ ”jÀÇŽ)/cF¤±H¨³V6g ü˜§p ±–` 5È‹iIVŽYÿÉgS²‘LIÃl”?˜ ½üˆ4Ö3“d#4ãŠÉ~A©–v¦ZHG>qžÀÖÂS&I7æ¾ •ŽrãO»ˆA¢ ]ï¶LÇ­Í@Ô{a|¬a—K,æ0-Çg» ¨Wlジg. Ž:ÀXc–×° .H%¢¥¤á, •o¤¼DçÒÕÖK*}©™AÒ¸®™˜o¦ÈiÄüì>`!Í]\M‚"‹¸n¦ôÎÐŒ˜ÉÈ ³£þL™Ÿìa;VǺ­Ë#ì±gâËÃÉÞ+³ÙÝÁ<1ÞeÖÌáÓÂá6@½ž…‚41Ù”§O\Ò—Ÿ¦EÏ Ä²žÿ„Τ‹$¡;æ9A*¡Éïåݵl &p›Žòµ„Kâ-`•æ¤ÄœãÙÕ­Á؈<¸Üšuq•}Ò‰ÐW:ŸºÂ›Qª¿”ë]ß:Øù‚è¾ðuìO);_ÎŽö¦¨}/loûRÞž–¸Ë=)tG‹Ýï~”¼Ÿeï|/ŠßÍøÀeð^)¼áƒ‚ø®(~ñ?i'œÏŠç?“Ðceô¤¯‰é¯‚úÔÏdõVi½ëcûªÈ~ö/©=Unû–è~*¼ïýJ~/•à ?%ÄŠñ’äCeù>ñ /[#DˆHß^¿©h\" ¯”!áÞœÿóŸýƒ<í9·‰˜Ë ÎzÍgb奶@f­ ­Å”çúkƒþàLÇ;t#Ý~!Ä'æÙ—6ãçågòJªqF ¡õZ–D 6#‘5o¡^Ùñãg3’2C"r!Ç[„‚×1‚äAŒ„}b÷ÕÑN¯Ñ2?¢mÖ!1*2HàÔ0zуô1¤Ñ$3ÀV6H÷bE˜I<¸t–³€MÑ€ÅÅx¦ƒ6J>(J—ôñM&…HØ‚41ÏñÞ‡†¸A…•c…L…1( LMFø_&@>b  ]`H‚³æAG‡ùÿa •n‘K±ˆp‹9tø:=ÒÒlqI¬ÁÍå" ²E˜xˆ“q/o‘5™Ô\-÷Ô§!¢ÄŠ=øŠÐÑr2ØtGQ}̧›¨v˜¾È|Á˜Èõ‹qŒH‘Œ#1#UyÎxÐ(#00†WFq" ÜxwÞXàI*Û¸xçH+ò8ô+³B+ÚØ XU“Òþø“bV–% 3(¨! yï8é0#IûÈVUá ùy )ÉŒ5U‘…å‘n’”2%#Y!Cß§c¡a¯`Ñb²‘AqQ´ÿÕ1é@’1D…ÕÕ„ºÕ@ƒg?²“ ±i¾¥'6 õ]·ü¤%\C‡5D‰ÑRÉP;$êå.®6R•Ý–Xã²-H¢Op‰PÂWeRP…ø!Ð’xÒ”?aKqƒQ4g'VÑö•Œ3òŠè.N%ÕNA"’Öæ5žÕbðmRf*NPšddÑæ34¢ulYãšÄ_ôFÓe˜£)d¦iGñqa‡æ“Çå_6«ÅhòApÒ´œ9a>'h=S6KCa*@[ªec¸•cqžT%!ÿsÊUd¨žÊ%i9Vœž´ ~FŠÔ7dãI/©5Ÿ&d/À©)‚é¶tkÐQ^Ÿ51"àfêeJKw ã~³ö#;óaÏ<]$øDÐqüFOÒ„n1µæ¼ö1RÇ2Bã0s/YôD.s×yŸAc±4páJ"paÀ–[Y“¹`qGyŠ'„æ3i4D:²f8'1Î6F'$òr!dZËù Ð…lQê¤Ö6Huqñ¶¢àUhФ¼fA‚¡„æ@DPz¢TÆf ¶£MÖ£$\" ën1lõw: B*гYmvcžDˆÙÿ‰MÕ¥fàµ(PCó‡Mÿåq@J¶i;3ÿ•5µq©¼¶iªåjËÙ0#aC ¢5Ô‘˜·V1—!‡:z ¡GBò—”:dQ(×á«„«¥!ùFXâ#¯åZÑ$3Ä$·‘˱¬’BI3BBòO§šÖºiŠ˜­ÙùgÑÁq»êBÎê}ޱ1"¥LB$êsj«ág¹ñ†´u,ýÙ¶¤“I¦2—9ÊŸtšh"ÉûÊy°>U°fǰJ‘°;±° «[±q±9‘±Ë‹û± ²71²$‹&k(›²±²5Ѳ.K0K2ÿ;³Q³3q³8«³2Á³3ë³1´.+´0A´)k´/´$«´.Á´ë´-µ+µ,Aµkµ+µ«µ*Áµ ëµ)¶+¶(A¶"i¶'Á³€áWÑX%Xjk7»L$™–bho“@²3·%q³5¨pÑX€Ýã·$!³¬¡»ÑžõÝq°øÓ~¼$$z‘ä1H¨x¡ºq¸»vA!ˆ ’§cô…‚Mhè (0gšßD!K„sŒ$b„4•A–!>ˆ;€k_2J¢äG¸LÓ%ƒûo¦$F @à$AÈôa¸ØÓ»"ñ»1Faˆ/PC8%[ÿt¡TH3ó•dhÔ;=ÖØ‹!=ù"Áñ#–$$yñ0›k†–¾Qš®FhÒkΫ’±Ó¾ q³d’Š%?hð¥©?ø]Ђޑ#ôgb ú1O˜‰ºp‡³ŒÂu'Â@À¶Ä·É‹R‘-ÿÊ$¬wVá,1x(ì*ŒÃb)7,w9ÜÁ3ÄD\ÄFL+¶‚Ã3üwV!´â'-¼=VQ;PìŽKLxUA'U,ÃòêmB5VÜÅ&\zWœxcìAÌ;ü‹i¼…—§Y,L4SÁ¹Yvìu$p}&ÓÆxÖ®"¥AÈ“¡PqÈ ÿÅZDB«åâÇx^S®ÊzrÑGâJÎÊBóG$Z3AF1TÎÚ3$à#$к/Ó¬T(CQy$!teÁ’L”±«°,$4n=X”}\ÆŽ·˜¥’–§zrKJlï4³6l.ƒ¼ ×1å*ó2VªÏLn&¢“VÍ×áoJm‹x/Ð.#qáqÎ/l„ §æRdäáJX³Z<á#ÏÊ$+>´B>£5½<0-t%5d$‘ñ—4ɱw´6¦•Bh2éf0Joàô…ª5ψ™øÒ$*3ƒÝ¨qÒ¢Eò¼à¶sE4¶5\EY”y¨ÒæÙL-°3"1„!ïTi’ñ,öA!©í2œDAOXG{2Ýy4}vÑ [´Ø$ÏkJ³CªZ;­G‡DˆOÃ$ªQr¼¤.ZZ?$õË]¯ZfºlàdG_ÿlˆI6?&>fZ}`'ÇMY#a;ÑDˆîÙ »‹A¢¨¾¼I±½»[¾2A×±wÅâ4÷A•Š•ö2©QPŠñO1” õ?ãâ.åà—Éñ• ÕÑ\ÙœÁgݦáêr ÝÞ óK~¦ƒ5꣰íƒÐ$¦´”*áß±w–Ena$=±¹ú܆ÒA,~¹ôAÙãb” õqt¯wÛ¢Ç9&ßÚšË"­4ÐÔâš°!‚¦Íäë4É8^kœ)€-kNà ÕP>lŒX•U2ù4×P~z +#*²¹ü,ÆÂç¬HyyÎzgly…ÿ{‡Îˆ7Ç_ù«|ZO»è3á¶9{ÅnQæÎùÃÑDvjΙ¸”.wVÍxÅ4âÈ«,øéªäèn<ê2ñVx5x0vÕõDnñ1 Rh‡)Üžõ`«¡ÓEìŠ$c¦Ä©è»²‰V~çfÀÕ¨Æd$ºM¾ñd2“I÷Ù.æpߎq.ãÉ~ëÜ[•îê¾îNe; ©#¡Eh¦mK·ê*vë¨eÚý‘ƒüf„q(hî‘lxÀîŸðZÕU±ê)÷¢P¡j0ùqí*=¹†ÈÔååÑ×ù“<£ÈñDðuÝì0!3•w!âÊž b£VÓÛéÙSÿ„ݸA!›É7Ï3Í×1è:lò/!SÌ’w.ç¤Ô³Z+—#š¤1¹qÓáÜQobžE€®Væj ô-¡R‘°j³ZÏåèõ öaß߉n{gö€n9ó5K)6NRêrm ôƒµ½$°ÁÇbÕö‘ótÒæÁ+†>ï€ÍÜwì˜Q9' á0hÀáÈ%›ö»×:l_¦BÀʆb­q]Ûž%ê©:j¢ÿaKg»B½L¨†¡!1ÊÕ\©FÀ ÌïŸÃoÑÑδxÍ$bæj, c×ÜNÆ?Hî7"Ó¿3ÇqÊÿfxIÎ@ÿC!ô¬ªÅ¿Jê sÛÌÒ$ê‚¿8¹qEoPRì$-3ñ60îßíLòkÓ™4˜(¨P@BÅA .TÑ@ÃA 4 $("¡ 0L€ÈQ¡ L@AÐ Áƒ D0dÙò`.eΤYÓæMœ9uê°ÓçO A…%:ÔÀÁ‘ (P‘áQ 5X1pi¬’.U"¦ T¿†…ƒ¬ b]xq!lU@ȈáàÑs5¨<8DÕ”"¼ªˆ›–bÁ0‹.fܸhOÇ‘i¢°P'å!íJæÜ˜­Ã…G-<4Ñà"`KMè=Aàû 96aavÿ LhøJÕmè•*De‹Â@Ô•$–5 Ú¸‰*F‚´õ`íØ‰¿væÞ1dïœE~s¼ôhj^òÑÜOIä¶ @ÃðÚîÎaÀ‚ÚøBS® ˆI©×Ú…ð#"ölãkê{ˆ­ŒZ >&h/ë3é µ&@l*ŸsoEo¯ÅÅÆ[I„“,Bè$,@¿¶N2!8.8 (Æ¢Ž"aµ…|IP8I8†~4hI† :ŠÆØ¸$¬­ò¢ü) @Ȳ&OB¡¤à zR„(²ñJ†‚D)ÅíÔ³Å÷ JFŒ$½åØBk¼ ,Zÿ)Д*Ò€` Ó =?‚`ÊΔËò#À 73s² ƒŸTÌtUîúdU§ñࡳÖ4`T@ !×óÒ,×]Í"É8 ÆÓÑ"_ ŠN9CÕ…žÕ:ªt’6Õ<•Õ–(W·­ibš¨t`8$€šnD%pðŽyô¡ÀxƒM-¤* XE¤cÇ R:Ž9¥„0 ) H¤BürH‚ÜÇ"9ú]éÈ@ (Û\®èÁ4zgïk£LR“,Q8*Á#Hô3#-ÖI8Z\ƒ4¤† %}ô l5‘Às!ƒJE—¾8òX¨‚TÊôÓGÿD!0ÓE„‰ÊTrg•ìk¥K¢c½T* i‚…wZ¤@ýá!R˜´`„*A V ¢LzI-?üH?—’#Ü $.-Qnð‰°ågrg893Îõ•³%Ñ I€VPhR2–í©qfé( F´JÁNj¦8E(9ÛdIId˜~+"¤H0 „I¥¹7nŒEW„Qói”%щŽ´(°¡õ¥BŒú… nä+El@IJôÍÙÔÇB*ÅG¸ºD¹,T¬ö¹ËWÐÕ@TÍ‹I_¥#”UæÕ…z…g~ÆáЉ0´ÑJÖ„ iL„q˜tÙ¤'Ý“ÿ‹AlìbÇ”#&ièž' Ž”êÔÙ¶ìA|Ý+i¢Ô*²¢\ä“RÓv©ãC-CÆ7¤E†Y±Uå ÓX[Þw1³p…{Ü w{ÆEnsu¢\ì1×¹Ó­ t¯']êf·%Övµû]p×yÞovÅÛ<ò–wºç5^zÕÛ\öϽï=n|…7_ú×¾®Ão~c»ßÕõ׿¤°ê<`½ørF°EL978•ž\„% C /ζ`†·aëÏÇqˆí7â¿•ØÄòC1ßT¼böµxo/†±ùdL7×X|7Ž[ŽuŒ=ÃÍÇH Kf*”þ¸1Aÿ~ÛCu)_ý„@JŽ “Ùæd—ÌèJG²SgÛd§1©^m±ÌnÃ|Ï%EV˜@’©L+§ Ë,Τ)á¤'Rò¤ðÌž"=¤HŠÒÒV%)ÑÜ”UÃÞ<\ßÂpÎušUD›B¯0›˜¢"Ê‘˜)Êê‰ÙY>-±A¡ÕÆzôó"ÝÂI·…<–Fµ£™ÂiŒàR›ºÔRB8f¤$š]»BK‘”SÐU+¬Õp~µcYã9fæºK¼æ²¥im8ùÑ Zâk3!¬ÛL¹K²]»ìä6{‚ÏNØJ¤ÝgQr3)èr—e‚@½• ’J™A@ ©ÖtÏ䎨ÿ~ÐÃAtc‹·ìnšS°óÃ*¤yx‘›è°ùÈ ZXŽ6D3…E‚ ÇÓÂ÷&9’û+Îhc·P@°€‘§ôUÝkGŸz×½þu°C½ê§#À‚‡õLi½k> Ð-Uö³£=í4ÏÛrÀ]î¯R;×쾓è}ï|§»ýþ®“Ä}ð¬ê;Ö” Ä+rÇÍCIòéH”ºffò6) 9ÜøªitâäÎÙ›ªØW‚Ý®t5°½1×…¥ ƒ­›ˆmžÿ‰]¥Z D½ ¤³C<¡eYɆ]0ÆX¡;é 8=¡HY†ðѾX­Ó¬&¦ØØ™0Ù  ÙüºX÷Ш® À*ŠŸ!8¡ à(ÕD0 r¢¡˜0ˆÂHºHˆ¥ð¼½8(ìè”™ž¦ˆ ØÒ«}#9®}м*‘†¨Zá 8R õZ³a™¶ø Þ ZĈˆ.´Z´½‘…°Å˜"ŠkG=ÔOÙ´YŠŠhÁ†: ÞCŒÐ©ZÒ XĈh¤Š€Ü‘à(¬¨ IÄÅaâˆb’ܤH4ù;Z À€N'DA¿…U XD¾°ù”œ¸¥È“°øp,ˆƒÒÿ[ÜÚ0¦˜á¥vdG#2‰ŠE¬汎9£ ùÁ ¥  ªxRj¼ŽM‰> UÚ¿­0zŒ Q eŒO˜¤¡lÄÆ² ˜€&à°ˆ‡?§°ûˆR9 úí K̈‘ø â@"…ʵR´_Ðe jŠMƒù¨'YŒGØý‰‹ðzÀ"Ywl$Ï)ú‹N‰AÑäð*»(¤¤À¢˜ˆ)z%:,‰lìŠm*‰sQ©¨Nv”bñ´¹`+åX"• à‚€šK|Ýe-ßzš‡øŠ a=ù¢&ÄŠ=<  6Þ¹¸¬ØŽ$ž‹"= ° ÙbÒƒ¦ÜŠÿí|I pN¬0Ü.&‘¢G„¬¨NhˆAZ’®åÀñÕ°Àe ÒjN‘½`)ƒ*¾bÙB^⊞¥œFvä?þ°HžGäêšdÓäÕ¹äVñdÕåÎÈdQv èc£J8eÊI•weZe\®eW¦œˆ€p fa¦€a>æa¶ˆíe3efF.Ȭg&ØiŽØ«»fz…€ Ðf‚¥€¤õf]}9qæ×ÖrÖØ€tÎVRnçù9€çhm ç`Àç`µgöÙ­NñØî@!—h~®“}^¢¥‰6Ô ºm·›@\Ÿ°NÿU^ˆ…>h¹gó¹è,S¶œJSØeš5Ÿxi¦ðåç@€ež"yé\‹Æ”¹"Jz¹¢ÑŸb´˜µ™~ˆ÷ÄÔˆº”:ó„@ Ù*ŽØ•³˜NErƒPŒ>ˆ xì ”¿€”‘P"v (£X³6c¦QáOªíêˆ[p4—˜"{; Ò§2ª4H‰’C±N¯p\–a”Ö‹Ð <Ž”y誖€ ¸‚c ²þã¨ÔQ%¸˜9¨\‰¨™µ}ÒDÓHyˆ-%Q’ö«Š‚"^»¾?KádÎLèIlû˜OCþ¬”î4TeFY¨ñ0“ÿ«3Ea“ú0™Ï¾Ïþ½&ÞňQ›„é¢AÑš˜;h@€p³¶N- vabA‹‘À ]³ÑHO]ãì¼kQCÆ@r$“!kã°+Jº7°¸‘ öæÝ{›êŠ>èH‘ž1˜$³©¥X¥@šž*èl “iˆÍ8Òú0©aŠê˜Ùã”®ð"õÏ-Rއ¸pT1ŠnéN®#u!ªìªfŒ`€n6­áˆÛðpÕw `€êîqÆô€ t6ŸÐPœò{I 8€ hiç9 ^þ €lvr~Á·Xg*_+Kiqÿ XKér/Ç—¸ê0¯ 'ó+÷:÷ å º&oómyó `€èðC?tDOtE_tFotGtHtx€1÷óK C?ißƒŠØ©']{Õå¦Y}?чàDÄ $‚sáe*¨`zÔ0]ð¸ O ~Q ”ˆÞ’P"©A€žzÐïMŸˆ:…ˆ#D†%Ô£B4Z·cŽ‚ ÉRb"@P£D7Y“ŽNŽD *P)d”O‰¥N#Ôä–0A fL$0A_ŽÙ’˜jº4˜9PšmªÄf+¥'œrÒ‰çIw:V‚T„úT{òI€‡Ú©e}+¬%é¤h!º§øÙ(InZÒ —©©§!uJªH€)šŒžÊ飮ªÿD¬,Œ+G¦ÞZ’­ºf”k¯"ñ ¬E¿û‘°ÆNTl²M Á !Ë,DËN‘ð윭Z{QµÞ:„žÚB+m¸ ûV ´ën»½ûn¼òÂ;P½ö „/ôÖ+@¢ÚÐ-ºÊÒz ûö+¯ÂóÞ‹/ÃîBÜî‰Á¢ûjpÆé¹§‹µÌñCêŽlp‚,й&TrË­†·0\3Fݲ\óË7{)rÏñ 4«C;$´š”@’Î0=fxÄtËN=µÉU}õÈY÷¼5Ç]GY Kÿ\tÌ' uÙg3vÍ_gü6Ìq©ÙŸz¾§é“º>˜mù=¿¿eT ÿÊôßl?–%€Sþä×>Oý/J+HÔ ¸©feƒA"(ÁP¤`#¸ÁŠ bÀØë‚–¹${Z`ÿvVB² € ÿ\X ú# ѶÄÄÏ l” ÿÕÄ? qLEÄÓÁ”Ä:-qKMlÓ±E5M1JUÓ”E0mÑH]ÜÒ‡F,qGeŒÒq”F'­QDm4Ò?Ç!ÍqAuÜÑ”Gí±>}ÑåÈ R;…\Ð!¯“H-Ò7¬Ï#wIùìnI®ª¤vv§ž^}MØßA ʆlà2 (}\FQ¾ÕÂ…¬(=°IwJ4\23˜€ŒÐIê­° „bè´Ç–@ bV)ñGB ™b”ék.„˜Y³j $ÊL70A T› ˜&<ãyg1yÐæ™,0lX`ÿÏÚ €2Vʧ ²Ïð´Çž˜ hpÐ~4Ÿª¬¦ þI6{Bè;ò›Ò@¨¤OX€¡, ’BÑNqÚÌ"íYpÊÔP:ò»Ì…扽cä;(séG“y™”)æ0bél㜕Ni€åbJz€hf eª‰¦Œ ºÒˆ á4HUs˜­&šÜAÌÂJ›f•XäLHJS9%YºÔ5µñ(t^¬­À9eE(uFSÖŸþ4Fé)ÊÆ#Uç0 çSÙS¬jÈ<+UB[à 6‡QVI@YbG=*¸kIiy9ç?êT=Q`ç¬öB¢gE°zÎdÿêó¬é+xìI"¼,]i5=»TÅfU· g‰r›¤¢G].uÀS\θ1nÇy‘b6] x= Mࡈ«l)Ü)Ó =eW§ •ÂRº”®q¨‹™Ív¶81"VÇ#¡ÄXÔ2M{„‰X³Z—=è ª‹¶{Rpq6µg/Óž• ÓBwý) P&!¤Z¸Ä1ìJ€™•63œ$Ï]»ú 3;M¦sD@Ì °¸Á%ñb¨£LàŠ`´hÉ…9R“¢Ñ¦êÜ( sÊw‚ ¹¥´ ,ÒËí”øÙ²:3 NÃ\FW6,›{šwf`ÿË"h­Kóy Q–²4³Þ<+“™y&íU.`1'ÓѦXKëLBð1CÑ#“€(EéJw[‰RÙ¡{( ÀP 5Q’Y±@ú*š¼ÎÁ¹'9±ñÔrS´L0íê'sZ5²ŽIjMFXÛ-×0‰}­7`»0Õ¾™¤g½eo†Ùžqvd ½i;†Ú‘±ö`°ýc›ÛƒÑö_Àýqo„Ç ÐôD£LúìÖæÖHuZ‘ 1„Üœñ¶o@£$Ë„–® ´Ùó’&4Ø€Âô€ß½´÷Bð­—x#„«®YgH-ÛœçD§Å$$[žÜR@\ÿ렆 Db+NßžQAÔ›ð™ºgBÐ)~L^ûx‡º·iÅyóÍÈ| ‡uÍ«×ܦ@àéyV.t—;®è‘iÐ^“cobˆégçeFcÏ›kýAT¿·Õ%‡õȳÄÍhT& `^3˜"°gh>Îå±'èj‡wÛÁÄ•9š ?’¸B†ŽÁo‰8ëĦCÔïÀsÚâüܲF4‘¶tâk㯂‚ @Ø?a<]Ä]ú Z¨½éFϓַ.ª‡‹´ñBQûÞP ÷¥½  Q°´ò)%Âj»øÇWîe¯:ÚûúPZì@ ¼Ó*¹ ÿæéþùXÿfå·Êø«²ýËŸß'$àzûÿþÄ?†ì?õmWœÜN0}Ü÷!ÿ·' €/gR¸Q HP ¨€õ’€S/°ºÓ5ñ P1 è‚(/ø€(/ |4¤m¸' €îg$-(ù—zè;¨˜ƒ‘~ ƒ:qƒáƒ>1~0H·æDØFÈÐ%–ƒó‡·K"@9Bè)˜PŠ’3¤ô‹)O©™Tîe•¬dÍc‰-Wê–´\Î,s)*[æ—¼ÄÔ.ƒY(_Ú˜ÄÐ0“é'cʙ̬Ñ2yò&€Œ!'`›6‡M@Ms'jPË’!-iɈ 1_7%â̸@ó!Ò ÏxR=ŒÀBÖñ¾dDÿäsÜùgÜòÙž®³3ßÔ €ü ˜a.bO{à ý/ˆ› ™ÔÀEø›§|tP„Únd=‰Q‘$ú´GAÅR9Íi !HDÇC?™t¾’F¤py§CTš¥Q.BªVM‰Ô2&­§ø(‰2dõÔ§&mJyBÔü¼pRªL‹ÔO©¶40Ò¡ê„®ŠÕ†u,BmH8µÔ&ñPîqaÀRËé¢Íå=sQ•þ§×µB m5È[ÅW†T3NàaÛt:È2à¼)›Ú$“ë6t&žQçÀaw˜—X…,6,--RN –ÔªÖ(¬eŠk_K”Øÿ.e¶h‹Û*·vËÛî%T)ÝÀp‹k¨ã&¥ZµZ.s›ˆ'0ëºØÍ®v·ËÝîz÷»Ú]Àt;âÛ¤÷"Ðõ”tÇ»‘ò"å¼ S/qÙ[ç"E¸ó¥o}OjÝê׋üýonÜ{ø ˜&6 “ƒØ”àšûY ºˆtyð™™à¢ü0j'àæGHš‡®u9FëMq&Êi&ŸÀt60DK›ä¸èB¶ÆÀáàêÄM–ˆhÉé,¾Nà–Ès;Ó–äüS-,sdz_AÜã ,¹Éxò”ϦÇå/úÛã*Z¢È=.ÿ?A†·fí ?,…]J(¾… ÉìÖÌ7ðd­Šjâ³ ´çøÐ r€°–DkpÅ5tý œUšÑ%Œ\™í Ùå‡:Ó Z<{¹¸Q`C*ܪßÔ°ü”@x¹â©Ïv?!¦àT®¢e\ë:BQŸ ××Íñú¾v€tW&Q×ÑÌBëÞŒ³ ðM{Ú‚þÙm«®šbîAØ? 5ˆÁuFÕÙÇgÐWSÝP;5õÀ#%ôäÝY‚Zïæm8‚.1ŒØжk–¼Ð:ÍAÓ!uH\‡npQC±™^$ZõAn:ÐF±ö4^´À0èÍTÿ6µ„ƒx¼h ï·@FNRØÔaë§9midtrxÎÒ©å‡tSþXƒüwEÕðòšâˆ˜tàø(éLßY’!‚ü5{}O:Ð^Du.Ñø  ø&êzêË Ý߿良·ÛÓyû¼Üû)3Ý;yhwè™O€Ù½:˜&Aý¹íèkð/¾y€9’CDó&̉LûOfìeÞ0Ù‘š÷‰,“Ð÷dô¤‡‰éy‚úÔ»dõ;i½ëõ„óÙ3ö:‘½í 6ùÝ÷9ѽïk§Õá{²öÆŸ—‘„Ÿüæö¾ù—>N˜ýHÿ&Ô¯>y‘¯ýh=¿û·ç>ÿøÇr}›dü)MÎ~‹¨Ÿ&ìo?EÞ?“øËŸâ¿¿Rè/ûë?«ô²U'Í–5!€´Ä1á‘TÕW"æWÒM ÀD3h"hš%1„yØãcÒx>¶:YTV&,³j\’?["V±™ÓeÓ‘‚šÅ‚Lø¸T-Mã3=V+Ò-³"0R ƒ>Å€U„L‚>%è0QUFX-¯Æ:(#›„èS-R8gÿaÌ”ƒ.KFèB "øc’8E"$gx! ãƒZØRA#='² !yÕW0;sulãopy8˜NôTXXÿbno!Óuôà áDUçä 4ãb|Si,åRämEÓ‰ëD†-a†Ã7U3€‰C!á¶%L,u‰z%$fU^#yõ‰á bYƒXоxP¨øxë¡%%í1°Ø‹æä$cNǃ‹]÷ƒkÕ‹ RÕRÓæ#'PÅè!uŠŠØѱnqGù„€‡%þDµòPíhMù4xü‚x+Fƒ§wühOøÂ/êø}BÁˆÿɸÌWM éë8‘Cñ*Á€!c‘¥Q‘=‘!õ‰÷‡‘)¡‘1ÍB’èg’(‘¦"+29“4Y“®¢’ÌÿÒ‘%‰'Ð+Éò“@”BY,ËÂ,0(°“ P+G™&òç’ˆ±ŒIáO9‘Ri()& •ÿ—•%±•)@`ÙbIdé‘b’léi9a²E¿#ãdãÄQ fà>Õhs áh640q T™BÔa¡8Á˜EÃ&{IWÇ’9ж.…8’q›¦ Hs<¶iA{Cš¤ƒk€5ñ1ŸcA!:5Z“s1÷ñ‚bè6HCB5š“ £IAS²›«›ZwB b„-71¬YÁÙ?ÄÉ$Òxƒ¸’™ "IÔ:4q bý4ÀamàÿI=½s! b351ø±g(¦Mô H… é #Ö1gX’3š(‚½Ã7ÿÒ;…‡³rŸå ’?™¥6Þ)2÷?%P Ôƒr¤…™ÎEøQ2Õ±‰hck^Ã2%b$ºBr¦AIDfÜq858Þlõ ÂÙ:,JrO AãP$9#÷kH¥$lÞùáP(c9uã3øñ›Ú¢Fãq&gF:½C@ÍC˜Î9#8€3T@>ó3(21bº5öó4&GLªYÀÆf™%¢rcbþ6d¢¦=`Šb"CDÔCRyZ7(ò¦g#7Wt2Á2` l3¾FmÃÿ™1Öù b™c7%ns%>‚Ts3s@ˆDè˜ÙIŸ&$1§& â#lã˜aJOèãk'á³ckC3;J!û!ÀAsC†bsêû³7´1´aY´F[LÛ´3´¡´ú'µ¨q³PûV+T«”›µL±µѵQù´`ûb dÛ~iûX‹~;Ó&Ôy‘f;{ZÒšKѶa`UbIi¨÷è<}xß"ãñŽ;"…'®ÝñvÛzÛvS~û¦U”yûÁ>óñ¡Z’?ÿA‰àaN¢VVµ„gµu  Å%”XC|³9-‚/v»­{ŒÄvE C:Èá C÷Q‘+á!¼SzX!æNp8‹DRURqjó ‚»þj "2ƒÿ%?ƒ ªk‰BEuhU½ù®ZRAôáó$¼¸:>BU–š%±¸Ÿce½½X„H3e¥» 1WÛã"¼¸O…eUçT&Z¢MBgh¾Zó#^£W.(Z£Qmâoá1®C²Ÿp(%¢V<Õ«_…`N-r·O⌼s·ºcNEU‚ÿ¶šU¿h|"I¸¹¸A94o[ÀÝë±+¤À9KÅgÛ[*Á2gI¡u—Q±ÖZq±zÉAQÏ~(ðŠ¥ßȯ5ݸ/uúcÈq’® &0·‚~ °^‰BLbþtìáq#[4&–OûâÁÊ!› `+I ~Q¥\ó¥IU2=]Èa‰H'BÅV¼û‘C¥‹kYµ2ÎÕ̲\šTÁbžÊæ$VeUÌR‚ØË¸jÆSPdul‘ÑÝ p]üìÏy2à5Ò$]Ò&­]Ö…áqAßèQ…Ð'盓‰[ÿâÐóÜ"#m€ÑýÓ@=ßÌ,é¢}Â,@•DÆ µAK¸001íW8$FU«5L%Ìy¡ÏÞ/Ú×µò$°Ì%Û“œç#kÍ‹óñÄv…>ßè‡?,P©¬•ìvPÔã×):iÖ$±3iRY>Úgxü‚r‚“•Y ¥ÊXC&¨×vA~=~(7µœÉHË=ËÙ>Z9¢U£é0øX•ÆiÍ{~Ì[XÃFÚ‡UÒ3EÀÍ»“Ë·xDáO+†ÂQÉ»Üì`sk8‚°§²cÅš7øõÑy‘U‚£lsXÿs*&ZZ¼03‡&>ŒËdÚñ?(‘37Í6Ê)Ölè½[4˜$AD!H>vÆ<Ñgú9º7ö9 Dp3‡f¢œ¬™6Ÿ“††7Á–5öã4ˆÈ@>ƒ$ajáÌ€I< D€s>B1±¦jrÖ<®¶!%#®^ê¹;úU/¶ TŠ/ž@ðaYd²=ʆªÄ€ñ"®*E ‚°Fƒ5HSJ°C®ô$4¼³q‘«KÓƒ”ƒaD:îzšV®+ôkÛšhä·æ Å%Ð-ƒ#É¡8FSn'g87n¦9ó›"פò‘Ös7%\âbÙ#jÿÙéÚBžVÚ;žÕ:š­=©Y4ÿTéäÙu-ô¤9+:% Ÿñ£ wc®¬)QY³>ӥċb‡ ÄQe>éJ¼þ¤?‡3=Ö&¹#§…z< êåW1(“f%H¼Dc¥¿†!W@Ìà ÂYŽÌÛn©§ â9 ³s«ÃæjÊæ ^ADbÊ6—Dˆ u'vj T4@ƒQJ§ëFvø5"uÆÝ<Î6ÃÝFó£»r#¨¯ÆR t<ÅvŽ&?L2kES4Qܳ絆",ÁûöfùÅoíêÍËqc4ƃ<^ój\’5Fb(¿ \3®%ÐÞ 7!ÿPQ Òþ䢮38P)§&ãá$@þø98Zòš¥b!€gJ2ŸIZ%Ã!&÷žôÔ¢9ÝÆ#ù9?«3è{ª„ꥒæ3MºÐ\âgb\Oqß \iúæÜñÞCn?Ç@á¦,~23D{¯’úk ´ ´›TB¬/%cÞ ÓñBÏ㙉ùäœnCBîë˜ÓÚ—ïW+ÌÃÿ;Ãߺ·ÛW¢@ÃßêàÁ%ͺê'e%1&kL7†9¯ç–‰ÿ.¬çQ—’÷Ú1B~% ÷ÍDi¯k{ãªóao.·/ç`âŸX´ù Áì B¤ X0„‚‚ .TˆáCˆXÑâEŒ5nĸàG!EŽ$YÒdF‡Fpà`Ĉ ?PHq¡¥‡„2¤ðÐ2&L›4k:ˆgÁ)€: 0BA )Xª\éàB„R[®ÌàRÁˆ“)†%[ÖlEgÕ®eÛ¶ä…S8ˆêákÊWSœHZPàÁ)fÈ7…< $8")á†#छ"CbQ)$­|9E º-8–ôiÔh?¦fÝÚ5IY3Ä,"ÿ•I7$>bÃ…¾û†È[`DåÏÉ…'Ü yÒØNCLwðêAéÔûeLÚôkðnÓ†'_Þ|ßêN/„ˆalÁ>lp¨a„B@ÏzPnŠê“ʽþJʦ œ-¦~CPÁ „,«Ó¾3ïB“ÆÃpC×ê+¶ „ͧþk¯ •#L¹K( °$l ¾”˺•ÀQ*(ˆ @ݲ°C$;Z-I&›ä¨¯¤œ"j´ êS ¥öBP)?©®ÄMK‚¨J2S.)0ç Á±¨ÊT@¨®, +7ir€Â †¬ÐI>#Ò°O@õ+…Õò‘ ø@Êÿ «#**ÔŽÔÉ?'µ”I ª<ÊЂ©JM#ЬÔ$½ÉJOU×ܪT‘FBˆhtUJ—ÄuW^{ÉT_ÃK5Xb×:áØºãHVX-j£ÀŒ,Ãa§µÖ¤Ä"Ð5#§DRàÛ2/ .#HÙöZÔªEwÝäé6‘‚Ó©¢n7*R­sÙmK]}ûu”*„*S¿ÄL¬¥7â’‚+U ±oÃ,“ËÆ‚«n®%6s·Ã¾-˜á­æÂmÎ¥õ—5~OV¹ .ÁŒ` ƒ0Ïåüa&DC¨r¹Ê\„uƒ¾U &vl.£Ò‰ã¹nqºÅJ­­|W&ÿ+e«Ov(AžlR ±ºÊqk9ÀÕb«o\ (˜Îƒ9­üoƻڳi̳CD4«©ÍÍš4¬ÿÖ÷ÃìhÞ;r§ž zoQÃú²î¿ì[ µçNjóé| rÎVƒÒ;Á÷ݶô•G×{¿âŒJ®†.Ѳ˜^ìXf¸>›UvÆ›ngÛcü Ʀ*Ú²ÜcxÂU:ŽtÔÕ °ÈûønM,tæ(qE±ÆÁKfM“`¾7Ûà.Û1Hò¤2‚Ù$„d ‰¥eh•š(9£ZÉ•0¦¹¤dfÑç>SÐÏòtÊEp‘¶Ø7‚~„…VQp°h•lhÍi)+eÀ7á8çéî%(S;*ׯ ‹YUaCòC„”œƒ0 L}áØ‡ìVQTÒ¦Á)yŽW¥Ø…}Âé‹SÖW0›tõ[?‘`Wx"NUõ¥+ ã޲»,ÿSšÔoNpG,aR`Õž©MVD²R c” z¥^ 4MRÓ}Ö•Iy=c¡D«ÇФ+r‘hÐÆ˜˜Xf¦˜œAªÂ¼ZFi1ÙÏf[›Ò¹øH'8ètrФiÈSŠ*_;׌È6IÀI”ÿr«0°°$1úÍQª™ºé[ÒEg!ä{˜fp¡/iž *%HÐG>@¡Cý†Ò™MTnÆ1’QFyažIë jQ¹vBR¹Õ Û|«ù@žª§˜› yÍ‹.Ëʳ:Ó®> ÿf ì({CŒmÊUOöH51b  b8ÃŽ&@è¶ €Öè;T:’”ü¾®ÿˆØÛ9°°u2ƒQ }Œ’”¢ƵâÉŸ3è¾hëšÎ¼™«úì±D™’KÄòCa fÕ¡˜Û¸úìr±ðk jù𝠠M¥ÓMù}RMœâ ±øçüŸØÐ§=Ö{¢¬bÇY%jtÑUÁ蘖lå78Ú"ÂFPͰ%dE.ÊJ×E<ˆ.Y·Py¼š`&+ŒÏN¸šzI&µ£ÛBá¹;Ïwl|¼†(‡Øå*‹ )bV/šì,>s Qt¡€ÊLl¥IÂøÿg¿äehfš‹Ysþ-œìǽ1úЉ:Y€,8ô$©{çÜ­ª®É‰J¢¬œ˜Ä%2†T'H»³Dƒ$DV`šH*e• 0ëgÙQdõÁô¤;ì?î½;}ºÓ´W‰I¹i™‰ÿ ‰m@êÀ³˜H+Ä#‹VaÀ$7 ÌÀ(r@ ì@B½ô@ŒˆêóCAŠ+Aê9Ad5ŒlÁA{AÔ‰Aì3,¼Á<ËAÁÙA|3ü Â3¬)B#”2$´%\Bk•yB(41)T*¬Â»Â“ÉB-œ+.ô/üÂ} Ã~C2<$3Ô4LCÿZCviC74!8\9œC8ã@I#Gz ãÛ"á`®Å€5 ²A) )¡8£\l“o šGi£§RÅ‹ÈÄ`ÙD†Å§˜fý'b¨ˆù D›2 K’Å8j9‰£ÈÆfLª<ñ%T3F± Å&Q! ¢Æ­Ùæj& h£ÝS&¨0E*ëÈ {¤¼[(Ft$!udvD“fŠ˜Ã€GBi¦©I šÎ‰9’“¨ÈÿéˆLÅÄdôe\ˆƒ&ßH ÌIÈÁ¤Í’¸Q¦ Œ^ê‹–Ü I›Eù´Ž”ˆì•Tˆãá,§ ÂHkÊŒ¯8Žo1š8QœhJ¡!¨[ 䓊‚9ž2Ùµ$Á‚ÜÊìÊ`ŠòJóèI^ùI“HK²³Ü´,‰ p¡ ¶|·Ä•ÀéK¿üKÀ LÁLÂ,LÃ̹챺¼KÖÈËU)€XÉœLʬL˼LÌÌLÍÜLμL0² bL Av±Å´KѼV¼h¡ÅLÍRK_AxMØŒÍÕœ@ÍÛlLÙäˆc9Gÿ@é …øDT<Åe©BÇT•Ë–‰ µ‘Xµ®b¹Åã3@ŒP =ZÂå< 3%¶ˆ«O1§§ •› ä 0™@#üÎK/i:t’•‚Ù !¾ãº¦6ŽÖ™±raö¡©ˆÎk ub'\¤Õ°½p*Åâ)9Á t[aûy™k ¸(“â®pAø´ñj¥0’нy™Òc˜1®*ÙzÉÐ0É.ÂÒ¨Ïè;Î+ˆÊ¶–È ë$‡Ð½I r‘õñ™Q›À‘„‘‹Šš› ÑI¯­‰‰Ù ›‹„®ù™˜„èRöyÈYB”·²®è ­Zÿ³Ú€%1‘<µÁ¸`踒PÓ¹S³Ä°9(Æ2.B›ý„B*ñ"Ä JœÃ:J3œÃ؉¢‹å¡ÿœŽ!ę́¬ 8Yú : ¢‰ù&¸˜S  q O=Pœ¦F¹Š·±9‚Ð ™)Ó)ýMŒ§ôFªì;š`ÙY¨iG]ˆ¨½0¬Q’ àºçâše-ß ®¹ÑÀ Ç ÛˆÖÏ9E×±¦i>¼0T^ÍÓº  Ϙ«x‰«´Šì—çážê.üZ 0šŠû¯ÃúžûZ‰¨È€PÊû¼‰°‰©Øâx݇Šÿ£"Ù€ùôÎuµˆ M)“)uÍME‰“Ek±èÔÂC ”¸ìÍKYY@iY—˜í™Ù@©Y>¹YœíÍ•ž=ÂŽ Z5Z¢}C£=Z:LZ¥ÍC’mZ›úÙ&áY¨å©eª­Z?cZ­5D®íÚEüZ°…D±[*[³µš«M’¬M[¼D[·=™µE•çŒ[Á™Ûi[»ÅMÒÜÛ¥}Z¿õZÀ ܰ\Â%[ýà`+5úDZ«‰ë £KR#¬ˆÇH¼å½…sÈ8rH‘¼®Ê]Ë”Z{’ÄÌÝ,l×馯ðR«DÐ.y½Â ò:©Ö½ÂÒ6* ÿªèÝ0ñš˜à1eÁ[-­+!Ê¢YÞ ø]Ì…ÛxŠÝ€üЩ-ª’÷øG2òÂð‘€|Þâ`˜Lj¦¤Z:ùP£ÙHŠóŽ“‚ŠÖ„ XË ™~ìF»ÞêPßèM\µˆãýŒ‘•œÅç}“<¸LY'sÇ[ݪ‚ãûŒa}F_b,áÈ ‘4â€>1 IÝ=\]j©Û°`‡´Çã*`n²Ù%²a¬õå /ba1ò-1RÈŽG]–—Ï€Éâ@½ÁëH¾,DaáÓ£’ŠgÕ€Äë2š˜èH†Ž[“Ưh,裠Þâ€ÊȆD¦qÊ+ÿù>YÕ•^Ø àXbÈU#ÆQ#§r 5‚\,­2ò¨‰£ ¹¯ì͸=N8ZÔ™ÉÕ!… [„\‰§a8>Üb9bóØ\K®%ÿÝd•ÁäòÐd‹(ðd¬d&1°€R6ežDe&a 03WžXN’ p!7»e…eò8°b.fc>fdNfe^ffnfgNæ(²^öåæð@€a~fmÞfnîæe–åû1j®æ\F’]¦1g‚°fðåò±tVçu.g!q–çÒ ç ie|þe}îç&aç×бà<â9’ø ãtåDeç\‹”5 ê”Üÿœˆ\‰ ¯¨¤Ãpch×O&À…ÞˆX=ÏòSH‘XOŽhÏÑQ8žÏÚP 5˜ü$µšÎ/ݱʵ̉{"Ðü¨P¤!… áP# jkò¦‘:®ûÔгëÐ7ñ«hÙ¾ EÑ”ZÒÍzQ…ëˆyÓ˜²QûÀQ”âWR&8­½ !]‰¼  #ÝšEÉN%í¢zƒÓÙƒR°æØN®ˆ+¥-½ª®‘Ýöñ̨<2•‘™»(EÀ5ý!yÓÉ‘Ó}KÑš)ÉS¢Ê”>E¿?…IAµ°ááôèÖHÔœYT‹š‹F‘ÔjzÔIEK•V‘êœMµ0ÿᲬPÍ.º#j:ÕàHÕXUotUM…ÕbtTZ-[Ô\¤dm” ée\Ž_m©.V4‚™šÖcE“då¾írÖ§€VBÑmÄ®ÖѸÖ÷ÈÖ÷8—°ÁWx³ÄquŠrõ‚A×0ÑîÐÃîÔpíFqW®ŠWŒ™WêÄ¢¤‰|Å}M°rbû’ЬX5» Xœæ„í®½ïЇÍpùB,¯XËp¯ŒÝØ÷„ãÍ3‘쬉âè‹h¬¾3wh0ðt!p ?!?/òcüg%·Z&oò­l(_•#"Ÿr@~~³,G— ЖÃs2/s3?s-4/ó 0€/G¸€ÎŒs9Ÿs:¯s;§sÛls=ßs>ïs?ÿs@tAôM;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveCheckboxMenuItem1.gif0000644000000000000000000001361010520670125022677 0ustar GIF89a÷ $$$000444888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶ººº¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòÿÿÿ,ÿSH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£ÎÜP¡ªÕ«X³jÝʵ«×¯`ÊëÕB ©hÓªmé Ù·pãÊKW+…"ÖêÝËw£ˆ}wnp¸°áÃ3@@lÄÆ#¯U,Y¦ãʘ3+¥¬¹ååΠC÷ä,åçÒ¨SÃ$­zäéÖ°cd-ÛãëÚ¸s[¤­;ãíÞÀƒ'ä-œâïâȃOñ8óç²—Cgè|ºõÒÒ¯#¬®½;æìÞ rÿm!|mðæSŒoÝÀ@úØèͯ×K¢‚ò§˜Ð E t h`$@ï©_xó­e`˜‚… p! ˆ@€B‰å5˜ÚƒÞE˜V‡ˆb A† ‚ L ")Xàž¢~Fä"Z0P¦0£ýµå…"æ%d D&‰‹Ý-) ` åêb Š`Bd¤{íååeh`j'¦T9 €Ôžý‰ ãœl–x'žH.ºç¢ •çuFjéhÞY饜â4©u›¢Uæöét¡JÕ䤖 _¦^¦ÿÕjÀª«° €àë¯À+ì°Äkì±È&«l­jÞŠë—°&ùÁ TkíµØf«í¶Üvëí·à†³àõ,vÑ)+T'0[@çBkéºO… æ»ñ9ïcšÝo¾úFJ¯SÜš®Ï lðÂ!̜ G¼[º*BlÑ$€@±F)r\P‘7„a‰%Ú ~J\’ÃÉYLf¢€‚HQr2A†ÌfV¥=«<ÛÆï¹<RjA ¥ A2- AH‚~My£N T_h’"h.Í ̨ÁÖ]9Û_£)¥L¿à†m8vÙL ÿ„¶Úl‹À Ð"±ŒœÑ](øG#ÈP.v"Õ’»çÞyѨÀÌý975Bc°Ó(üÇ%ç¡7¾9—yAи…\6z^ è)ˆN:›§Û®úë8^8Ñé!‘‚n‚ðÇ% &Ј‚l9ÐõÙ[ÎåÛPVOé;f¿a @@àŽ‚o¨¡àâdõ4’½ Ä5›z¥ºœúþ´#ܽ¯ñ+žfž÷<ÖõÅpÅQÞCŠ=õåñ…¾¤G¤‘è08îƒO²À€¤9TíJˆ”N8¸ç„=‚Ò 5 ·"‰N…iá ÿ¡C¤ÍAéëŒ 'D»Â@P8tH‘dDر©oÅÃà@²X"=ï>9#È“R€‚×1­<4¤ ÿT3€€FQcQð¶y¿+ÈÕà 52ˆ)’]g~dÇ”æ‰Á‰bCŠÄ55`Fy1TרôÈò0’iZ”ž¡üÆ5 VÏ> Òz 4)î|è¤)Ë“Jú²wNÃ@ІD²iÈ£´O‚Ô3÷´’KzƒúÄ &ÊPÐínD(i¯o~²üd²¡ 8ŠdÒŠT› L--Bò•: ¤QiCÌ›°€ÙpBW[§öEÍ2.fFF¹fo²¹ÿoB@n²@Ó¨ÎÑråÉ’œ¤¹N;Ê“‘+ `d¨(úÔ ?r½Üä HÓ@‘–£ %t íßš:$‚yF46ôÑŽò‰<ùðËx{i”Ú©Ýh1´ShCiG¤®³I0‘Iõ÷'ûÐt_8í .ÁȦR†ÎL"AV{‡U¦õ4/ö™@~¸ê5ûd £5…ÐM£ªšG&ÊhÉhn6ÊÖ¤ôÉkZ[´ÖºúU#Ùqa«‚ 8P! €R×`Öœ%6"‰M‘ ;Æn„®-Õª)ì¨s”¹‘µ³d*Èu eˆö²Z‡X ™·Tg(Ñÿb³™åÔ ЀjfÇOkÈóu¨HvíyA×zÚ3§ˆ[¬æŽnY$ÖDÊ­avíØ5ë¾Ö¨m(tD=7%W  ‘ì4Óóf—³O_sK_…4@M½í,Å:T!ýT¨D½U“ŽÖiQý5d÷ä&çˆD¤ùq©DHk°k¢@}÷´èCð~ægQ wêÄ^4]Í ËiKQ2ì§Ñmñvæ[ßDÌê­tÚ#¥KªetO–:´;9µCâfçLt¢ 1Ù6Zτԧ ¬ÂkšHÜÎ9…sœëÔ2ŠMdC•jiHšóå“1 ¢ÙÁQÿÉJ¢±—’rÙùÎxγž÷Ìç>ûùϵRÀbÃû@ LK]²C3—Ë}Ê<öš† j¡û2P­½ðÌ´wå†.µJ“ˆ,š¥dÚg~”63¢ÔK§µ'Àyiqkã<çZ„Ì@L‡&ˆÁZ &äE'ЍHË sC‡æÅ©°º(À†& Ë OhNJ›_—mh¦ö@@[*²¤eä¦ZNfõ†“{½¡¾9!¸µu’ &]Ÿ Ë)(›@¤Î¹G°^ÜE›ÄŸ‹*`DNu‚òóíBJjÛˆÔ‰¦ö”Ð=¯]†¶t߯-Nu¡ûÄ%|á‡ÿŽ“»5cyË›öq Û*š£/|z3,eÙ´ìp é[¡ßzf E–T“mÜcƒÔÄ&6h²¤¬â\Øt4¶°3“eÏ,[tÿ\豌›Õ»Žu^ªGgòuy­EP{D®¸‰·Ú÷ÚÈ}î^ª»lîŽ÷…t Ú‡}ˆ ¾I‘ìÍ ¾bH(k¢÷Øð½ï!gï|†öå½­¤ñÆT;X™46‡|½æ5ó²Nf0ÝnçØk2§™7õ"ˆáD7™¡€•r…›×ç5&ŸoMèE? 4އRÂ`€N):Ut î±` ùøÏËÝGßÎÞÞ#ÉöHÕMàûKCßÿõi¤À™_5Ã'þùö#R¢MicSrG)>-n?úÉÒ@gX4Ež£f¢1\b&<?ügG©|{&r¦~)Á;ûÃ4í±;-´L³Kn´t£KVT=Ñ“\Ñâ@uûa&EÂC!hG‹Q~ž×€zò€xÅC'=Ã<ÈJú!H¬… 23I”‚$$<3¼£€ sG;‚4T$7EØF惔"ƒ3X8ƒ3 Àf%õ`~3nmRX°“ "ðøCR`Cä¤#`È%ãöFæm³Ä&rÃ)‚­"K €2ÿc&)BNà+©ã73#6 ma:B$¾¢!š¸;¬å5EwCR¸2§ˆ*TˆV‡§ˆÑŠ™!Bç~Èk‘‹‹ñ:6q~©‘~ ás¤rt½ã$6ws=“X-ÕK %6œƒ?üC*ELjÇHl˜Á¿ç_“ŠÑl_ ¨‡PñZ—&—F #’ øMp4"‡T¹Óuˤ=òmbLÕ³ŽUˆŠäÊõZ‚CA…5Tø³mP&$“ö8~ f’n$øtm,%ý賊F±5‡Æ# e‘ e'¹Qè¤$í"¯E%çTòäijñw‹g]·‰·ØbG*šÿØ(P“Œ¨!ŒQ['3’ï„FíäR%Y æP‚6K•%©ÂóŠ‘yÙçFP&ÿ3`´‚Ú„‡ƒ ø>Y@Ù‡öbÊUKÏ“Lþ³×J© µä7ÂlDâN‹&"¤%Æ{Ée'mÓ]ñÕ^vBˆR{[D(‚â9ð•2N_¤Gzž£€R²;­÷z‘$I©×]Û㙂g)iÙ3e]ƒ]vÄ9ðe'E^vÄ>íeG²Ç™œÃzjarÓ·?À”C8è5¾)BúSP²}Å7}èS`ùK“ö$x‡˜‰Kƒ¥ä‡Ï¹?¥TB6r}bD*ÿ4—y<ÿx‘±‚4bç#tÔFSSžì9$ØCQÁYM¤aÿACæs(QBA)b ¢³8·d| ’6oÄZ]t‰! ½U3åIšÞ˜0n§ùuB(²$>‚si±¡&Ç#dhILY=b=3’ýÄ!‚4 tR<¾SŒuƒKH5qx™ ¥§ b ž£X&Òœ,@r(™÷ƒJªBP=4r„0…q J:pâ7at‡5“!1 ;Z=vÂ3—)dr㈞“€Üg>:¡S¡}á DŠØ–cHU޹!qâT>(†døVQ¹9`˜ 72;$` -ÿe‹úã6êà©ùLä“Jë·!nò'˜Z TyA€$ñ£ ¤0aµb§EZžS$’˜xA"™Bfâˆ^7‰@’“St¡˜«D'†¬èå~&°ŒUÓ3¡”“*(¬Cwv=#6>$Œ…@ )Pu‘­Úº­V!Ì¢ª°a# æS­‹r­Üš®êúÞšªwÚ.T©±†æª)rʨª&àŠžAAªaª/A§ûʯý §-s¯{1¤«Š12ldK%@x ±a°ᯚ°.q¡ ‚&°:n “Ê#<ù1A­/¡±™Á±5†4¶¬èS|g÷s[ÿD#“E*1tJ.äƒ1ÉMÔSŠ%\C[<²459ë7=ËZ1É,‹.K_Èמ^ˆ;ÀJ!R!:Z=q2?1e(Ê Îw³åS¥ò&@ €¶Q"€&˵’ôµþYy)ñ´•µ¹µ?º˜¸9¸÷B7ú#8ñÙ*BòkJ’GÛAþeX„[Ÿ‡Û¥.a·’ñx½¸°Ÿº1kTó¨ 1($# ;š6!„µóBRÒRøÑ#Ìù¨‚AÿÖK™ Zy;Ü$;¿ëAfÅ4߉»'h‚A»²Aëêc›"ѣѣ#u˜HóQñ—G;ØKEBmUÿ4 ã‰™nóA23 ™£! 8EFY†^ñ ¿âÃ@–¤éÛ{Ö½u»¼PÔ¼A€ ŽbãF|sVa6c&oB„%ˆàUlBÂ4N8:\óÀA<Á¤“d@Ó8U“_b6WºÁ Iô<Ñ#ˆ¬ÌB¥o"¹‘…;2ní#;ö“=ùÃKITËJç¨@»+8¡„qu%f‡Gl&#У\óËPhꃬ{•ãäA*A6yXÊ,QƒâÇfx‡$#SÎZDQb¸Éël:Ô‡â“C*D˰ÓÎêña<6œ÷·>£4$„Ë%—XÈ7ÄÆƒ¹K„M[C·Yž Ýšr‡3ñI>dŸUTžkp¤,TM M¾„$r´9ÉKŸÔ*CbeãF#é?Ö¼~ÿÿ‰‡a@‚3û£Ó€òÐ.7ÑQÑ&Ôº…¸DœD@ýáHT€Q:U$bvâV0¥’“5õÑ;Qm¸«÷}ÈA[BXä nRK2¶•’JÕë'K\ýcýÔŒ!wâcÏ¡²±y,wØÿ±—úÿÑÎ4$E!CU2ñ×DÜö©1šrw×#ï[6–U½Q<‚ t8XFMºÈ-‘Üý7’d<#„6$ 3lùaÜf'sTŒMVìW§: V2ž‚ªýá9²ãÕã³?ׂp´£:JÄÞßûôßuU$üG÷³p,Ðh"Ï+TQµ\F•ÿ»ÇÀ”ÀÈÌKv‚†ṟ+:)”ÌòË… ÍgÍG&õΣ ÎÅ×(ÉLœ2d¢üœÝÔ™¾ú“BBǃúužxÇH,mvo„3ItÓqÒƒKZÿ´èÿ™uhâCâ4ÿÍþJ# äGvü'iÔ)Ç7G]”Ó%X‰áDø6;Xt¶ÍiC3óë>ÔE»žÆ¯“Þ?^An—#ˆòI"Ö½Ô3ôJ[³KíÓ;Z,‹ûaUSD7Öìâ7í⿃A¼f(ÄLJ»¤ÕýÖ3%­4Õ­šæž£û.7hJº‹|A‹K¯DI2¥ù×o‡ç¥çlU–¡+‡¼m½¤’Þ§‹‡íï>>Ò)Kl‘Ùá `)D1¿(žü{ ,PõR?õT_õV?,@°™e.`öb?öd_öf¯- °\¿ölßönÿöp÷r?÷t_÷v÷xŸ÷;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveContainer1.gif0000644000000000000000000002331610520670125021433 0ustar GIF89aÕ^÷ $$$(((,,,000444888<<<@@@DDDHHHPPPUUUYYY]]]aaaeeeiiiqqquuuyyy}}}………•••™™™¡¡¡®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Õ^ÿ]H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê”e P£JJµªÕ«X³jÝʵëÕMÊ{±C¯hÓª]Ë6í dãÊ[°Et[À›·¯_¤) üUÙ€ÄàÈ{Nl²0ãÇc.ŽÒ1å˘INÎÌÑ2çÏ /n}Ñ3éÓ¨ŽN-Ñ4ëשWÃvèz¶mβo+¬­»÷ãܾ ò&Êâ`‡YlX¾yðÐÀŸ.†ƒ D4À€wÚ%‚ÿ0 ]nôòÔ_š0Á× öQ P Åß›¸Þý|øüíÇ ëpÝ@ï $`‚ü¹ÐŸ  `yb']z-Eèatg ! t·0€v 0âˆ!Šè ‡Üa°Þ~ãá…yˆhÀ{)ªwÝQ8–…Ïa¸’}v`Ÿ.l`€ ² ‚pwPö¡‹U^¹A°À‚h9ãwº`nb€Pf§¦—y¤`z¤¤JRèŒ&´(–jŠ !y†êæ%fwû©IP9v"R%£äõÙ’Áý™™:7¥ ö¡à(¢ÆÿéÂŽ_Öú(­@¥±4'Ú‘€aìyhž¢2Eªo¦¢t%^'âŽ,ºø¨›hŠ(%£`Z‹% PСžr'b‹¤"ˆ_îh㮟κb²K-Û[³Î.Ç®rc tœ@ÖAÀ$Œ‰Â,üûo”†° ÊÇ/sÎ< úBŒ° | ½€ñI/¾ —œ“½º‘lòÊ4¡|›Ê,Çü’˶ÁÔS+Èüͳ٠T  AÎ:ŸÆ3l>%MtÑŸý`õÕXg­õÖ\wíõ×`o=ÓL; 5n"'k@ ´íöÛpÇ-÷Üt×m÷Ýr@6Ù<ÿ}vdR³–ôOì=øßažÚá=•㈚¶¨ë´B•G®ìä}fŽ“ †i5çzz.úé)Žšé¨·žê§ÙŒ0í„G·¤ÙåÎЄ…ç•-¶èDû‰ºëÁNÌ@ù1H,Qõ ¢«.äêA CD7šPDߣ.óÍ“n¤Ê*hLj?L_V³ÚoAƒˆBèRœâ0°Ë(ÎÀ „@Œ!‡LT×ò6¢r  Ø X€&ƒ# ”=Xp„ è¦Ç‚Щ ‚Ë1!5ÈABˆ}í+™Ê( ° P‰\?Š!„ÿT€ ˜ ƒPš(°ÄxQ©PRÔY´*)±P÷{“ $EZ‹ _\Ä;ŒÑLä ‘è‚ê…±ÜsÙÆ€17zµ(À%1j§ŒgL£›p˜:÷QHe¡â¡•D>¤+†ûÁàä ªV|$A;Q°$ÁúD@ÁðO“"AºÇI L·‹doH1ª“h´eñpi’“êrÓ+!”»Pr!Î É.9Ä0Ö’ÏEª§›Ýî东awÿÞ̈w¼P+/f΋^©÷2ìmoÌÞK™øÊweôŒ}ï[²üBf¿ü¥—à‹jÀŒ)°õ„àÄ(xÁj0b aéHø0®pp.<˜ k¸7þ‹‡?|›ûeÄ$ž‰û‚âï,º¥â®‹[·â¼´xƨ©1]nŒcÒèx.<î1h~,— mÛ=2ûˆ#ÛD`»dÀñ""c%ÆÌª2c µ o"޲2C˜L#ìx 4a &½Eoÿ`|©I0°Ð¬bYê—JÑÔeàí” ]^ –WäìyÊb>(–ï¥å“@ \áB£< žA <Øjë”À%"€È;=š’ÐVO¦¨CLìN-ïÜY…*\Wê딺 -Rk*Ò‰nl’a2§ ’ × å3yÔd¨H‹éÑñR¤…U(+¯«*¶©‹§+@X{õr¢í"åZ× ã±§ø¯GŠØÝ¶%W­(,Ê;ٹ㠤¥rœþ\§ž)U7MòÛWÞõKÄ4«æº[Xv¬Š­-v Gʼnª»)e(ŒÅ«V2êsAìó¡OGƒóîö¿N2%È–ÿ¾¼"¤s/¼Ûßq•¾¥‰ïJ¥¢t¿…Ôe6Ù2TgúN¶w>/’<Ü>É{|§ÏÆ6?·ûi$[Jª–· ºi T¾óaw´NÖ)kô£,é;qwÙ…br±8™"[{PÚ–·¤r· Ý›bwœ ïFß;Sß‘<íy‰à—BxŽX€l·òâ•¢€ ´åò˜÷JövøÄ³dòIA€å3OúÒSÅœ7›çSz¤D^# ›êWÏúE§ ñFÙüìi_{“%»ç}ï‘>—øMø*iýQ^ü£(?÷¸¯ìQp ú”¯"¾-îó‹Ò,`!®ÿEzjͶO%rúµÅ"ñtûD1 IXÔ_ WC[òjçFĤ6Ò]ð7¦"Mxoi…,=…€m$Q[RjdMµ>¢ÔFœ"cÂ)rÒ"TKÙÃ*Àâ-%efÐ,….•Tj•-h(Fà<|ÁDÄ‚m”QSÒ!-7=Œ5€Bñ'8HŸ4H{¤<dRÃ.Œ:¼4DC²IûA"…ƒL1`'—4…å\û§B[„‡i2T?•l³PYXRQ²Pð4»´;û¡BEïÑ&äÓRé„¶÷2I÷U—t0¼ó„¨t"Ö„ˆlF”MÙÿtVQVËÑmÝdn\O$‰«d#U(3u…yu F|1‰¡“n“!§J³b#7R‰`RK’WK¨*0@xTBbR‚fP"-G"·#e*`QøŒrÔr,Õ"*ÐQcD&@.mdEP:"ÐRf‡â;µÄ„PU…áA^ØJý´E&4$dW˜È"xÁ„ ²BÈÁE&Ð~¡Ã#ì2Qϵ‹@Ñ‹ûS.RR[-‡RäQ(%†iÌI `%&ÕVN¸µT„e-ÂU „Q5%ì†ßãn<¥Š"ØQýÒ&µ„’óx(DõŠÏ"QäŽBEÁ$€ÿX3IgR8Xpµ$’p><õˆht;õ“îÍZw¤>“ ôp!ŒÖ@ TmM¹>oHÉ,·4È18e‚ë3\‰–Tyh™l_I;Q¶>5\}%Q„¥?ÞÅ?ñ'p?#—F…©‹9Ù3I‡–w„ûƒ¸—‡‰4¸×|¶Á—>Á|”I–Ù˜™™l™¯Ñ™ž ›É¢9š>Qš;qš¨Éª©¬Ùš:ñš9›²‰´‰¶y›zš‚3™¼9d¾¹8ÀœHF|Æé¹y»™œ’1œ«SœÎIËiÍ9.Q5qØùyÐ;ÒÙŒÿ¡4Áâ9|gwž°Až3ažêiì)îùžšñÏžôéñó™Ÿ!±Ÿ0ÑŸþùú§!ZilâÙ7šê¢É pY Š%­&šr~jŸÊ„Ÿ)á*)r;ëÆ@ŠBl„Fér¢xèo‘LTòkœr ó…*²\­¡-Ñ™tô&("WÂGorn2$uéÅ3DáÂ=Òò!%2\>z›:Ê /o"UƒB¢¡RlàqNú0´.çHÝÆ…»¢qVê¡ ¢)á)j×"ƒ‚Fšƒ2âmƒ%€š²B1dsyeo9ê¦È§(á)!UVÂÿÒ±&%ë!"T"eÚHòhÎÈV×B)šr@…ê{<±E j¥¤ó¡¤*¸#Þ¥lb@çj"²'!œÆ¡™y¥+! ÚºJˆÚ«{"ªr|ÂÚ¿š¼ú]Áw¬à–ž@Ö4Cã¬cf¨á¬;{e3­Ôªh%slƒ7â:®äZ®t£7{Ӭݚ¬(±U6ð¯ò:¯]Sœ·¬I¬bñxLƒ¯ãÅ®'á¯axû¯Öj^Øš%P°è°‘°8wÝZHú:±ˆá°%Á°K±È¹"0?F10Ìa¡!²Í1f±§ƒ±$‘9AiF"Á!³cš‹ÿQ³ˆÖ£xCƲ#Q9Ÿt[r" ÇOHö?%Š@ñOm’@µ«¤Ÿ;+"›lPhºÌ$¹ƒQ#™h¹E¹ 9S¨ICi(pFWàÄO %)³R(T5P1àÿ¤C"J±¦½&eEÕ&5fÌ„=ŠÒ¢ê;ÕëoñŠÁ4W¸ZãBË1guÖ£ø±0“W-@tÈ‘A  Îûã‹T&¬’.ŽôUmÂìIED<'E›Û¹c‘-¥5g@4øoéKPÃ¥´B4% „@”XÜçƒçëO÷ÈÂ")ò¡¤ž–iÞ!¢œÔ(¶¦_ &§æ.[*ì¼{(!Tu(ãH.QÕQ‡Å.‚*‘Êl"@Š3§k¶MÚˆG`üQÿK”.LĽ'’Wd´FCR³N–FÄ©¡’‰RAÌkȆ@,0ÈÊ–.Ìæ)-ÿB¡r„Ä;÷jp23ñÄÅñDJ×@¶e0”œ 1Îñ1>åCžõ1r1Qùq"dhÖE¿;ë/q'hÎqf¥ÌšL¿GBrtK¹af+íöQ»¢Èä/”b¤†b.ñö ÞY±zm…éÔWR¢DÁGÌ"Å8¸¥(mf"#¯²·9Û”ÜÁŠ1^H!aÜœæϸ(5ÇÍÆ,/:Ý‘sœ"¸öœÐ< WKu›õ´ØU@Iì]_‡YΌλ^*{¬ÞÑAõé¼KbõcÊC‘ѱыL _=ÒsWÒõuÒ(} ]“ á ×ÿÒ¡†¼ AÓ¡v(!Ò(Ý 0š2,±¡ Óâ$ ÚHmq×Ó,ÝÒ6±4 Ôá<À‚iC§2¢n )¡(#Ô"PÂÈr 'J£b£#Ê¢_‰5êf^‰@}å~áÓ(ÍdsÕ.;·#Sk ]&Œ>ú-AœÂ2&æSIjR'ÞÁS}Z"øñ¤‘æn“=¥R’Íõ‚¡×Kfz¤MÚK³7 àßé%èF´¹÷}\Ķ„j+eª¦ƒºœ§Ò‚Û‹¬RsÑ!ÚÌC¥}Ü™76œzãEâ(vª¥[ò&ä8¦kÄ”Ž2Ì„ÿÒg±6FéÖ©»Òªÿ;(AÜû{C) :öGG4,;b5hò©5]Ñ$!ñ%¢Þ­@áÑzþ×SMÕ3¡)`vÉã- Òéã:~2*­_D^ä7!ä¡äJ^L^NÎ>x4Öx- x­;¼Ó¢ ‘´‘å Q¢!Œârãc>™Qn@ž$AâÌßCÊ ¡=rÔ= !Ürþ>¶JÍ6ûN i>ÜSî:_ôSúÿ¸@5t5à $A©C2Blö) ¼?ù㨘.D(t< Í1@µ¹£éÈ!%SË>t1Ì*d1ij9Ô±Jö}ž5k"e…¢>¾;>U&gh5#FGä"oG‡–v JWb#TìG"Õ¶ ¾ì¤*ì·(eã&üap s4Ž1è^èÕ 11'‹Ë‚Ò»>ïXŒQbEHJ}è&7¨>¶$¼”$I7T’µ\d4=ítoì2&þ.W×ÁC›;SìVJê‚KñëÐJ<ý;o!ÉG*ÏÂ)ž4eÐDì#¾ Öë$TýD%ö„RòDMVd†ÝùÿÔ“U Â5˜lßwN¬ˆƒàXS¦»³î‚~äÿEîán r´§U _[±5!•" ²ñu@èD?ê¸Ý5Ù“#E-´Rxh-uSF8@ÕóKTOP±å¤µþD¼Pu&õlÄÄ”&tƒ‰¬DO`FÏXß1BF¯6$÷ñŠ^"Oƒ?#-²"Dòâ>Aû×ãÃUxäJ/LVXR—häV]ÅUë±G Gn%!j@pbXðÄ*XÒAûU‹‰V7tI*ŃvŠÆ¤ú·óUCÐ<¤¶ßãœÝ¿6,æòú|ütV&g’&±‚'ùîQ;NÏæs[ºCv¬ÿEZËc[b7[Ò‡Z›5!ç“Zøwm¾"¤N›Z·³HÅ"ŒE+}ZÛÂáÞ÷ ö÷®¾  @0Á…  ¸0`ƒ ˆP °‚@‚šp±a!ƒ…EŽ$YÒäI”)MR@¡ÒåK˜1eÊdÐ1!¨˜™¢ÀL A…%j²A΢Iƒ"ô¨B!D,:0€¡Ã‘¨>|ÊÅÆ©.@*% E˲iÕÆT±aÒ—gú\[×î]Gñâ5ðp" „ˆp¡Â€– 0`L"Už€)ëÑ{5oæÜ¹,]Ï¡E‹Ô;:é[$6°PZ"ˆ,ÜÎî±Cÿmˆ­sÊ–ªÚ ·¦…'^tqäjK'/K3næÑ¥O·{œúu˜Ë±í0qûwðáMZ_^{yôéÕ¯'¿ûy÷(K|ˆ_ß>Þö÷™Ã×/²…€èëo@eʯ@áø+PA#é@ =SÀ lðÁ ;ÔB5+@CK4ñDSTqE[,±cdï'C»pÀ 5ä°FÁ±Gåà’AòÈë~DR©õûoÇ%£dNI)‡jò¾ùªÔ29*·œéJ/Ã3¦.Çt L3ÓT3¢2×4JHµV£€'»TŠ,´ ¢€°Ô ÈÓ$:˜8N7Ókÿ3Ñ‘Ðjº+$¥ Ò€–@0€£”n2áÓ¨dB6ctÆSrT& b„ÂÜʉ:IÈ©ƒ `Í*×ß’Wm "]]者¶6@«ƒ¶jÓʪˆêŽÎd[²57046¤T€uXX8R0ÀI¬TÕ[4ÝUc¢àÖ ÁLƒ+ÐL €ÐšôÍ×1Ëðe)"0¡ƒ .Œy .¬*z?Uª‰(m6ç$ PQ06(¡àƒ ¡&ÚW*JÓoÝTÛ…)¤w‘eÈ`};zˆ#´‰gm? 6‘1à-ØxµTdˆ00ƒÄ2„¨!Úÿ Î YW§G5ÖªÅõ«O±YÒÐjÙeidûLD“úÞ“)6Ø>†À#NoÞ{S ažø·‚2ù-ƒ‡€Œ~Lg‘ pÌჇü H]]KS<á–¼¦ôó·“t;u”dviî… è d„`-<Ü–og!¤Å.ü ‘ÍmçÇyb8\ÇöúðƒÐ‚ ¶ãY0•É¡&‰ >µ‡BêÀi©f½íñSr]%¡…¦~ƒÇ_kÚå ~Þ­"ü±Ú ÊrsÕ†–pÂÁ*$ ° õBF+J¦#Øc€®Úw™°1&R ÿ 7·wÑ+'ï*ßv`vÿªó¥Äkö2Aé ‚‚;1„gáºÓ§rÂØÐI.}saDúöÈ06RQGÐò§æ0"{:!¨jÈ‚?Õ°00ô ªÖAê|Q!L N6!ç<±Rt‚bW×ňP%"€T…|“¹€Ñ‹jlTÜØøFûH1Qb„c§ôE5ÒÑŽ{ŽݤG>24~\ yHÍRM†Dd#ƒG02Ò‘“$‹"Ó$IJfr(–4&5ùIA²‹že)UÂÉ1‘Ò”«, *ŤJVÆ"® ,eÉJZzÉ–·4e.·´K^‚Ò—Zf059Ì*Ó˜”D¦””¹LG63JÏ„&"¥¹$jÿVS×DR6µÉGnɛߴc84NrÂÑœ=Bg:Ù¸NµÓ`„gä‰qžê%ïY”è†0±×>ÙÏþ“8 ÑçL²-ƒv¦ž2R¨KªB•îô‚yÌÎ6•2ª@‹ °ÝÚªò«ŒV Ã.Ò—ˆzf¢1ª¨J8 €&ðÇиí”1.œô(¨•@€*Ÿ¦TP §"pˆN1˜&¡å«iJ`:– 5,0Ýf#À¾ô”¡Ÿ*¨Ö¸´’T¬}yhV%ºÕñu%_]HXAö˜’`§ !bªÎ}î§$=΢2× ÔÕÿ®›™iˆôz¾^åiUEHc?&Tƒu1 ÉA2›ÕU©M3@iE»xÄ“MKe=tY“ŽP´}¤qK]3Ù¶C×%K 4‚Ýûh·BÜ%ˈ¾ ^÷ˆWBäUŠ`t^ô¢G½Zlu_üæW¿ûåoýû_ó·%‚o|ÉWG$  fpƒü`GX¦p…!|à-0pxæ !ö&åÒ0;ü#(ÄEyJ|âò¤¸@+Š pÃøÀp¤±PRcïø†ŒL|¾2’ňIÿ†ÉŸì*c²Tèº ŠU+‹Ä2éÊP<"¨+êä2NŽ)”Hýi†yDaHÐòÚ¢üN(&0È'kæþèqp©qÌÉç1S€zkàÏ~Ú@ß $É —Ó]‰ÌÏ {AD ˜'")ü»Ì£é Ý.–0“~Œ‰sFÔAº%@õFÕÀ¹Ý¯¬ÓãñXÍ‚¨¹e{ ôÍDÒë ¨öZD ]ìyTÛcõA`å–bCÄ0Áy«jLõ.{%Í*$˜ÈXm0‹`×âˆø (lžLÖÖ-LvÍ\D€”#ããL‘zO$PN„þ'’‰¸E#Â΢ÿ[‚öWü;"TËÃN'sDx£²”ï þÇrj!²JëýBÂmàùš¶xÖaw™mn'°!Ùe ÓrÉM„jÙÛšH6õ)]á$y{ 9¦qù!‚ÀaB.µò–¨˜‚uÏ ‘•wdÐ&˜W±¶=…¯»Ž&'ÞFM³BoÀ*{¡Ø8Ž6Ej¿ÙŸ³¢žtÀ17©9ð”'…õŽîç:ðð¼lîx˨ôTèQ!Ë`Ç.ÛÜ*>òY§Žë¨fÈ@¬g¬{${g1•æFD…cÀ s¢å†ÈÜ´dN¿qŒèCÖ’¨1í6¿±wÓ  ­Uk^O©˜£ÿ&÷ˆ°„éŸ ²±Va—ä÷©uÝÙè'åGþmzˆºÕ˜åè³;Ȳ\¾}z¼ýu¿>߇Äò—_BçwOúÕ!ö¯Çýï/PüÕ3úÈþéÁþ?$}¶é?ÿ‹#tÀøØ?ô8@D•­k·¬#4ŒÀ7š@ñ`@ Œ±d— Ü@zêÀ˜ù@„"  ,AA"AŸ|AÕÑ>,'œ"¼A¶‰Áï˜AŒÜ B.ÉÁ9ÚA#<•!|%\ÂDiÂëB ª`²¶ —¨Â¥‚(wóÂ÷“Bê Âሊ,’Ð;04‰«ÑÿY ò?1œŽq‚Ÿò³ª½é¼Ú8.I!èû2°¹CaŒ‡-„@|3Dèbìé4 —šhÄ‚>„é?AÄ{£¿9”Žq AÃM‰­½*ÈÒ èÕ ©øñs1 Ñ¢:¬qEE Ë *»9)ª€ĸA1ˆö¬U´EÙ¨ìÄèøÄ¤¬¸Ê Ðê(Ñ¢žœ`Œ©1€UL­ð+Öj¬°+À»jÃÙH ÄÈš¡¹ÆUtŸ8Ì?eÜ'TŠ¡ºŽxFÍ‚,¢"ДŽ[ÅݱÆh«¤ùo‹ â©HD©`9ˆ~ܲ¡jGNDÂ?ŠÇ¤˜Gg| ÿèÃÑ;ý™6‚†±Œ€Š¬qÄÆ@iȱ  •Ÿ:ˆƒ¼ž •« ‰,˜¶X4ØX 2+¿wLŽqˆ©¨Ç‡àB©ŠPX ” …øÀ©ž œ‚Ø2ªÜ²Ú.ÜŠ‡1§<©-ÊŒHF‰,$Š„Â4ùIä(Bµ¶,·|ËшKâ˜ËˆP£Ë½°ËáÀËYØK¾¬®ôÁ$ÌÂüŒ³\¤´, ÐÅlLÇ´#˜ ØLÎìLÏüLÐ MÑMÒ,MÐt€©LË, ¿ŽÐLÓŒMÙœMÚÍ(‘ÕLŠÖ4 À„ˆÉlÿÜÜM¥èÍÑøM8Nâ,ÎǼ¤È `ÎætN”¨ÎÚzÎNŠNíäã "û #(&s¨†2‹ì;̤˜2ë[ ìKŠøÔÂn$Š/S®™0 èIƒ OñNèÂ*»X³¡h3L‘6± 9S²:[ÃþäÎTÐ=¹I4bIµÇ¹2BD[4L sñ^ÙR „i­ œ„è4ïø´À 5K ®¢ Ÿ 4 ÝV{œý®X{2}%µµcɵx^K·_K7a[A‹6Ê œd{ˆeó¶Ú`,h³¾i{ˆj£¹Ê¶ŽØ¶n³f‰ Â7…1·±ƒÿïúѬòO ñÎw“yžàÈ·MÄÓ}û3ƒ‰°ö‘˜À)8±‹,„˺>i¸@YT« Ô…ùŸÊ Ñ»8O1<;}‹ŽÛÉÜpŒpÓ2 ÒZòΓÀ”ƒ=á¹—S˜˜{—½qŒ { PÉ9k:ð9hº+ó¢3:J1˜¤#OMž«Õ§ƒ.áÉžO©º¿bAÔ7U]Õ®‹¯;¼g;Àá³#»´³Ñ»3Qcy;>º ºð¡Àóƽˉ¾[ˆ¿“©!WÂk¨¬•Ä#7Æ» JÐU‚ÓΘ¼c£3Áù½ÌkU΃.ƒ âƒ×#½¸7»"Þ[½)kX³ØÓX™=~3ÑýŽÐ½Ý‚>–b ‚ ¾ >ã[H>êòWÎh¾WU#èkYhý%­>8šO­ã1~ýÎð«YbêYŸ5? M&¡Úõ+Zg:Z¤…?¥&¦mÚú{ZlŠZ©Õ?ªí&«½ZýX`L5J€óäÚ*¡ 0´M[µ][¶mÛµå€ Û4Y °0»½[¼Í[½ÝÛ¼µ “[À \Á\Â-\Ã=\ÄM\Å•¥€;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveApplet1.gif0000644000000000000000000000607710520670125020743 0ustar GIF89aÊ»÷  $$$(((,,,000444888<<<@@@HHHLLLPPPYYYaaaeeeiiiqqquuuyyy}}}………‰‰‰•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,Ê»ÿ[H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÌOH`!ÄÀ S¬ðÉ´$S``€R3, a DÓ¯SdÈÀ¡ÅʶàÁƒ@B 0ÕD–ÖJFð×C²0ÀÔ`ßøAeûˆhÚ<²@€ÎlÏ(‚qïhqÝ8+Þªÿ0ß4j øŒgÎ!¾!âŠxÏ$â”Wnùå˜gžÀ™wîyæ$DÞÂ|nºéXpúê™/0²â#4` tË7ãæ•98îÌé8ïËù~{â¹'9üyÂã ¼jÉ×½|jÍÇýSåc}¾OéS½~Oí?ý>Oñ3=ÿNõ}¿Nù½NýsÙÿp@ ð&4Øm’@|-°& L×iÁlMp&dÖe’A_m0&ŒÕaÂSð%%ìÔ ]’ÂH=O,ÆÛ•Y §BDGÑÕ@Z(¨çYÀ4 © |ÿòÙ1ÄFbAxh¦ç%HH*B wN" FÔ‰QtÞÓU‘:ÁAÍ…JÔ‚).1†Î#Þ@F`ÊÀË4‹“ 07¦å¼ŒYÚ¨GÉ@¨. TÀ#¹ÌñŒŠ[‚:#š¬ Çí™ÎtÊÕ@…HY${´‚0Æ;ı T É:±LŒð¸3! è?Ít¤âÒ¼†1â+=S– =¥:²Î cÉÁ‘†^}ž2 aº…-‘|W1r!¯,ó)°9Î/í£2 ’U<&AR¹$àÙ¨>òz c$éìñ:õ±‚ ö1tZžñc,ÿM¨ì†ŸP‘ŒwˆFé©1=BBèZÈ"bµæ^ØúÎX”Q„>E.F©K±€ƒC¶¨Å¡ÈÜS‚D`R„œJZáC$0Ð.ž¦"(%’JYÓ!Ít%5õÑMU’Óí4%=åÑOQÔ õ$EÅÑQM’Ô-µ$M¥ÑSIÕMu$U=ÜH™WPëmz]ÕÞW©Vï{eßY¹—Vó­|mUß[ÉW÷Í}u•ß]Ù—Wûí~}Õß_éXÿ …àaù—X.€Uàc YN••àe˜Y n‚Õàg)ZŽƒ¥U.€¼Ôž €Ûa`K6¼ÿe€{Êmž  Ýú¶NÀT䦦âvÉ0®rµ$:“\µ¹ y.t=² LW5 °Ùu¿b‚l75ø.bž%^°H·¼é.z¿¢·õ2åqîõ _ŸÀvõ½‰Óò«“¤Õ–¿3Y-€sB;üX&Õ=ðM ¬`›d·Á6Y[Kң΋ 8dH…2‚Í „Â=aABÇ“*Ä6cˆ 9$ñ”±JK bâ¤`{;‰‡L:¢.¶ènYÑŠD”Å+z…@)Ñ…TDãpfŠ+p²rTÄ™(dÈÜy—ˆ8Ìç¤ ø/H(d€âà-!΀^“!Þ ˆÿ7þ|×:EsæÌ0R2šL±æH´tÆ1ð€TÊB¤ð“ãͪ³›;X»"湊cÉ=Ú¦+-*Ï:#S OJ€#æ¢#f€NNe˜F@~☂DH:WYm®Ÿˆ]‡2°¡ P$ðÊÁ´Œ' €˜9Òåâ EÕicÒüsá8ûy ?‘#È1`™Å¬df€"Ëw¹³:àÁ#¡ÐN« GËr’kGR(Ùz¤.n¡M¨¢–@ÓÀ±cCÊȸå8Sup”âdBFó-²qÏ«¥9• ñ:áx¥``¬“w$’ágqâ9OMH6l<³ý#%¹ÌÿâLÈM!ìð3¹ä^L¸ãÎèðóXž)TX¬mîx&Õ÷WP°€«‰d,÷æÕDß2ÔŒE¡ mz‹¡r‚eË:Ë·fÈP•‘¥ÃIO×Ýã–á «Ã+к[@ ͯ°¬úÊ~x±‘dà82-@ÝyÂ[šÄ’FYR (P£C8&(€@ÖÝ‘O ;!*ØÀã]V‚àŽvɧ@7Š,€’g› 2€P€ñžÂÀœ´wˆ`ÀI Ÿ¼ËPÀ55­ì7²y?>"ðSì릂ÛM@òýÄüæ;Iξô§OýêÏøðW½ï+ü1 ûé½$++òz|ü©ç|E>zô[Äñ‰üîÝOÿúÛÿþøÏ¿ý;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveClosingFrame1.gif0000644000000000000000000003271110520670125022061 0ustar GIF89a,È÷ $$$(((000888<<<@@@DDDHHHPPPUUUYYY]]]aaaeeeiiiqqquuuyyy}}}………•••™™™¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,,Èÿ[H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£JU:â‚Õ«X³jÝʵ«×¯`ÊK¶¬Ù³hÃjH1µ­Û¦¤K·®Ý»xóâ¥`ÀÄÛ¿€…²À"°á–&^Ìx& #“¡@²åË$cÞ¬‘2çÏ +jMú¡çÒ¨S­º5ÁÓ®cf-[5ìÚ¸#ÓÎMú6ï߀wçì{¸ñ¨Â[.®¼¹ÒäÎ3N}(ôê§cßÎó:w·Ú¿‹ÿ¯é}|ÔðæÓ»,¯¾)úöðO²Ÿô=ýû çã/j¿ÿŒúýT(Q€©  6èàƒF(á„Vhá…f(a ÔW™ n„ AP0‰(¦¨âŠ,¶èâ‹0Æ(ãŒ4¶‚ E`ˆ<&4¢@%°] èøaH™DDÀF&)%D?¶Ðä“QN©åBU^¹”Gí¸%]:ùe–c¦IP™XFdBp²%‘˜jÈæ™¡À€ö9À*DDgÿ݉˜MpÁHP è‘„Žihuˆ6@a"™`À£‘ª9)u•2êG#êÖ tzӧѪ«•ÿ éf  ªM¬:+B»Š¸¤i³.åA¤š­-l`ë°Å¶PB[A €ì­2åÚ\¯q ௙ºS l°B›#ºêžµ¬Ð€­µ–€­cà>äå¡y‹‘¬Oy@ÌÛB ŒÀŸÀ ɦjuªL¯ÇqCƒªñHT— ¢ÓÆA-õDm»mçÙ ¥ÝêÚ"Õÿmw¡x/¤·®|‡ä÷ßûÁ=œ«,¼ÛíÆœ–B( Žkà ¾-BЀ½6”ÁÕNzíÁÕ!dz ¦¯¾æy|Pn¹ÅLšÉïA Të9è¡–¼Á„ @̶mµÈkÐáoià»í·Ë ;BšÓÜ"¾Wûù¨)xÐ|ÔŽp´­Ð tuúëO?œçýøç?á×^yö,Qp !ôUL6,ôMbJs_ ¿‚œ }:€úÄÁz°ƒ ìŸ@•ð7°"AøСPk s Ë–€”L†\Óö ";£| | P_ ÿWrBÞÀŠxì@‚G,„M«3ô±œô¬¾.r‡±@µ‚8Ä–17°b 27%aÑ0|b¸CƒtïiQ"!‘Ej\#/¦»Œ=¤Œ¡ž¿óEÜÈŽÀ$| Y›C²­±#DJP‰$`ÁB.9E`trBÌB¬R’ "'ÁäÜÆHÙ8²oˆ$B¶L†fXÚÁŒF.g)Äké¥E&hɲµ26¯4\,I,‘dÀÉJ]Á:Ý¥ U èc BЀ,-` ™ºi²ä’dïkÁ'Oà¤x ›áf6PIyBÓLÈÑ*ðÿ΂X3öˆ;á™´T}͘ËÈãV¸ü,s– AÙÄJ'­ÀVŸ#™AíµI %`ÍÀºP–Kóäœ 8] z™ËšìÙ žå«­à\^;¹–Ö€}z3—<µ×zúÑs¥À¥0]©D‰É´cº&™=ãHF`&[ÍÔéÄØ"²‚åh %Á±N°gVà£(sçk†²„}ò`%Ø€™¾ÖS÷yMˆ¹üÜ'yfP‚å2GZ­á{ÕÿËõ?’}%ÿo±Ñþ'èØX€@q€m‘€±€*AB HqG3h&0F˜'Gs·ÄÈ%ÈP!xS-$X‚á€Sz1ƒa@ƒ88ƒ Ð?-肃R!ƒ98„XaƒDx„s±ƒáCàƒÓs‚C–‚†±‚À„Nø‚P8@d…Wˆ…”—o–l^ø…`˜;”F˜[f†W„†¯¦†ç†Ç†ÿÆt'1^qS121} eÊ·‡„„Q!m°öEÿU§ãÀd-ЈÁ}e÷d Q‰SˆYˆB[(>†÷ç6•5œX§ˆJ­ØÈ’dibˆPˆ1‡Á3ʃvNt0rRCgµpœ„2vPó4/©óagE C†0ÐDI'ƒ2óâ$ÝTYÊ“#ÊC:Îr2`XÌ8Œ-†<ÎRÓx0åäY’ŠF4Š Ñˆ_óLÛå8ô´Oî£XC%/Y³4/u4´%Q’8íUóä>G£wÉòM/F/XE…X²u£RISv%Pâ”#ç’ÛÅbU'´ø¶˜ÅfRF‘’˜^K#Q‚7/¡¤Ue5/!#QüÔZ ÿç,²x‰I¦uBD꣒“^•´Uè’Wõ“!#2`S©Âzmõ“ –"éŽ`¶4E.©ÃMçXŒxQÌ(MIVEù5Lõˆ¬3ZG]È’a5Ä•Ûô9@¹]WÐt-¸E[ €eV©ó–%'¯Ø##é%‰ÅvNôÔ\ç²4ä¢w µŒ'Rô’Œ¬ÕGã$ÊÒ+IÙ$Pf‘Pç’9b+Ž™"UIåUç—#ÐØY+S`‰?c/ŸÔˆZ…,¨ŠvXpc8ç¤V@`_UW)ÓM¹d«äš)•*éÂ:ø$uÉòUêt5ºÄMªÉ:E¹dã$ÇÿùIe~–#ØT:ÛYvÚÉ: Àcòô\ßaí4g[r˜M‘˜QløX^"ñžé«(%øÉúiˆ0ªg…ZN± IR Kq ±†tªJz¡ÚœK7œÚj *wx8¢$ ‡•'‡(jjViHXÙ¢u¨¢bÈ¢2Úš:z£(‘£H±£s‚‹>Ú@zBŠfEJm/ÚH1º¤ÛÖ¤®ô¤P*nRŠLTZ¥év¥O•¥Z o\ÚX^ú¥Ï¦Æ5¦dŠGjIZGDš¦ÿg¦l†¦pZkZmšHu¥%ŠR¸§[Ú§ x¢€j¤rŠgtZ¨ x¨ÿ–¨ŠêwJyJgµ1SµÉcÆ©C1© Ñ£9!NGÓ?÷ {ŒjhŽÚܪKY˜ «jª‚Š‚„Z$–:E,Ð4:ó’ö——µÒ>Êãp®•4î'»Z~ >Íše“HCêøÇb¬Ì*>²J£w(¢5a2¾õ”ŸvÍ!P;ç‚2Ü—ăU/e[®Œ-“4ê ÍʈéÊ}i-¥”2 S/%¯Ê’õ™‘i‰£©BÁ©ó¦'AA@b4»%1ž‡®6:.É>ZÙ2ã÷]u§]«Ú¬­ú3Ã>¥÷R‹®;i9 »žê, C2,#D% ³-ÿ‰®E©4œ§`1Ü·2+p²ïªÓ->ó³"´±ˆ²Ôwª–ª'Á}zâD¯¨™q½§«°0óLåÔ³--!-»´®U.ÍêW´u‰@6bK¶BK,Øy;+ -«/램6>v5ê›D·{&‰æh^Øx0èyPÓ˜:€ûYÝŽìé«¢9‹6“ sÙB¦…ºo§uûw›ykŸ›¦¡ë£‹¥û¨tã´šµjÚ†šº=±º±Ã°I‘@´k†¶Ë¸k­´¾;¢Á»ÃËCº›à;Èû».¸¼:A@p–½ÚË ´½Þû½ÿ4á@‡Ö› 3f껾'R?ìû¾ðK#0¾Éë†ç‹ÍûÏ‹[ Óë¡÷{ùIû{ð¿Ê »¡&»GAõ‹¢l,K캗3«QX«l\ÌL+ðbE!°keTsû E‰£À¨ÆÀ³!°Â‰Ã)ã«§ãÂ*Q^¬—“ÁOŸ8̹üô˜I)`›aK ã‡ÜÅœÄc'ðN¯Šer‚©™ä‡7ÕÄ ²”d¤Å@â,\EÅY&ÅãJlŒÆìç—D@¢XÒ6^#MöLì1KµÃUI‚91ãŸD'xÔÿè>ßT0º(š äšýè5ƒ¬<Ì#‰òòÈãß5:þúIÐ2:°3 fÈË8T/g+”ür•ÊÝXVE9¦ÕV̳T LVtNþÑÇ3ñÇÏKOùUäeW©D•ñ´|)aôIdƒc(c_ÊÙV9B^Y†[ý´M<£wå¦Nˆ¥Kü„ŽÛÍÊSU*Ä‚2–•ºü.=“Í » ô&»•aÇÙ‹Ÿ#‘Ð)raŒ0êÜYVsN0Ó`ãÞuä¤a)CȬHŸ©œC¥UÀ”c Ç3×’OÄ^ -|õµÌ¹q`_Üw¥K$¥KºüÂG,ŠûÄôWf¢V"ÿõQ®õÑY-ì$‚—.ÚUѲ•p_Usì%QÏîÔî“p›ÌTk/©aLUCzYˆUÑÅйZQ.§>:]]! Í? ˆ|LÏ»&»Ä4ArWyC?ó<“˜Ÿ EÝ|lѳEÅa4:šT?¹=SÃgÙÄ{OËêÕœYXèªIш®ïÂʃårMľ:Ø•—"Ä I6.çÕM2Ùõb)K¼,¾\Ä´b´e.ž q9s€OÏt"žùUG[+ðUX…#€&¬>#I*=»IèHÂæóUÌ R©”SôX]DLÃÕRÁí™B RÃ#V@uÂ#ÿ=eõb_eÛÌz4œlÚh-l²»Ü\ÚnÕ8QŠrÚ1‘Ú!°jÀÔ71ª,­­Âi£œô ö=àjšÞÏ&Þ- nm ÞàMóàÝán6-ýŽ/}á?Qà/qàn€Nnâ&4âëVâ&þ£(.o*¾â&áá.â0Þ2Þ4^ã;qã,‘ã:ž<¾>þã«Òâ÷âDU¢žä@nä%‡äN+P>{R>å¾’áW¹áXŽ¡Un}WÞåÿòåúæbŽ3d€f~æS“æ¸æþǬ̺ÇÖáæç%!çÑÝ+­§š§ËÁvƒx>îßÿ4 7^cÖ!ÅÎbÇŸ : Ǭ#]ž :'0^3eÝ+EA®C•~‰N VŸ>SOÜÅŸ>´¡ê@âÜ’ŽešT<˜A.¥”x¥¤bÁ EŠþ,K³µµÒ2q+·ÃR+ç½GKn¢ÜÏb-xYbîSJbe¶é¼¬ï ´‹G2ýz‘ö®ûúë—‘47ÕSò*­Í"0,£bà„µÄCQÖþ`•Tw^®å0Êå?1äRI ãÃ`eµ´>P`£èã'­ƒqà®üJQkœ'AYƒ±0»îg4·Ïe-óíõ¾ì~šÄ@1[³æd¶ò׌±:ÃBSăZ¶ÿïè‡!r|…,¼'ó¤4g×ðu·ªo×>`ìàöî¤øîÓóê°ì¼ZµRÇîêÁ}¶¢0ñ•×;ó˜Q®Ý”¾Å²µþ˜õ;Ÿ~ÃŽ—µs‘»%Pвò^ôSzô=AAórV¶™`/0.Ç} ʦ‰ª<µ#AË“ö£0¦µ¹$D™ ·¶A{St}4ê´‚m4åÉq'¼6Œá ?¨Í¿a‘‰%µa5¬OÕÝÍIßMúÑíø‘ŸK¯:ÜWµqêöX ÷iÊ55wûO«ŸÏæ^¤àKçR¡ï²|.¼…n$`üÀ ;%ð?±¹Ñ<îÝìGóæÿ¤¯ÒüÍ_*€AÐï„å‘þSýzܳœ42ëK®ºê@BÜï,~éTLëM )Z ,qbàA„ .dØ@Cˆ%N¤xp„‚Š5näȰ Ft$YÒäI”)U®œˆ‚€D # Ø!Ë„#„(p³ÏdÙ €=Øp"¨R¢J”XÑâé† h`5ÁÖ ‚¦pÔ'΃Ñ®ex‘íÛ”@‚ ×î]¼yõt)qÂ\3m¾mP EÃ-taE-Ž–È`xƒá°-tž :7ƒÕ®-<„8lX©Ø“3o~«vïA#dϦ]Û6ÿm nÏÎpÁ÷oàÁ…'NAÁqäÉ•/gÞ\ÀÑ£?`ñÚúõ†,8çÞÝûwðá à€ôgq¦€œ!€ V?„,){ nmPxCÔ©ª*`¾Ä J>Å ›Œ?ÿZk.&é"”pBéϹàÎâ:ô°C vqÄUXÈÀР:ìZtQ2c”qFk¤íƒbt0.Ø@=–6Ðê«ú”:¡‚Ç"›¬…° é+‚Z ª„\ª‚*0í3±ì+JÉà`7^¬È-3­{$YLóM8ã쨯ˆ> G[ Ì„!«º+‚%uЬO*(ÿ,…)«œ¯½­ìr2!-@ ¶\“óLŒ6µ‹…ÚôtTRK¥3;ðÚé<¨ò  â[ÿÚæ«%ûàƒþ“ºé\‹ý:ä—6"¹dOÞ6e–V`lc–N8%¹*`ª©Nºo›=~R/Z6¬B7è*1"(°ž6’â¹€ ’*òüæÓzªüZ;„É‚<ôZÛ@cÓKˆ`ö*¿[JÍSY¢³ÑÆNmmÙ^)‚‘€6Z ±?[zãßû(„‘R<ŠioX•׬ôf‘x… ˜·hî²VºVƒ€zx͸z ]½g=ì˰Ld»jVZIÏ;_±NX!…¤j`„ýmΡI@ 0í 2_ÁR¾–+Ëp#HÜñ>C¥T HaÇÿ’ÙE¤v¶³î²¥»”¤àP†Y\ãF®}k¡aîg¥$N|Y"T2´ÃŒ¦€†M6иÕË=xËßèÞÃÆÊ€ŠÝ¥–ˆ7ÅPI…PŒLë,÷%*y//TÌP†rÊ|&PÈB"“Nh¦9÷"ØÁþ $‡ËadÂÒŸœî_w«ÚRRÈ•„"#$á^LX-¢$l*ôÜþúw¿¬ €`<ˆþøgCʰ‘’òëޡܦÍt…”‘ñ¡!IÙAšñ޹Êá@ r¨Ò1ÅsЉåM6ȤÆ|­rÌâ3»$¦jhÙÿ¤ÔF 2ÓV©Ê"ãÁºÿ]J3Óf³.•˜Ç°'V—bå×9ofÑs‡z¥ìʦF62/”V$OâÁ ®±„*+ƒ}Fæ‡ÌÓÔ:v@ÞÄ#p UilÚ ~|ÌOߌ‰G¥!Æ ðûÕE…ÒŸš!Ò0Ôk'\SÀ¹çuI! {˜™€Ï4zªÔ`f‡¥ $ {]á{h†1æTj„êEG0 Ü„¨ˆ±Ê@§´Ð$ò‰§<ïBÏRÙÓ$¬Z4qÚFj–i¸Ä)Ly©5„T°WŠqÏüŽõ™Ä`ˆÝëXS½¹ÅŸhPx†‰€ABWWÉ„E ÷[B©T71ö-‰IÌ ‹´ƒð/ÿš e%Ñ]6«*'àl!m†·€ì!-i5Û½‚ ƒ™¥,ïp¢È†Tժђ—VKâÁº4{,kÊÊèÖ¬`¬Ô’ÂÐÐP.P ÄTR³çØCñî¸'`Œùˆš©¹'§'0\­ ÓT਱\Ër*T»>U§¿ÒK_‰øö„ s¯‘Øk§ /ÍV/X%•mIb»JÖ²ÈL-f•ZË~i›UíAò‡¼uÏ–ap2ZÑÆ,o6s¬ARZ^!Ó±˜²eù‡J½œ@Xw)ÞkÆÂû",¿úÅ Gåߎx`ï¥1^¸Öc|Á–!²2Klì)wWEÿ¾Ë Æäv y!D†2JޱtUYË ©€ÍþÉù˜o!—yJTSR ±¼"aÙ€˜3CHY!TÞ2I®,§$×Y¿;ŽÕW9Ö GdukÉ@V@ˆP2³9ZEäœ:ëy#wŽSž%-Ϲù°–žëO—Ó¼µ†,^Jßúd8P7© d*'ØŸôGÍÝœØaúƒ¾*Õƒµ”’zÄø¤ËGŠ@_IØ8Çxd3¾ôI( 'K7ma[çÕiÅeÀõ`-T«˜~Ld©U°¤Akjò~N5s¥ÆÁþ892…, á~r7f)&m`·ëfˆïûç~øí\bj*ä É$žNu1£žE¢jLуt4¤k›ÁŠ—€Vh͈ÀWEð„OúàYÎ9sT@Žôņ©›°Ô«WñJ3²‡Ê U7 n©VH"šz†2¹):—ëâ(ƒuÍ"}V8OˆÍkBöžSäÙoBxÚÛuR_I¼|I« Ü¥ÁfeòŽÇò‰/)ÒêÜcÏË«V^4‹uK{ª^»žñîŸ9ôãÕ,³· Òn_ÈÚÓÔvΫË0ÄÄ£ ÃRŒ‰ôi‹Á®bLýË"ºšåÛî ONL§.°™aÁéEÿsîøä4,R[Œ«§âÓ·Å5W6íÐú†xÞL ‡þ¶.-SgD6ÏHžìèæ‹ðùÕWˆô_D}òW«r@>*Ç>‘ r$ó›O¿ù]„þôK‹X4æ_ö%⊘¿ñË¿°¿Á?LÀ ¿E@4@ì@@œÀu@ œ¼ ¼@¬ ìÀèÛ9Ayú@Lˆ ´Ž [Àšÿ8ŠØ¡¶%sÄfÉΰ•ÇàÃA•4AD| E´ŽAŒÐ ÄHA´ Bá pÃÆ‚!T¼”£ÐÈp ®èDRùÄ E¶Å×€ øÆÂDð€ÍðCš™dÎ(Æ£*R,]|^ä@_\ `Ü‹¥øR¨¤Rˆ&)&ኰhE*ù§.©FO¹Æ ÌF´ØF½ “ʨ L oŒILˆ|ª}”ÇB bLxŒG2C„>zÄ {Ì + ‹M ÿ› ûx ¡X pâȃlÇ‘òÆ…”y¤Àˆd‰‰Ä ªh–—‰°¥ˆ*ÐJ-Ï15˜|™Ô ˆ?+IlÈ){ÈÐKÉ•XÉi³cäI«:É J• Êûƒ=¤l$¥T@¦L §ŒÊœÊ¬J”¸Ê!™ÀJ´ÑÊÔC&;°K…!Ë 4Ë"{™  µ”¶¬?¹K¼¼ËÜÈK¾ìK¿¼ ˆŽ´œKu©K)¼ÄLLÄÌÅlLÇ|LæèFÀ Ì ôÉ9JÎãÊ“ðÊ‘  L޲Lm1ÌCtK cMÒ¬AÌ„4Ít;Î4 Ïl‘ ÍÖÜÓ„HÔ¤1ÐÍÿÝäÍ׸œÍ’¨ÍáœÀÞ Êß\NµlÎÍ|N¶ˆ¿u[‹ÀŽ-ÿy ™Šˆ²x sœˆÏð€Ë³Lé”Mê\‹ÐØI– ÆŽ£¥ˆå’Ò㈤Iv#ÍôL;ä$‰‰ü¥} þøŒ €€Q5 QPƒü Ÿè¥ šþ ’³€!½£º5Ĉ*Ç+¶ƒ¸ÐwZj4Ï™‰á8;"]“ ‚Ïè,Λ;ÎõÄ \¨ª"Ê»&*Á»:ÚÑZ™8Ú ÷k«¤¡½t;4²ªÜâkzÇòQ7þé;ÅЫ ª`"R?’©9Œ€qQ±ìÏžûÏŽ°ÇÆ`5 –š¢ZÚ¸ÿ7T-ŽÛ1!ͤrª’˜ š8ý¹Â黨Q¨hÓ@:¾Ðš·øÀ8c½ý¨Ó¤Ñ&•Ã/ÅJ0Í91å{¤¾Ê¡<ú˜72"Nr*N- Êh§(WJ p+!•©+¬¯‘#7ЧX p£ºR1»¦O:U­ƒ«R‚ÎHM¸I݈JžÈˆ«r&¿ë˜d•ŒÓX!»© ¬X'v<×C+ù´ L<í¢þè‚)Ð¥€Vñ:& µÝüÕ‚ VÖT:ŒÅPVó‰ü½gнUœ!&y”ý8¤¯89¡±½•CŸpk*+½+€5¼Ð@ ŽÌ®¹ÉžÅßs ©·åDWÿiSWí+CBû DÂ4í$‰x¿s…ѳ“ÑÚÒXöÔáT˜6Y”ˆM3´ØfÃXNI±Ð²ªœlè„ ’Õ<˜ ÓÝÙ’”ÙK£YŠPN¡M?¢•4£”MÚ¡íÙ(<Í“…ZÂ\Z=kZ‰@Z« =¬­3­®íZ·ûÚ- [ˆ[²í9³Õ2´mµ]Û„kÛ*{Û¶xZ¹­Cº…2»]ˆ¸ÍÛfÛ[&ë[…ø[À•4Á-2ÂÍ ¼=\/L\ [\„0\ÇÝ2Èí1ÉE—Ê…ÇË¥±Ì=–ÆÝÜ&ì\ýú\Í]Ñ-BÒ-Ó¥ÜÔ-²ÕµªÖEÝ×¥ÁØ•§Ù­]½•ÚŸ•Ô Õ]ÿÛå]“m×ÞÙºÝFÊ]ã}\á¥Aå]^+D^z^èÝæAê­^Õ½^Ì^iûSÝ¿Œ_è•^ÛñÞfÛ ŽtO‰8#íå î½Áß%•ÃÒ¢›ÕÉ‹ÏIÉê ºjÉš<0ã™›ÍGª{_óEôÝ–â ¬§ +™ ¢‹7‚ %ݛԊP¦ ®4K1&oOãMà’Y`m9H ¤HE&)Ö B ±À"ÊIHõ儼 s³áv©€|ß0aˆAál‘‘a\Ú/!.oì+olMüÐxb±°;YýaŽß$œßQ1b/) =Râ|œ þÉŠ¤À’ÿsR™‹‘¨á5^¡*G b.ÖB/ö0ž  {.¡œ­0 R¼ÄÐ’k’¯0CcC>+ -ß;Ã<Þ”e¡¼a)ÑËD΀VðXH<ÕL^+PFí¦Ñ^!~"–§•­c´Xe…ie©$€€å»e|¡åFŠ [Æå·Ðå{áeú øe`¶¯;<Îifg~fh €h®fk¾flþˆdNfwZfçÍfqgá˜fr>gt¶fˆŽºðæo.Äáe—â… c ¸qç’fy!fÛ1{Æggì­ä‡1vè'„gç%h…q„Nhxê]`eèÿŒØ¡µ ß’Ø¿‹,ÖˆL|ÅCÏIVCЦˆ%ÛO–¨€óì–FˆUdµG•Ž _ ¤TþÒ’Å“žˆCá°û%ƒè?…±Ó¢CÎB'{™¾jÛßuú>?;0I¬A­¾ID‹•N:°³$vK —EJ}n~Þˆ_zªbË©È ZÉÈ;ˆµ†œø#®ºŒØÑ©6Z¥Ãð!LÒ #Âë*yiÅh%½ŽŒ2-&˜2«ÃWsë ZlÒ`#‘©¤ªÓë[Ȳf—³Öeò€‹..q+¡™«Ð†¤’Z™+k#ñÊ’ ™{Õæ‰5ÐìQù`ij©ÿ›Ø7ê!”*^XT¥ªÐOÓ±V ÊlÎÝé^ìiˆ°Rù º7¢,©÷£n` ”†+9¯©•±V*>˜"ÞñîÄQ¹Ç°+ØÆ¦è²Èïûl9óü¨[»)»bmHunl„:&L"Ð>ñ‰M pî[Œ¯˜¢˜FÉ(¶‘8 ')ý¤˜AЦ`9«ˆU)q «¹›7u#ÖŸ€.=Ú5ѾZþžGÿfˆ¤)ÒÓYE-ñÖ•¹W ð ŠÅ„T ©iоVÁ‘íÊ)ÜC¥Öò•{£®T½›ò€ø’œb#ò¶éWšÞ*4Ÿ/¹ÑWnnîÞ_ˆÿ¤Aq`1ÑFûЕÓ^sôQä€Y2ññ¢çqªX‰;çÇ9¯5‡û\jªXÁsØ9Õci´âa¨b)ÙèÜìuéìŒX¨Ì$’.sù­ÚµP”±ÁÓáÏGÉ3hÄ=õ¥LuU¯3KWLõœ‹õs™uZ/8['\ÏõÀeuªtu_g²]/av +vméud‡u`ßÊcovýRölavi¯2j¯k¿vbö²un¯¾l—–m÷÷R)wsŸvooKp_÷²m÷ú‹vx/t'u¯÷Zöô.~w}Ÿ[yÏCÿwi»÷y¡w‚¿ƒ÷”|OxˆYøMixÿ‡_Ë€§Zâ¥Ý‰Ί÷ÍÏxËÝxçìxÛù°ƒˆœ•ˆc"o†x9‘øQ!Џ ÷̵§éèøèˆ ùÃeù…Aø8éŒ ïF÷¬#ÏcTùŠan¡åy8qù’ H¶àCÂa±¢ú HÈØ÷ØQP&ªï‰¯GHú(/& Šì"ûÞûùéùET%')ãÊŠ‡`¤¨ Çê²T¼ Fú*¶{Œù’¹Åº{Ã÷ UÜ{o|ŠÒ B¾À' Ö Ÿúؤeú7qz’Øc$V ªG  0« ¨Œ©Œ£Ò’É“ªwLâѧŒ£ß°1¹ïoKý“*Vÿ¥ßYÎOÏ¿˜?ö0D+Ñ -2ø€ &z}¡hý»3 ²¡èŸýFq£Â0(P¥Š/ƒ’úx{~Çc¹'Å៌|Ü ¥`þ@FŒ*ŠÞRYw„ó/GâÚ¦ø§ó¯ëOpˆ-<(ТE…!¦È`°E‚- Øpð"ÆŒ7rìèñ#È"G’,ir# ';D8éò%̘2˜ióå7g6°¡A‹ N´Ø±ÂA•pô Ó!Š5zB(Q£ "LaТO[ô :TkÄÉf¸u*X¨-+xÝi÷.Þ¼7S®l©÷/à5ÎIø0âÄŠÿ3n|‘¯I–Ž''L9¦áËš7sîì9&ä’’?“~i¹tĘ̀W³níúnh’£_ÓÆxº6FÕ¸eš@±û7ð¼±GÎÎúöoÝÆMªÁ÷òèÒEY|ºg仕cÉ€çÝÇw¯ò:ùËÚqsOÏ‘xðâÝÓÇm$úúŒ(èïÿ?€ 8 ภƒ :ø`€ÄúYÈÚ}åw!bŒð!ˆ!Š8"‰%šx"Š#jp@Š-ºø"Œ1ŽÁ„\ ‡9z–¡GêØzµµÇáàÙˆãI^ÆcG>*‰W´ yáG>y¥cLrä$–7EùÚ”ú•pÿc—e*¦åF\šÓ—®…¹&œqº„¦FjÊiR›­½y'Ÿ}¢¤Rd~ù)Sž¬íS+l°`ŒÞäèA#´uQC2¦˜BZ’ƒî¨h‚zjZt‡¾B[aéUA§6±ŠQB5ðL4i›†”‚D4ªftfd'°ºš©.IÔA'”ÂA•B Deä,´+8ZB³BM…Q Ü2Ûl³Ï’ë¬Yß‘¸#DtP¸Y m ÔZÛB¼ëþz‘´õVí Ô&ÕÀ %pUìdÂbD,‹Z²&eЩHEAR•¦JeÁÁ-\œqôZLºntAdÿ­D#'íVo°Êð*DCÔ²D#ø•@ îfÜÖV.O´éÆuœÉµüÓ D0B Ë6ܘÂ1¼õE—qI±ª¨ÓH×+ÑZYó»¦n¿·Ö-` •ÁU°ÁayÐVÜÒÑ ü]]%øŒÐßkôq½Ü-rµQd8DkCÄh @©…¯DDƒ6× Ê&*é ‰MÙ# µ.Q È^€@EÐi²o%ëì5 tîÚ½òD è^‚伊l|P»-²¤Ä{AÓ ¬`­{‹þºÈ9À<Ѩz‘íxP€ì²O”R=Ÿzb]ô5é«ÖºHÏTÿD4‡P•_nwþÍ " HÈRµ¯¥Ä"Š»Y¾e‘ÉÍìwù [6P¸õ¤´[Ж‚ÀÀQ©ñÖõ?Ä$ÎZÖí¸79ø!F~- Øìçü…Ämnë‰ÁÌF»¢Pg%XAª6ĶÄ!ëê”EF=uÐoDËY~:(EtßP€x±‰”@|aÉ'³Ï~6õ<Ï=“PÇ ´ É?Ç¹ÐÆ4ô¡ÓAAò¨“@çECZº“°€ÙÔf8ºœŠŠ´¥±á" 0¡™Ò´¦6½)NsªÓò´§=}’ŒÃR—U#0-*²Ò‰Ô¥îä¨L½ŸRŸ*Õ—8uªÒŒªU³JŒjÕMXí*XÿÖí|u¬f­ªY3Ô´ò­lÿ=ÌZߺN·Êµ0e­«UéŠ×¼Äu¯ÚÔ«_íÒ×À&°„µÉ`HÃ*3wm¬K Y—$v²¤“ì$÷FÝl$±ŒV®BÒYÑ⪑7©¬e·†YI¨U¹YÆ×‘P$H pÒŽ¨/$¶½œlg‚ÚÔ"lµ:úÀe.‚T `GÌæýE¯ˆ0*†Ë­¸°u‘pY+^W¡V'«U0ˆÐ ^ãÅ׿ð…/¢ ë àÕÈp‰ ,ã^("8›îåúVŒÍ s#À ΗÃ0…Ø™å:5+Û¶1tߣˆ@|9ò†‹[¹¥ˆP¾%~϶¨íÉìÚH=V¾¥¯ÿ~N€3îl ™€´cÒx"HqHn ¬[‚LÅ!#lÀ °Lexñ‡!2¡pÉØ”CÎm§¾èÄ;17%61AQ\Ÿ£"v+oއ|2Úz@Åè°ŠW&ìV» Ù¯˜ß5L=ĉ®0¾të4 MÏRö`AšçA+c9²\Vm#²âû"$Æ3îà€;ˆÉù¿1F^ ElõÍ ï’³‘3Ý=ò‚KÏP~²Ÿ{…½Iï6¾…î“–ÝC}¡o„^i2E´r „*;û¢uŒÛT'(ßãoœ—å½{ÌzV1Ⱦwà?w/!u[ä•_-ÏX§ç’ÑlC4®éHF®¥!”\#Â?$2 ‰Ÿto¦8k‘Ñú*(s¢fùZOz@Rì¶›E$ÕÀwgÄÕÚ–·EJÛ„@Îv=øE.Rþ™0‡øš$þê‹c¼L/4Ç;Ž¥c9ä"R pò¿ˆ€+'h. £™Ó¼æ6¿9Îs®s#/ï§ (¡¡½èF?:Ò“®t¥àçN:Ô£.õ©S½êV¿:Ö³®õ­s½ëJ ;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveMenuItem1.gif0000644000000000000000000001100110520670125021220 0ustar GIF89a˜ƒ÷ $$$(((000888<<<@@@HHHPPPUUUYYY]]]aaaiiiuuuyyy}}}………•••¡¡¡¥¥¥²²²¾¾¾ÎÎÎÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,˜ƒÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£*;pXÊ´©Ó§P£JJµªÕ«X³Ný€´«×“P@¶¬Ù³hÓª]˶­Û·pãÊeK`Aˆ¯xórT A¯Q ü ü„ÂC?@̸ñ@ÅŽBŽLÙïäÊ:/cÞ|T3çšž?‹–¼x4èÒ¦Só ­º%ëÖ°c¾Žr6íÛ)mã©{·ï½{ .¼xFâÆ£Nμ#òæŸCŸ®P:uˆÖ¯k˜}ûÂîÞ§ƒÿp<ùäæÏ?^®¾=wöî%¦{¾zûôcã'¿?¿êþÞèßhjWà€œH‚VÆ t6èX„ÌQ(!b—á…‚m(œ‡æ¢o#†èU‰õÁg"z*®¸ž‹âµ#Š0E#m7ÖTްñ¨£O>þ'ã8¹bDff¤‰H&‰S“.é¤iPŠVå”3]™ ”X~¦åf_véR˜r)&fdR–&t$Àœh¦„k*TA±ÀÀpʉeužƒpg]P¢$\pÁ‹’Pž8*Pp©ˆ@‚¦:zÁ§Œšåœ æÈ@ Z€½ÿJª­Îš@$@¨_¹BÀ¨¸â'® ðš¯\p+ Aƒ Ú¤@ml í³2ÊØÂæ–KBéš‹.¸ràí¢Hà©_ï®ëA¾à®±âé«¶ P@œ"øj-¶ÚfK0 p­l¨"x#«w¶ê$k°¯“¶Y°Áú«^“”2 Ö‚;ðÀÏLòÂ)»¬' 0 “¸VìQ®í©›µ-´Ë%:X¿Ì ÓØÂ;òËx>ë& ó ºÁ¬Ù‚û¬¡§þésG°AÙ ¬Û«@eŸm.Ò P:®¬n½*µ°"MòðÿŠ«À¹ .¹æö”9N›ÀÖ1ð«â[÷9ë¨8›*XÐi ´yÀ9Ëžvà©çopíÀ tà×’.Pê‡;v~E/¼3ï…`ã›40ß{F‚.¨­K}`V’Õ4-bè@±®u+I+[ìÒS¬Ê¥Á•y d¸V« -èªpð÷€üëŸH0BšAWÓ Á ÜõË^V¡ºÿ¸E‚iŒ[èB[³D@Ä\ ZXYÌ*·x \ç2W°oñ\ iÒCC„€hL£×ÈÆ6ºñpŒ£çHÇÔ0„ ÀDÂj­*uˆ]ûžõ._ÅÍqX¼Õ¤’²z-0[³– V¿e SÙ¤ý>òÐñ“ |cîøÂê匡L¥*WÉÊ7ÚñŽyÜcH„¥¾jqìSASšË°7 ‚ T³™_îM’›¢Á(L¡¥L“"éd+§)JR–Q†¡!oÈB…l Ë•ÈÉp k„ëÎVM*n(gœ"È Ëž”ÜÚ†ÿ¶gêr“ÃéfGÆXJl~ä<ßÊÙ48Ës8cç*'9†v.¢œëî5 Üê{{‚˜m%>…TD„GE:*É…Q qá5 ê‘òo€ˆƒ©FôgJšväyÑÓix$>Ÿž¤vƒAªQ•#¶Œpî}Á½*4…èΪãSªeX˜ À«" €êCþ•,³Aì{àl:ϤU½˜gWYßDÀ8JŠzñ¥òÚ*"üÅZˆJV`Å€Ìé ¥ÈWÛ„³‰^`U[J âR°ËŠoJ@Çf%?BëV%½ë^… Þ}U[ˆ”ÁŠx­}rVÚŠ]ÇD€Nëÿ•0S#Û(ee¶Zƒ!ªT ¤`¿‡BÑ¢ÄsK©ˆå(¢)*"D:K2·Â¦V$°ÍVjq—-ë¬5×@JÕ¨GsdÈÀÓBÞ‚€@]ÿbÙÈ‚ ^èJWöåœõNW \"´HI1Ù4üdË l«›S‹XO‚qÛZY&ò¢ #H0KÊ9+î3¿Ál\ì  »`ª·¼±šUC!9‡1 ¡&),Ë^7<LõsUU¡r 1–Q·žjo%åËpÎ pÝS3—ºk‹7¤ÝÎx¬·Ï3OUŒ•§&»ºÕ.î€EdTwã„.sî±i#œ¡ðô×øâWÿ“û¬}QÂ8-6€€/k[w“/ÖV…uÕ1=gÏÉ‚±Ó¨‹Ò tÌq„~SÙÖ…g—AÙº±Þz; öz]É:1‰ß˲P 1mWd¤CÅ^dqΣ©þa/5ª]Iz]xI ëÜ(ͬ`_ÝÀçäª+0nÃßëÚÄÄ«²ƒ¥Íz¡}r´ß&Â¥8šQ6ï^«-ê‚„žÚïEbh€’ÄaUgq«l­wY8ÛdÁÔYÖØ’^ñóALhï‘n6Äðú0Ë’}é[gh J¯¦‘xÃJ¯(Ifø$õ.n„óÔ‰57B‰Ý›’—‚@€AM¹²¸·¶ÿ y}‹8ª‘3ØI|%Šü%rt]«l”˜G;…'Ûš®±èE ÙÕó-¿¸}’X¾ƒ™ïôFxR7.'³}˜E»#ST¥*Šÿµà0§ºp¼·V‘àN¢ñ@²âÔ©¿ÓKE“âc”ù-ažˆò/·‚("L_Å 9Ci:+ ªo‰©=¢Á|Õ„b !d6vÀ8j–ô¡°Ù’†“`±`/:“"<&Ác)a“2™x!Y&0ZS%V¤á;¡¤ ÑŽᣯWc¡¢ÁŸ;¥Vê‚ :£ÍF“&x-@ºm‚;`ZÎbDÑu¡¥9!§,ÚP*V.ظò9R3ˆzoÉ^ G|ŠV A§7¨Wÿƒ]¦²p$6¡éf|‡õQÔP·©¦8d9+§Ã5o8–%…3ËÂpö¥hœ£©œõGç´Y’U0'y“«¤zmå!¢B2p7a¶q#Ä–Vtœûä«H2mùbÄÊo«¥ŒVŽm©-=ž3|’–äqšŒŽ–[w)EÖ—t'­·Z¤»a?(TyrYr‚X5Áx'aÕ1H×m÷Õi $A «×òU÷b„š fˆ°à”9  [‘[pWv¹…)Ù寶j†A®¸á0šk)_`—H^“šñyŠ7óK®RmÝJr!¥+y4¦³túõ+­i_¿)³ŸÖ]yæØŠa%pFÆ–2¨[“o±=õ#€1òC]k9%S0–eqöXöf8ƒRhV‚«pÃ9Xƒ&–]S„–ÇÒ4øf#ÄtÉHfÝ…'ef?÷t˜aAJt[·v{·x›·z»·|Û·~û·¤dFÛ(8JbT‰e9SŒói`Ù8‡(–Ò¸¢Yq©ªãGŠ4x”ò³a™d\ªHED³Bk£ ‘ÅoTÉkhÅ”Ñ8¤É±¦¦nWØíåºÂáh»±pߘ“k»¾û»À¼Â;¼Ä[¼Æ{¼È›¼Ê»¼ÌÛ¼Ú;jcsp-1.1-rc4.orig/src/org/jcsp/awt/doc-files/ActiveMenu1.gif0000644000000000000000000001142510520670125020413 0ustar GIF89a‰÷ $$$(((000888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡®®®²²²¶¶¶ººº¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,‰ÿQH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Qœ((]Ê´©Ó§P£JJµªÕ«X§b8q´«× dK¶¬Ù³hŸ> â«Û·?$€Ûõºxó*Tª—¨‡}÷å+è߈ßNÌó0ãÇECF x²åŸ’/Ót¬¹3ÎÌžarM:&èÒ,G£^­ò4k”ª_Ëéz6ÉØ¶ss¬­$îÞÀ+òÎñ7ñã‡#Çh|¹óƒÊŸSl.½zôê©cw~}»CíÞwÿ¿wúöÙ×ý~¾@ùöW×·?éýóõç_hÂ'à€ØÞ^¦ z 68ÙƒçE(ác’gá…‰eÞ†æ¡w †؈ەh¢^(b§âŠxµXÝ‹0Â%£t4ÖèÖÏ娣W<:çãG¹ÜDFFA’÷UÆ$K2‰ä“A‰Ü”Tbe’XfÙ“•Çui’ –‰`€ÂW`'&I T`YjšP™@nIä› ‚@ à)Ÿ$€@‚@ƒzhH€çQ( ÀU )¥"(Á¥@™þ¹ HÐ < Pd*ƒ6ÿ €œ3µŸ ™y¦ª¨Š‚¤©š( ;¬4€´õšÏ’ HÀ  é™É2›-ð@š«€@Þj+Á¯lÀl­zþˆ+B²¢®t¢Ðé¯ëæ;¬ $¤Û¬QÔ thÁæfë ùæûm¾ —+)º(l/€)¼OÎ{Й 4lÀ›> ²²鹿V ÀÀE½;Ì’~ñÍ—{óÄ-Û|A£ͱ”N¶Äóš(¤¼pÁ…šKq¶0%) Š + ¤»fÃå~®YKl€ ?»¼æÉ º®L¶ç±A?›jÀ¡á²üì´çòüî™iÿ±ëfº+ ¨y³Ã†ãý, îöê­á(Lk€H›¯Žo”AЇVº°@TÐ÷}W°pèŸwf'¥ÓÕvo™Ïðäº~yJ¢7d:CvÞYéî?Ån~öB ½ß²”éš2+”-Æ„ð²aEÇ4Â^ú&Ȥ«‚?#Õ°¾å¸€U@Y!3@læ¯(Fí$ÉÈ1`¸"WŒXò’˜Ì¤&7ÉÉNzò“  ¥(_hÅDàv%9™¤ŽE‘ ä<¬ã»Tyªp-ÌPßY¹à¨³@Š(ð£  Êb³“€ä [xXZàâõ² |JY–Ô–™h¥ê™kZøÖÏxU3¥êZ¿DU£”uH“P± É´Þ2™i‘šâC%Ir7ÿÜñxA³Óçx8M}vÊáîv÷Ï…%Ô^´ €·’w$Ÿª=+‚,d†²±¨@B0O¸üI£ÉáEÚ—E‚ü‰!/ H_#Ò¾dà$`ÙDJ:IE*p¾ˆNr*ÚèÓD5ÍK+1¢3Š\`mdX;N£v,{Ù€ Ô7˜N_퟾Äz®z–‘Sß«B–´Î)€›’ULsJ8=ªU"£Ô¦ð*‚lªs –Õ"•¬¤] ¯(Øk_…&Ó£†hC 0ÁúÖS”BdT¤›ズª†µ#t-–<°6Ê=`MOÕáïRØÓÖõWê šìöÙJÿõªs:#Vîtk:ÚJÕªD»HÔÓüÅô¥ù#ˆÎXŠ(ýU~¥ ` È ú#áŠû§?Qt#X›Î* 7ƒzt$V¥Ò¶?*à´,“@ƵރÐÉ™zm±ˆßùr5wŒ ÉLYc!–+SäÍÛKófÝ·$¿©²¥øj©´¥ÊTCµTê²æ(IÉWUï¥ÓŸøú€Rý¶#Bû[±pUX7m0™h… ‚Q­I¤+íóVU¹›ös¸ª ºô¥cé&mM;.—° ‘§ ä\xi¹À¹VQj¿™/ÙVk¸ƒú*ƉëçÊ5[È·Ìû}@ß4ubŽÍÿÉc‹Ü¹f`½–Kd*y §&úþŠaA.— º‹¬`NJhh…0Wõè'“dÀ«‰Ð2 ›M,ttAÈ\9ù&-P1ª’õ¹á–un*æ'¬{®¦:8ÀA´ú*Ý€ù®êsš®õ©LF_…¬&{À¡Dðå8‹t• )5*bßg]ÂÖ_±-•Ø©nÒ¨‰tƒf&2ÙZch5\hŸlµ5›÷É9ý¬’ä'ƒÀÉF–ؚ誳€¹Û#¤-VK;Ù6_¤ßBª€Ë!m¯‰rfª±fUT`«^­ú3«\\®vŸkS+WÄÝ•1jï¹—­¾ªR•,ƒDVœÿÉ«Hµ‘•Ÿªª&ø… þgÆ ×’•ê¾Z•¶ ä°t0hb²e›oj¬÷ùcßðµUDQªo8××Sådêa»4 šEb8?¯”º9%ÁR‰tuÒDÈ <É~ëQÊÚ É!YG‚RË>$¹*íÈÜRöÐ$õ'#OÝGœ}¿:&Ûð)ÙÔPeV…~!µ¤ìCú÷„Êû(;¬‰Ä9rër0C`Mw6"”ïŒåw2vÚUc±µ¥×6]YÝ]k×äbZªµû\+÷uyk.dô `ü™}J¸HaPqaQ))õ5uò2—ÐêuB_Ó»öo¡}kÿÕ¯ÿý[ÊP!WîÑM0«¯ª}†£œ¨m{@Ím¿À~%©ûçÐJ¬Ž6O×—Ù× Û—,#4í…r&4øRb×·€ïU,Å‚cã’_ÊEã2.!öGUZTÃMÍ“,§²gú&zA£ “_°¶Lô63‘zšq€8¡3”ccUÖVsæpŒóY8ˆc†%:}ek¬¥`­–pÄsWc–4 coµUqKèj…{óseÐ{ Z2x4x¹Å0ëR8¹Çf*Æ~×%†|vp]Ã[(0h¿%+KcXú"G‡bzÒe*I³67€"G óW ('NvXýg|¢&d¨W€ò…6ÿQ.¡õk2vAe* :„'‰âdV“l°‚lhʼnªb5 àk±—6´6Y¯Ä|IsŠúÀøâ‰RbÅf]"Sê#pxUËqq)Çü´ˆ¼ˆ”¸n³!´'ŒÁµQŒÑ…–áˆÌ¨Î8ÐXZås!yz'x1QCÑ^­H¢F÷WãFºxmŒ8 â(,óRÌõ†LÅCŒ•\'Õ9MãUö–CM“XýV(Ç…]Î¥sÚU[ßøŽþ@ajá…*—8)¦'U›lɸCÖWÉò­“‘sd/ÀW-%¦C°$’”raõaF*ÂfdŽ‘?¡3òÿUtghú2]ñVQ6d`ö+¡•5úèAi£bÒÅ­D„1VXÕö+H#“ 9Œíë¶i…V.ôe*²’Œgiy3oÆ·6°'Ts˜XëR.i²i!SjóE*²R1ŸE•»áùa“ÆEt¨oŲvúâ+^§iÝ–X¼B…&¨fÊU(v“ùådŒ“)êf5W–66€wi•ê¡b*6q­9…F‰ïV'TWNj2*åÔ_Ó^¤©?‚0÷W·8Gmóä¿èŽšy*™œC+@Y¨ãs[–‡Ò^`I’:d‚/F¹e[†_•â9tÉ6\,³9}cVY8p½yçÿÒn!Á*i]×xšwA“Œ¡——gb#AŠ»yYlwìÙžxÉLyញŸþÉ…û ý¹wmQŸråä šBW•˨ðv•0Ä3* ¡¡ÑŽúžÛ±TM§/¦fŸWÕ¦BóO‡"YSystem.exit * upon a Window Closing event. *

Process Diagram

*

*

Description

* ActiveClosingFrame is a process containing an {@link ActiveFrame ActiveFrame}, * configured with channels for event notification and configuration. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. *

* The difference between this class and ActiveFrame is that a Window Closing event, * generated on the (internal) ActiveFrame, is intercepted by the anonymous process * and results in a System.exit. This happens regardless as to whether * the (external) event channel is null. Otherwise, WindowEvents * are forwarded to the (external) event channel, so long as it's not null). *

* The internal ActiveFrame can be extracted with the getActiveFrame method. * Channels can then be added to notify the occurrence of any other type of Event * the ActiveFrame generates. This is done by calling its appropriate * addXXXEventChannel method * (before the process is run). As many channels can be added as are needed. *

* Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that the output channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. The simplest way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myWindowEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveClosingFrame myFrame = new ActiveClosingFrame (myWindowEvent.out ());
 *   final ActiveFrame myActiveFrame = myFrame.getActiveFrame ();
 *   myActiveFrame.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureBoolean *
    *
  1. If this is the Boolean.TRUE object, * the frame is made visible
  2. *
  3. If this is the Boolean.FALSE object, * the frame is made invisible
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveFrame.ConfigureInvoke the user-defined Configure.configure method on the frame.
Output Channels
eventWindowEventThe WindowEvent generated by the component (note that * Window Closing is handled locally to cause * a System.exit).
containerEventContainerEventSee the * {@link #getActiveFrame getActiveFrame}.{@link ActiveFrame#addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the * {@link #getActiveFrame getActiveFrame}.{@link ActiveFrame#addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the * {@link #getActiveFrame getActiveFrame}.{@link ActiveFrame#addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the * {@link #getActiveFrame getActiveFrame}.{@link ActiveFrame#addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the * {@link #getActiveFrame getActiveFrame}.{@link ActiveFrame#addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the * {@link #getActiveFrame getActiveFrame}.{@link ActiveFrame#addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveClosingFrameButtonExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame frame =
 *       new ActiveClosingFrame ("ActiveClosingFrameButton Example");
 * 
 *     final String[] label = {"Hello World", "Rocket Science", "CSP",
 *                             "Monitors", "Ignore Me", "Goodbye World"};
 * 
 *     final Any2OneChannel buttonEvent = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveButton[] button = new ActiveButton[label.length];
 *     for (int i = 0; i < label.length; i++) {
 *       button[i] = new ActiveButton (null, buttonEvent.out (), label[i]);
 *     }
 * 
 *     final Frame realFrame = frame.getActiveFrame ();
 *     realFrame.setSize (300, 200);
 *     realFrame.setLayout (new GridLayout (label.length/2, 2));
 *     for (int i = 0; i < label.length; i++) {
 *       realFrame.add (button[i]);
 *     }
 *     realFrame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         frame,
 *         new Parallel (button),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) buttonEvent.in ().read ();
 *               System.out.println ("Button `" + s + "' pressed ...");
 *               running = (s != label[label.length - 1]);
 *             }
 *             realFrame.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveFrame * @see java.awt.Frame * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveClosingFrame implements CSProcess { private ChannelInput configure; private ChannelOutput event; private String title; private ActiveFrame frame; private One2OneChannel windowEvent = Channel.one2one(); /** * Constructs a new ActiveClosingFrame with no title and no configuration * or event channels. * */ public ActiveClosingFrame() { this(null, null, ""); } /** * Constructs a new ActiveClosingFrame with a title but no configuration * or event channels. * * @param title the title for the frame. */ public ActiveClosingFrame(String title) { this(null, null, title); } /** * Constructs a new ActiveClosingFrame with configuration * and event channels, but no title. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event a WindowEvent will be output whenever it occurs * -- can be null if no notification is required. */ public ActiveClosingFrame(ChannelInput configure, ChannelOutput event) { this(configure, event, ""); } /** * Constructs a new ActiveClosingFrame with configuration * and event channels and a title. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event a WindowEvent will be output whenever it occurs * -- can be null if no notification is required. * @param title the title for the frame. */ public ActiveClosingFrame(ChannelInput configure, ChannelOutput event, String title) { this.configure = configure; this.event = event; this.title = title; this.frame = new ActiveFrame(this.configure, windowEvent.out(), title); } /** * Sets the configuration channel for this ActiveButton. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.frame.setConfigureChannel(configure); } /** * This is used to get the ActiveFrame within this component * so that it can be configured or have components added * (using {@link java.awt.Frame} or {@link org.jcsp.awt.ActiveFrame} methods). * For example, event channels can be added by invoking * getActiveFrame().addXXXEventChannel(...). *

* NOTE: This must be finished before this process is run. * * @return the Frame within this component. */ public ActiveFrame getActiveFrame() { return frame; } /** * The main body of this process. */ public void run() { new Parallel(new CSProcess[] {frame, new CSProcess() { public void run() { boolean running = true; ChannelInput windowEventIn = windowEvent.in(); while (running) { final WindowEvent window = (WindowEvent) windowEventIn.read(); if (event != null) event.write(window); switch (window.getID()) { case WindowEvent.WINDOW_CLOSING: running = false; break; } } frame.setVisible(false); System.exit(0); } } }).run(); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveButtonState.java0000644000000000000000000001722311105701167020214 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; /** * A state of the {@link ActiveButtonControl} finite state machine. *

Description

* ActiveButtonState is one of the elements of the state table governing * the behaviour of the finite state machine within an {@link ActiveButtonControl}. * For each controlled button, it holds the index of the label to be displayed in * this state, whether that button should be enabled or disabled and which state * should be jumped to if that button is pressed. * See the example documented in * ActiveButtonControl. *

* @see org.jcsp.awt.ActiveButton * @see org.jcsp.awt.ActiveButtonControl * * @author P.H. Welch */ public class ActiveButtonState { int[] labelId; // button labels for this state boolean[] enable; // button status for this state int[] next; // next state after this button is pushed private boolean verbose; /** * Constructs a new ActiveButtonState, performing consistency * checks on its supplied arguments. * * @param labelId the button labels for this state. * @param enable the enable/disable status of each button for this state * (true <==> enabled). * @param next the next state after each button is pushed. * @throws ActiveButtonState.BadArguments if the consistency check fails. * The exception contains details of the error. */ public ActiveButtonState(int[] labelId, boolean[] enable, int[] next) throws ActiveButtonState.BadArguments { this(labelId, enable, next, false); } /** * Constructs a new ActiveButtonState, performing consistency * checks on its supplied arguments, with a verbose reporting option. * * @param labelId the button labels for this state. * @param enable the enable/disable status of each button for this state * (true <==> enabled). * @param next the next state after each button is pushed. * @param verbose if true, a running commentary is printed on the consistency checks. * @throws ActiveButtonState.BadArguments if the consistency check fails. * The exception contains details of the error. */ public ActiveButtonState(int[] labelId, boolean[] enable, int[] next, boolean verbose) throws ActiveButtonState.BadArguments { if (verbose) System.out.println("ActiveButtonState creating ..."); // sanity checks if (labelId == null) throw new ActiveButtonState.BadArguments("labelId == null"); if (enable == null) throw new ActiveButtonState.BadArguments("enable == null"); if (next == null) throw new ActiveButtonState.BadArguments("next == null"); if (verbose) System.out.println("ActiveButtonState: arguments not null"); if (labelId.length != enable.length) throw new ActiveButtonState.BadArguments("labelId.length != enable.length"); if (verbose) System.out.println("labelId.length == enable.length"); if (labelId.length != next.length) throw new ActiveButtonState.BadArguments("labelId.length != next.length"); if (verbose) System.out.println("labelId.length == next.length"); for (int i = 0; i < labelId.length; i++) if (labelId[i] < 0) throw new ActiveButtonState.BadArguments("labelId[" + i + "] is negative"); if (verbose) System.out.println("all label indices positive"); for (int i = 0; i < next.length; i++) if (next[i] < 0) throw new ActiveButtonState.BadArguments("next[" + i + "] is negative"); if (verbose) System.out.println("all next states positive"); if (verbose) for (int i = 0; i < next.length; i++) System.out.println(" " + labelId[i] + ", " + enable[i] + ", " + next[i]); // sanity checks complete this.labelId = labelId; this.enable = enable; this.next = next; this.verbose = verbose; if (verbose) System.out.println("ActiveButtonState created OK"); } void check(int i, int nButtons, int nStates, String[][] label) throws ActiveButtonControl.BadArguments { if (verbose) System.out.println("ActiveButtonState " + i + " checking labelId.length (" + nButtons + ", " + labelId.length + ") ..."); if (labelId.length != nButtons) throw new ActiveButtonControl.BadArguments("state[" + i + "]: table lengths != nButtons"); if (verbose) System.out.println("ActiveButtonState " + i + " checking next.length ..."); for (int n = 0; n < next.length; n++) if (next[n] >= nStates) throw new ActiveButtonControl.BadArguments("state[" + i + "]: next[" + n + "] is too big"); if (verbose) System.out.println("ActiveButtonState " + i + " checking labelId[n] ..."); for (int n = 0; n < labelId.length; n++) if (labelId[n] >= label[n].length) throw new ActiveButtonControl.BadArguments("state[" + i + "]: labelId[" + n + "] is too big"); if (verbose) System.out.println("ActiveButtonState " + i + " checked"); } /** * This gets thrown if a consistency check fails in the {@link ActiveButtonState} * constructor. */ public static class BadArguments extends Exception { /** * * @param s details of the consistency failure. */ public BadArguments(String s) { super(s); } } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/package.html0000644000000000000000000000137611077340707016233 0ustar This provides CSP extensions for all AWT {@link java.awt.Component} components: GUI events and widget configurations map to channel communications.

Each AWT component (e.g. {@link java.awt.Button}) is mirrored by an active {@link org.jcsp.lang.CSProcess process} (e.g. {@link org.jcsp.awt.ActiveButton}) that works to a channel interface. GUI events are signalled as output messages sent on channels coming from the CSP component. Each component may be dynamically configured by sending it a message on its configuration channel.

The JCSP-AWT components may be wired up to any (JCSP) application network. This allows a safe and natural approach to GUI building as a (multi-threaded) network of communicating processes. jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveFrame.java0000644000000000000000000004255511105701167017000 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Frame java.awt.Frame} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveFrame is a process extension of java.awt.Frame * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers a WindowEvent whenever one is generated * on the ActiveFrame. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myWindowEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveFrame myFrame = new ActiveFrame (myWindowEvent.out ());
 *   myFrame.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureBoolean *
    *
  1. If this is the Boolean.TRUE object, * the frame is made visible
  2. *
  3. If this is the Boolean.FALSE object, * the frame is made invisible
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveFrame.ConfigureInvoke the user-defined Configure.configure method on the frame.
Output Channels
eventWindowEventThe WindowEvent generated by the component
containerEventContainerEventSee the {@link #addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveFrameButtonExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Any2OneChannel windowEvent = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveFrame frame =
 *       new ActiveFrame (null, windowEvent.out (), "ActiveButton Example");
 * 
 *     final String[] label = {"Hello World", "Rocket Science", "CSP",
 *                             "Monitors", "Ignore Me", "Goodbye World"};
 * 
 *     final Any2OneChannel buttonEvent = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveButton[] button = new ActiveButton[label.length];
 *     for (int i = 0; i < label.length; i++) {
 *       button[i] = new ActiveButton (null, buttonEvent.out (), label[i]);
 *     }
 * 
 *     frame.setSize (300, 200);
 *     frame.setLayout (new GridLayout (label.length/2, 2));
 *     for (int i = 0; i < label.length; i++) {
 *       frame.add (button[i]);
 *     }
 *     frame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Parallel (button),
 *         new CSProcess () {                 // respond to window events
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final WindowEvent w = (WindowEvent) windowEvent.in ().read ();
 *               System.out.println ("Window event: " + w);
 *               running = (w.getID () != WindowEvent.WINDOW_CLOSING);
 *             }
 *             frame.setVisible (false);
 *             System.exit (0);
 *           }
 *         },
 *         new CSProcess () {                 // respond to button events
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) buttonEvent.in ().read ();
 *               System.out.println ("Button `" + s + "' pressed ...");
 *               running = (s != label[label.length - 1]);
 *             }
 *             frame.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveClosingFrame * @see java.awt.Frame * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveFrame extends Frame implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveFrame with no title and no configuration * or event channels. * */ public ActiveFrame() { this(null, null, ""); } /** * Constructs a new ActiveFrame with a title but no configuration * or event channels. * * @param title the title for the frame. */ public ActiveFrame(String title) { this(null, null, title); } /** * Constructs a new ActiveFrame with configuration * and event channels, but no title. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event a WindowEvent will be output whenever it occurs * -- can be null if no notification is required. */ public ActiveFrame(ChannelInput configure, ChannelOutput event) { this(configure, event, ""); } /** * Constructs a new ActiveFrame with configuration * and event channels and a title. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event a WindowEvent will be output whenever it occurs * -- can be null if no notification is required. * @param title the title for the frame. */ public ActiveFrame(ChannelInput configure, ChannelOutput event, String title) { super(title); if (event != null) { WindowEventHandler handler = new WindowEventHandler(event); addWindowListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveFrame. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ContainerEvent has occurred. This should be used * instead of registering a ContainerListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param containerEvent the channel down which to send ContainerEvents. */ public void addContainerEventChannel(ChannelOutput containerEvent) { if (containerEvent != null) { ContainerEventHandler handler = new ContainerEventHandler(containerEvent); addContainerListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param frame the Frame being configured. */ public void configure(final Frame frame); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message == null) break; else if (message instanceof Boolean) { if (message == Boolean.TRUE) setVisible(true); else if (message == Boolean.FALSE) setVisible(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveApplet.java0000644000000000000000000015365611111260160017166 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.applet.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.applet.Applet java.applet.Applet} * with a channel interface, specialising in the operation * of {@link org.jcsp.lang.CSProcess} networks as applets. *

* Shortcut to the Constructor and Method Summaries. *

Description

* ActiveApplet is an extension of {@link java.applet.Applet} to simplify * the management of an associated {@link org.jcsp.lang.CSProcess}. There are three * areas of provision: * * These mechanisms are described in the next three sections. * *

Applet Processes

* In an application, a network of processes can be executed simply by invoking run * on the defining ({@link org.jcsp.lang.Parallel}) process from the main thread of control. * We cannot do this from the applet init or start methods since * the browser would freeze until the process network terminated. Instead, the process * network must be started asynchronously with the applet thread. This can be achieved * by using a {@link org.jcsp.lang.ProcessManager}. *

* We could do this by directly extending the {@link java.applet.Applet} class and * overriding its start, stop and destroy methods suitably - * however, the necessary logic has already been built into this class. All the user * needs to do is override the init method to contruct the desired * {@link org.jcsp.lang.CSProcess} and register it with this ActiveApplet * (by means of the {@link #setProcess setProcess} method). *

* For example: *

 * import org.jcsp.awt.*;
 * 
 * public class Flasher extends ActiveApplet {
 * 
 *   public void init () {
 *     setProcess (new FlasherNetwork (500, this));
 *   }
 * 
 * }
 * 
* In the above, FlasherNetwork is the CSProcess that will be run * by the ActiveApplet. The 500 parameter defines the period * (in milliseconds) of its flashing and
should really * be a parameter of the applet itself. * The reason for passing the reference to this into the FlasherNetwork * process is explained in the description of its implementation * in the next section. * *

Default ActiveApplet stop/start/destroy Behaviour

* The default behaviours of the start, stop and destroy methods * implemented by this ActiveApplet are as follows. *

* When the HTML browser invokes start for the first * time, the CSProcess (registered by the {@link #setProcess setProcess} * method) will be set running in its own thread of control. As the browser subsequently * invokes stop and start methods, events will be posted to channels * which may be optionally registered with the Applet. *

* When the browser invokes destroy, an event will be posted to the optionally * registered channel. If this is not present or does not cause network termination the * process network will be forcefully destroyed. *

*

Sun's Java Plug-in

* Most of the problems arising from the default ActiveApplet * controls are avoided by taking note of the following: *

*

* * * * *
* Use of this ActiveApplet class is recommended only for browsers on systems * that have installed Sun's * Java Plug-in. *
*
*

* This has the robust behaviour of invoking a destroy immediately following * a stop whenever we leave a web page containing a Plug-in controlled * applet. It re-launches the applet from scratch whenever we return. Whilst this * removes the option of allowing applets continued execution during visits to other * pages (but see the cheat), it does relieve various deadlock problems * that may otherwise strike our browser. *

* Note: to use the Java Plug-in, HTML pages containing applets must be * transformed using the * Java Plug-in HTML Converter. * This renders the HTML somewhat more complex than it was before conversion, * but the results are worthwhile. * A browser visiting such a page without the Plug-in installed is invited * to install it - a link is offered to make this easy. * *

User-Defined Applet stop/start/destroy Behaviours

* The applet stop, start and destroy methods can, * of course, be overridden by the user to interact in some user-chosen way with * the process associated with the ActveApplet. * However, the proper way to interact with a process is to communicate with it over * a channel and support for this is provided without the user having to override anything. *

* The methods {@link #setStopStartChannel setStopStartChannel} and * {@link #setDestroyChannels setDestroyChannels} let us connect special channels * to the ActveApplet process: *

* If a stopStart channel has been set, * an {@link #STOP ActiveApplet.STOP} * (respectively {@link #START ActiveApplet.START}) * will be written to this channel whenever the browser invokes a stop * (respectively start) method. As before, the first invocation * of start just starts the running of the associated process * (i.e. ActiveApplet.START messages are only sent on second and * subsequent starts). * This replaces the default start and stop mechanisms * described earlier. *

* If a pair of destroy/destroyAck channels have been set, * an {@link #DESTROY ActiveApplet.DESTROY} will be written to the destroy * channel when the browser invokes its destroy method. * The browser will wait for up to {@link #DEFAULT_TIMEOUT_ACK 10 seconds} (by default) * for the applet process to respond with a message on destroyAck, before * proceeding to execute the default destroy mechanisms. * The timeout period can be specified (or disabled) * {@link ActiveApplet#setDestroyChannels(org.jcsp.lang.ChannelOutputInt,org.jcsp.lang.AltingChannelInputInt,int) when the channels are set}. *

* These channels should be set up either as an explicit part of the init * method (and passed to the user process as a constructor or mutator parameter) or * by the user process constructor itself (to which this ActveApplet * would have had to have been passed). It is important that these channels are in place * before the user process starts running (otherwise the default mechanism may be triggered * if the user quits the ActveApplet web page or the browser too quickly). *

* It is crucial, of course, that these communications are accepted by the user process * associated with the ActveApplet. Using a channel configured with * an overwriting buffer (of capacity one) will ensure this. Note that this overwriting * cannot cause the loss of any significant information to the user process. *

* The stop/start and destroy operations are implemented * via separately set channels so that the designer may make separate decisions on whether * to use each of them. *

* Freezing a process network (e.g. in response to * a {@link #STOP} is usually easy to arrange - just pinch the data-flow at a crucial * point to achieve a temporary deadlock. When the {@link #START} message arrives, * just let go. *

* Note: if the Java Plug-in is not * being used, it is strongly recommended to set and operate this stopStart channel * (rather than rely on the default suspend operations). *

* Note: if the Java Plug-in is being used, user-defined * behaviour for the stop/start operations are not needed. * Any stop is quickly followed by a destroy (for which the default * ActveApplet response will release any locked resource). * Second invocations of start never take place. * *

* The destroy/destroyAck channels enable the process network to * tidy up any created resources (e.g. to make invisible and dispose of any widgets * spawned off the web page) before termination. * Correctly terminating a process network (e.g. in response to a destroy) * is usually harder to arrange safely - so it may be better to leave this to the * default mechanism (which will follow the destroyAck signal). However, * secure CSP algorithms, at least for 1-1 channels, are known * (e.g. the graceful termination protocol) * and support for this may be provided in later versions of this library. *

* Note: if the destroy/destroyAck channels have been set, * the default suspend mechanism (if not already overridden by setting * a stopStart channel) will be suppressed. This is because the browser invokes * the stop method immediately before invoking the destroy. * If we did not do this, the suspended network would not be able to respond * to the destroy channel. *

* *

The ActveApplet as an ActivePanel

* An ActveApplet extends a {@link java.applet.Applet java.applet.Applet} * which extends a {@link java.awt.Panel java.awt.Panel}. Most activeApplets * will just use this panel as a container for other active GUI processes that * form part of their ActiveApplet network. However, if there is a need for run-time * configuration of the underlying panel and/or reaction to GUI events occurring on the * panel, the ActveApplet can itself be used as a process in that network. * Fot this case, an ActveApplet has a channel interface (which, together with * the browser control channels, extends that offered by * an {@link org.jcsp.awt.ActivePanel}): *

* The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure channel is connected by invoking * the {@link #setConfigureChannel setConfigureChannel} method. * Event channels can be added to notify the occurrence of any type of Event * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent =
 *     Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   activeApplet.addMouseEventChannel (myMouseEvent);
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
destroyAckintSee the {@link #setDestroyChannels * setDestroyChannels} methods.
configure{@link ActiveApplet.Configure ActiveApplet.Configure}Invoke the user-defined Configure.configure method on the applet.
Output Channels
stopStartintSee the {@link #setStopStartChannel * setStopStartChannel} method.
destroyintSee the {@link #setDestroyChannels * setDestroyChannels} methods.
containerEventContainerEventSee the {@link #addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

* This example continues the Flasher example * introduced earlier. * FlasherNetwork consists of two processes: one is the ActiveApplet * (supplied as a parameter to its constructor) and the other is a user-written * FlasherControl. Here is the network diagram: *

* FlasherControl responds to mouse entry and exit * events on the applet area (delivered as messages down the mouseEvent * channel). When the mouse is outside the applet, the applet is painted black. * When the mouse is inside the applet, FlasherControl paints the applet * a random colour every period milliseconds (where period is * the other parameter to its constructor). The applet colour is controlled by * sending it a message down the appletConfigure channel. *

* Here is the code to set up this process: *

 * import org.jcsp.lang.*;
 * import org.jcsp.awt.*;
 * 
 * public class FlasherNetwork implements CSProcess {
 * 
 *   final private long period;
 *   final private ActiveApplet activeApplet;
 * 
 *   public FlasherNetwork (final long period,
 *                          final ActiveApplet activeApplet) {
 *     this.period = period;
 *     this.activeApplet = activeApplet;
 *   }
 * 
 *   public void run () {
 * 
 *     final One2OneChannel mouseEvent = Channel.one2one ();
 *     final One2OneChannel appletConfigure = Channel.one2one ();
 * 
 *     activeApplet.addMouseEventChannel (mouseEvent.out ());
 *     activeApplet.setConfigureChannel (appletConfigure.in ());
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         activeApplet,
 *         new FlasherControl (period, mouseEvent.in (), appletConfigure.out ())
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* FlasherControl demonstrates three basic JCSP techniques: *
    *
  • * {@link org.jcsp.lang.Alternative ALTing} between guards (a channel * communication and a timeout); *
  • * {@link org.jcsp.lang.Alternative ALTing} with pre-conditions * (the mouse must be present in the applet for the flashing - controlled * by the timeout - to take place); *
  • * construction and use of general configuration objects for an Active GUI * process (including the double-buffering needed for security when reusing these * objects - see the note in {@link ActiveApplet.Configure}). *
* For completeness, here is its definition: *
 * import org.jcsp.lang.*;
 * import org.jcsp.awt.*;
 * import java.awt.*;
 * import java.awt.event.*;
 * import java.util.*;
 * 
 * public class FlasherControl implements CSProcess {
 * 
 *   final private long period;
 *   final private AltingChannelInput mouseEvent;
 *   final private ChannelOutput appletConfigure;
 * 
 *   public FlasherControl (final long period,
 *                          final AltingChannelInput mouseEvent,
 *                          final ChannelOutput appletConfigure) {
 *     this.period = period;
 *     this.mouseEvent = mouseEvent;
 *     this.appletConfigure = appletConfigure;
 *   }
 * 
 *   private class AppletColour implements ActiveApplet.Configure {
 *     private Color colour = Color.lightGray;
 *     public void setColour (Color colour) {
 *       this.colour = colour;
 *     }
 *     public void configure (java.applet.Applet applet) {
 *       applet.setBackground (colour);
 *     }
 *   }
 * 
 *   public void run () {
 * 
 *     final Random random = new Random ();
 *     final CSTimer tim = new CSTimer ();
 * 
 *     final Alternative alt = new Alternative (new Guard[] {mouseEvent, tim});
 *     final boolean[] preCondition = {true, false};
 *     final int MOUSE = 0;
 *     final int TIMER = 1;
 * 
 *     final AppletColour[] appletColour = {new AppletColour (), new AppletColour ()};
 *     final AppletColour panelBlack = new AppletColour ();
 *     panelBlack.setColour (Color.black);
 * 
 *     appletConfigure.write (panelBlack);
 * 
 *     int index = 0;
 *     AppletColour appletCol = appletColour[index];
 *     appletCol.setColour (new Color (random.nextInt ()));
 * 
 *     long timeout = tim.read ();
 *     boolean mousePresent = false;
 *     boolean running = true;
 * 
 *     while (running) {
 * 
 *       switch (alt.priSelect (preCondition)) {
 * 
 *         case MOUSE:
 *           switch (((MouseEvent) mouseEvent.read ()).getID ()) {
 *             case MouseEvent.MOUSE_ENTERED:
 *               if (! mousePresent) {
 *                 mousePresent = true;
 *                 timeout = tim.read () + period;
 *                 tim.setAlarm (timeout);
 *                 appletConfigure.write (appletCol);
 *                 preCondition[TIMER] = true;
 *               }
 *             break;
 *             case MouseEvent.MOUSE_EXITED:
 *               if (mousePresent) {
 *                 mousePresent = false;
 *                 appletConfigure.write (panelBlack);
 *                 preCondition[TIMER] = false;
 *               }
 *             break;
 *           }
 *         break;
 * 
 *         case TIMER:
 *           timeout += period;
 *           tim.setAlarm (timeout);
 *           index = 1 - index;
 *           appletCol = appletColour[index];
 *           appletCol.setColour (new Color (random.nextInt ()));
 *           appletConfigure.write (appletCol);
 *         break;
 * 
 *       }
 * 
 *     }
 * 
 *   }
 * 
 * }
 * 
* *

Accessing Applet Parameters

* ActveApplet provides a set of methods for simplifying * the acquisition of parameters from the HTML source code. These methods are not * specific for JCSP - they are useful for any applets. *

* All methods getAppletXXX have the same form, where XXX * is one of Java's primitive types (int, boolean, byte, * short, long, float and double). Each returns * an XXX value, parsed from the applet parameter named in the method's * first parameter. A standby value must be supplied in case the named * applet parameter does not exist or parse correctly. The number returning methods * must supply min and max values against which the applet supplied * value will be checked - values below min being truncated to min * and values above max to max. *

* For example, Flasher should really * acquire its period value as an applet parameter: *

 * import org.jcsp.lang.*;
 * import org.jcsp.awt.*;
 * import java.awt.*;
 * 
 * public class Flasher extends ActiveApplet {
 * 
 *   public static final int minPeriod = 300;       // milliseconds
 *   public static final int maxPeriod = 1000;      // milliseconds
 *   public static final int defaultPeriod = 500;   // milliseconds
 * 
 *   public void init () {
 * 
 *     final int period =
 *       getAppletInt ("period", minPeriod, maxPeriod, defaultPeriod);
 * 
 *     setProcess (new FlasherNetwork (period, this));
 * 
 *   }
 * 
 * }
 * 
* Now, if no applet parameter "period" is present, the defaultPeriod * is chosen. Same if the parameter was present but doesn't parse. Otherwise, * values below minPeriod are rounded up to minPeriod, * values above maxPeriod are rounded down to maxPeriod * and good values are just accepted. * * @see java.applet.Applet * @see java.awt.Panel * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveApplet extends Applet implements CSProcess { /** * The process defining the behaviour of this Applet. */ private CSProcess process = null; /** * This must be called during the init() method for this ActiveApplet. * It defines the process that is to be managed. * * @param process the process defining the applet behaviour. */ public void setProcess(final CSProcess process) { this.process = process; } /** * The ProcessManager used to control the execution of this Applet. */ private ProcessManager manager = null; /** * TRUE iff the applet is currently active. */ private boolean started = false; /** * This value is sent down a {@link #setStopStartChannel stopStart} channel * when the browser invokes a stop - * see the user-defined stop/start response. */ public static final int STOP = 0; /** * This value is sent down a {@link #setStopStartChannel stopStart} channel * on second and subsequent browser invocations of start - * see the user-defined stop/start response. */ public static final int START = 1; /** * This value is sent down a {@link #setDestroyChannels destroy} channel * when the browser invokes a destroy - * see the user-defined destroy response. */ public static final int DESTROY = 2; /** * This is the default time (in milliseconds) that the browser will wait for the applet * process to acknowledge (on destroyAck) a DESTROY message * (sent down destroy). The default value is 10000 (i.e. 10 seconds). * See the user-defined destroy response. */ public static final int DEFAULT_TIMEOUT_ACK = 10000; /** * This is the time (in milliseconds) that the browser will wait for the applet * process to acknowledge (on destroyAck) a DESTROY message * (sent down destroy). If negative, no timeout will be set. *

* The default value is 10000 (i.e. 10 seconds). */ private int timeoutAck = DEFAULT_TIMEOUT_ACK; /** * If this channel is set, the default stop/start behaviour changes - * see the user-defined stop/start response. */ private ChannelOutputInt stopStart = null; /** * If this channel is set, the default destroy behaviour changes - * see the user-defined destroy response. */ private ChannelOutputInt destroy = null; /** * If this channel is set, the default destroy behaviour changes - * see the user-defined destroy response. */ private AltingChannelInputInt destroyAck = null; private final CSTimer tim = new CSTimer(); private Alternative destroyAlt; private final int ACKNOWLEDGE = 0; private final int TIMEOUT = 1; /** * This sets a stopStart channel to allow * a user-defined stop/start response. * If the channel passed is null, no action will be taken. * * @param stopStart the channel controlling the stop/start behaviour of the applet. */ public void setStopStartChannel(final ChannelOutputInt stopStart) { this.stopStart = stopStart; } /** * This sets destroy/destroyAck channels to allow * a user-defined destroy response. * If either channel passed is null, no action will be taken. * A {@link #DEFAULT_TIMEOUT_ACK default timeout delay} (10000 milliseconds) * for the applet process to acknowledge the destroy signal is set. * * @param destroy the channel to which a {@link #DESTROY} will be written. * @param destroyAck the acknowledgement channel associated with destroy. */ public void setDestroyChannels(final ChannelOutputInt destroy, final AltingChannelInputInt destroyAck) { setDestroyChannels(destroy, destroyAck, DEFAULT_TIMEOUT_ACK); } /** * This sets destroy/destroyAck channels to allow * a user-defined destroy response. * If either channel passed is null, no action will be taken. * The timeout delay for the applet process to acknowledge the destroy * signal is set by timeoutAck. If this is set negative, * no timeout will be set - i.e. the browser will wait indefinitely (which may * cause a problem if the applet process is mis-programmed). * * @param destroy the channel to which a {@link #DESTROY} will be written. * @param destroyAck the acknowledgement channel associated with destroy. * @param timeoutAck the timeout (in milliseconds) allowed for the acknowledgement * - if negative, no timeout will be set. */ public void setDestroyChannels(final ChannelOutputInt destroy, final AltingChannelInputInt destroyAck, final int timeoutAck) { if ((destroy != null) && (destroyAck != null)) { this.destroy = destroy; this.destroyAck = destroyAck; this.timeoutAck = timeoutAck; this.destroyAlt = new Alternative(new Guard[] {destroyAck, tim}); } } /** * Called by the browser when the ActiveApplet is first started and each time * its web page is revisited. See above for the default and * user-definable behaviours obtainable from this method. */ public void start() { if (manager != null) { if (!started) { manager.start(); started = true; } if (stopStart != null) stopStart.write(START); } else { if (process == null) System.err.println("*** org.jcsp.awt.ActiveApplet: no process defined"); else { Parallel.resetDestroy(); manager = new ProcessManager(process); manager.start(); started = true; } } } /** * Called by the browser when the web page containing this ActiveApplet is * replaced by another page or just before this ActiveApplet is to be destroyed. * See above for the default and * user-definable behaviours obtainable from this method. */ public void stop() { if (manager != null) { if (stopStart != null) stopStart.write(STOP); else { manager.interrupt(); // used to call stop() ... started = false; } } } /** * Called by the browser when the ActiveApplet needs to be destroyed. * See above for the default and * user-definable behaviours obtainable from this method. */ public void destroy() { if (manager != null) { if (destroy != null) { destroy.write(DESTROY); if (timeoutAck < 0) destroyAck.read(); else { tim.setAlarm(tim.read() + timeoutAck); switch (destroyAlt.select()) { case ACKNOWLEDGE: destroyAck.read(); break; case TIMEOUT: break; } } } manager = null; process = null; } Parallel.destroy(); } //////////////////////////////////////////////////// // Special methods for applet parameter gathering // //////////////////////////////////////////////////// /** * This looks for the named parameter in the HTML applet source code * and attempts to parse it into an int. If all is well, the value is * checked that it lies between min and max inclusive and * then returned. If the parameter is not present or doesn't parse, * the standby value is returned. If the checks fail, the value * is truncated to either min or max (depending on the direction * of the error) and returned. * * @param parameter the applet parameter name. * @param min the minimum acceptable parameter value. * @param max the maximum acceptable parameter value. * @param standby the value to retun in case the applet parameter is bad. * * @return either the value of the named parameter or standby. */ public int getAppletInt(String parameter, int min, int max, int standby) { int i; final String s = getParameter(parameter); if (s == null) { System.out.println("*** Applet parameter " + parameter + " is missing - defaulting to " + standby); i = standby; } else try { i = Integer.parseInt(s); if (i < min) { System.out.println("*** Applet parameter " + parameter + " too small (" + i + ") - defaulting to " + min); i = min; } else if (i > max) { System.out.println("*** Applet parameter " + parameter + " too large (" + i + ") - defaulting to " + max); i = max; } } catch (NumberFormatException e) { System.out.println("*** Applet parameter " + parameter + " is not an integer (" + s + ") - defaulting to " + standby); i = standby; } return i; } /** * This looks for the named parameter in the HTML applet source code * and attempts to parse it into a boolean. If the parameter is not present * or doesn't parse, the standby value is returned. * * @param parameter the applet parameter name. * @param standby the value to retun in case the applet parameter is bad. * * @return either the value of the named parameter or standby. */ public boolean getAppletBoolean(String parameter, boolean standby) { final String s = getParameter(parameter); if (s == null) { System.out.println("*** Applet parameter " + parameter + " is missing - defaulting to " + standby); return standby; } final String sl = s.toLowerCase(); if (sl.equals("true")) return true; if (sl.equals("false")) return false; System.out.println("*** Applet parameter " + parameter + " is not a boolean - defaulting to " + standby); return standby; } /** * This looks for the named parameter in the HTML applet source code * and attempts to parse it into a byte. If all is well, the value is * checked that it lies between min and max inclusive and * then returned. If the parameter is not present or doesn't parse, * the standby value is returned. If the checks fail, the value * is truncated to either min or max (depending on the direction * of the error) and returned. * * @param parameter the applet parameter name. * @param min the minimum acceptable parameter value. * @param max the maximum acceptable parameter value. * @param standby the value to retun in case the applet parameter is bad. * * @return either the value of the named parameter or standby. */ public byte getAppletByte(String parameter, byte min, byte max, byte standby) { byte i; final String s = getParameter(parameter); if (s == null) { System.out.println("*** Applet parameter " + parameter + " is missing - defaulting to " + standby); i = standby; } else try { i = Byte.parseByte(s); if (i < min) { System.out.println("*** Applet parameter " + parameter + " too small (" + i + ") - defaulting to " + min); i = min; } else if (i > max) { System.out.println("*** Applet parameter " + parameter + " too large (" + i + ") - defaulting to " + max); i = max; } } catch (NumberFormatException e) { System.out.println("*** Applet parameter " + parameter + " is not a byte (" + s + ") - defaulting to " + standby); i = standby; } return i; } /** * This looks for the named parameter in the HTML applet source code * and attempts to parse it into a short. If all is well, the value is * checked that it lies between min and max inclusive and * then returned. If the parameter is not present or doesn't parse, * the standby value is returned. If the checks fail, the value * is truncated to either min or max (depending on the direction * of the error) and returned. * * @param parameter the applet parameter name. * @param min the minimum acceptable parameter value. * @param max the maximum acceptable parameter value. * @param standby the value to retun in case the applet parameter is bad. * * @return either the value of the named parameter or standby. */ public short getAppletShort(String parameter, short min, short max, short standby) { short i; final String s = getParameter(parameter); if (s == null) { System.out.println("*** Applet parameter " + parameter + " is missing - defaulting to " + standby); i = standby; } else try { i = Short.parseShort(s); if (i < min) { System.out.println("*** Applet parameter " + parameter + " too small (" + i + ") - defaulting to " + min); i = min; } else if (i > max) { System.out.println("*** Applet parameter " + parameter + " too large (" + i + ") - defaulting to " + max); i = max; } } catch (NumberFormatException e) { System.out.println("*** Applet parameter " + parameter + " is not a short (" + s + ") - defaulting to " + standby); i = standby; } return i; } /** * This looks for the named parameter in the HTML applet source code * and attempts to parse it into a long. If all is well, the value is * checked that it lies between min and max inclusive and * then returned. If the parameter is not present or doesn't parse, * the standby value is returned. If the checks fail, the value * is truncated to either min or max (depending on the direction * of the error) and returned. * * @param parameter the applet parameter name. * @param min the minimum acceptable parameter value. * @param max the maximum acceptable parameter value. * @param standby the value to retun in case the applet parameter is bad. * * @return either the value of the named parameter or standby. */ public long getAppletLong(String parameter, long min, long max, long standby) { long i; final String s = getParameter(parameter); if (s == null) { System.out.println("*** Applet parameter " + parameter + " is missing - defaulting to " + standby); i = standby; } else try { i = Long.parseLong(s); if (i < min) { System.out.println("*** Applet parameter " + parameter + " too small (" + i + ") - defaulting to " + min); i = min; } else if (i > max) { System.out.println("*** Applet parameter " + parameter + " too large (" + i + ") - defaulting to " + max); i = max; } } catch (NumberFormatException e) { System.out.println("*** Applet parameter " + parameter + " is not a long (" + s + ") - defaulting to " + standby); i = standby; } return i; } /** * This looks for the named parameter in the HTML applet source code * and attempts to parse it into a float. If all is well, the value is * checked that it lies between min and max inclusive and * then returned. If the parameter is not present or doesn't parse, * the standby value is returned. If the checks fail, the value * is truncated to either min or max (depending on the direction * of the error) and returned. * * @param parameter the applet parameter name. * @param min the minimum acceptable parameter value. * @param max the maximum acceptable parameter value. * @param standby the value to retun in case the applet parameter is bad. * * @return either the value of the named parameter or standby. */ public float getAppletFloat(String parameter, float min, float max, float standby) { float i; final String s = getParameter(parameter); if (s == null) { System.out.println("*** Applet parameter " + parameter + " is missing - defaulting to " + standby); i = standby; } else try { i = Float.valueOf(s).floatValue(); if (i < min) { System.out.println("*** Applet parameter " + parameter + " too small (" + i + ") - defaulting to " + min); i = min; } else if (i > max) { System.out.println("*** Applet parameter " + parameter + " too large (" + i + ") - defaulting to " + max); i = max; } } catch (NumberFormatException e) { System.out.println("*** Applet parameter " + parameter + " is not a float (" + s + ") - defaulting to " + standby); i = standby; } return i; } /** * This looks for the named parameter in the HTML applet source code * and attempts to parse it into a double. If all is well, the value is * checked that it lies between min and max inclusive and * then returned. If the parameter is not present or doesn't parse, * the standby value is returned. If the checks fail, the value * is truncated to either min or max (depending on the direction * of the error) and returned. * * @param parameter the applet parameter name. * @param min the minimum acceptable parameter value. * @param max the maximum acceptable parameter value. * @param standby the value to retun in case the applet parameter is bad. * * @return either the value of the named parameter or standby. */ public double getAppletDouble(String parameter, double min, double max, double standby) { double i; final String s = getParameter(parameter); if (s == null) { System.out.println("*** Applet parameter " + parameter + " is missing - defaulting to " + standby); i = standby; } else try { i = Double.valueOf(s).doubleValue(); if (i < min) { System.out.println("*** Applet parameter " + parameter + " too small (" + i + ") - defaulting to " + min); i = min; } else if (i > max) { System.out.println("*** Applet parameter " + parameter + " too large (" + i + ") - defaulting to " + max); i = max; } } catch (NumberFormatException e) { System.out.println("*** Applet parameter " + parameter + " is not a double (" + s + ") - defaulting to " + standby); i = standby; } return i; } //////////////////////////////////// // ActiveApplet as an ActivePanel // //////////////////////////////////// /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; // /** // * Constructs a new ActiveApplet with no configuration channel. // */ // public ActiveApplet () { // this (null); // } // /** // * Constructs a new ActiveApplet with a configuration channel. // * // * @param configure the channel for configuration events // * -- can be null if no configuration is required. // */ // public ActiveApplet (ChannelInput configure) { // this.configure = configure; // } /** * Sets the configuration channel for this ActiveApplet. * * @param configure the channel for configuration events. * If the channel passed is null, no action will be taken. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ContainerEvent has occurred. This should be used * instead of registering a ContainerListener with the component. It is * possible to add more than one Channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param containerEvent the channel down which to send ContainerEvents. */ public void addContainerEventChannel(ChannelOutput containerEvent) { if (containerEvent != null) { ContainerEventHandler handler = new ContainerEventHandler(containerEvent); addContainerListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will * have its configure method invoked on this component. *

* For example, to set the foreground/background colours, first define: *

    *   private class AppletColours implements ActiveApplet.Configure {
    * 
    *     private Color foreground = Color.white;
    *     private Color background = Color.black;
    * 
    *     public void setColour (Color foreground, Color background) {
    *       this.foreground = foreground;
    *       this.background = background;
    *     }
    * 
    *     public void configure (java.applet.Applet applet) {
    *       applet.setForeground (foreground);
    *       applet.setBackground (background);
    *     }
    * 
    *   }
    * 
* Then, construct an instance of AppletColours, set its foreground/background * colours as required and send it down the configure channel when appropriate. *

* Note that an instance of the above AppletColours may have its colours reset * and may be resent down the channel. To ensure against race-hazards, construct * at least two instances and use them alternately. Acceptance of one of them by the * ActiveApplet means that it has finished using the other and, therefore, * the other may be safely reset. So long as the configure channel is * unbuffered, completion of the write method means that the message has been * read (i.e. accepted) by the receiving process. */ static public interface Configure { /** * @param applet the Applet being configured. */ public void configure(final Applet applet); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Configure) { ((Configure) message).configure(this); } } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveTextEnterArea.java0000644000000000000000000004605211105701167020455 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.event.*; /** * A specialisation of {@link ActiveTextArea} that writes text to * the event channel only when ESCAPE is pressed. *

Process Diagram

*

*

*

Description

* ActiveTextEnterArea is a process containing an {@link ActiveTextArea ActiveTextArea}, * configured with channels for event notification and configuration. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. *

* The difference between this class and ActiveTextArea is that text * is only written to the event channel when ESCAPE is pressed on * the text area (not on every keystroke). When this happens, the text area * is temporarilly disabled for (by default) half a second; this is to give * feedback to the user. The disable period can be changed by calling the * setDisableTime method before the process is run. *

* The internal ActiveTextArea can be extracted with the getActiveTextArea method. * Channels can then be added to notify the occurrence of any other type of Event * the ActiveFrame generates. This is done by calling its appropriate * addXXXEventChannel method (before the process * is run). As many channels can be added as are needed. *

* Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that the output channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. The simplest way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myTextAreaEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveTextEnterArea myTextEnterArea =
 *     new ActiveTextEnterArea (null, myTextAreaEvent.out (), "Edit Me", 5, 20);
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringAppend the string to the text in this ActiveTextEnterArea
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the text area is made active
  2. *
  3. If this is the Boolean.FALSE object, * the text area is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveTextArea.ConfigureInvoke the user-defined Configure.configure method on the textArea.
otherwiseAppend the toString form of the object to the text in this ActiveTextArea.
Output Channels
eventStringThe text in the ActiveTextEnterArea (whenever ESCAPE is pressed)
componentEventComponentEventSee the * {@link #getActiveTextArea getActiveTextArea}.{@link ActiveTextArea#addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the * {@link #getActiveTextArea getActiveTextArea}.{@link ActiveTextArea#addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the * {@link #getActiveTextArea getActiveTextArea}.{@link ActiveTextArea#addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the * {@link #getActiveTextArea getActiveTextArea}.{@link ActiveTextArea#addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the * {@link #getActiveTextArea getActiveTextArea}.{@link ActiveTextArea#addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * import java.awt.*;
 * 
 * public class ActiveTextEnterAreaExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame frame =
 *       new ActiveClosingFrame ("ActiveTextEnterArea Example");
 * 
 *     final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final String[] string =
 *       {"Entia Non Sunt Multiplicanda Praeter Necessitatem",
 *        "Everything we do, we do it to you",
 *        "Race Hazards - What Rice Hozzers?",
 *        "Cogito Ergo Occam"};
 * 
 *     final String goodbye = "Goodbye World";
 * 
 *     final ActiveTextEnterArea[] activeText =
 *       new ActiveTextEnterArea[string.length];
 * 
 *     for (int i = 0; i < string.length; i++) {
 *       activeText[i] = new ActiveTextEnterArea (null, event.out (), string[i], 5, 40);
 *     }
 * 
 *     Panel panel = new Panel (new GridLayout (string.length/2, 2));
 *     for (int i = 0; i < string.length; i++) {
 *       panel.add (activeText[i].getActiveTextArea ());
 *     }
 * 
 *     final Frame realFrame = frame.getActiveFrame ();
 *     realFrame.setBackground (Color.green);
 *     realFrame.add (panel);
 *     realFrame.pack ();
 *     realFrame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         frame,
 *         new Parallel (activeText),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               String s = (String) event.in ().read ();
 *               System.out.println (s);
 *               running = (! s.equals (goodbye));
 *             }
 *             realFrame.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveTextArea * @see java.awt.TextArea * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveTextEnterArea implements CSProcess { private AltingChannelInput configure; private ChannelOutput event; private String s; private int rows; private int columns; private int scrollbars; private long disableTime = 500; private ActiveTextArea area; private One2OneChannel keyEvent = Channel.one2one(new OverWriteOldestBuffer(10)); private One2OneChannel textEvent = Channel.one2one(new OverWriteOldestBuffer(10)); private One2OneChannel configureA = Channel.one2one(); private One2OneChannel configureB = Channel.one2one(); /** * Constructs a new ActiveTextEnterArea with scrollbars, but with no configuration * or event channels or initial text or size. */ public ActiveTextEnterArea() { this(null, null, "", 0, 0, java.awt.TextArea.SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextEnterArea with scrollbars and initial text, * but with no configuration or event channels or initial size. * * @param s the initial text displayed in the area. */ public ActiveTextEnterArea(String s) { this(null, null, s, 0, 0, java.awt.TextArea.SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextEnterArea with scrollbars and initial text and size, * but with no configuration or event channels. * * @param s the initial text displayed in the area. * @param rows the rows of the area. * @param columns the columns of the area. */ public ActiveTextEnterArea(String s, int rows, int columns) { this(null, null, s, rows, columns, java.awt.TextArea.SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextEnterArea with user-defined scrollbars and initial text and size, * but with no configuration or event channels. * * @param s the initial text displayed in the area. * @param rows the rows of the area. * @param columns the columns of the area. * @param scrollbars the columns of the area (java.awt.TextArea.SCROLLBARS_BOTH, * java.awt.TextArea.SCROLLBARS_VERTICAL_ONLY, * java.awt.TextArea.SCROLLBARS_HORIZONTAL_ONLY * or java.awt.TextArea.SCROLLBARS_NONE). */ public ActiveTextEnterArea(String s, int rows, int columns, int scrollbars) { this(null, null, s, rows, columns, scrollbars); } /** * Constructs a new ActiveTextEnterArea with configuration and event channels and scrollbars, * but with no initial text or size. * * @param configure the AltingChannelInput for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text area is changed * -- can be null if no notification is required. */ public ActiveTextEnterArea(AltingChannelInput configure, ChannelOutput event) { this(configure, event, "", 0, 0, java.awt.TextArea.SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextEnterArea with configuration and event channels * and scrollbars and initial text, but with no initial size. * * @param configure the AltingChannelInput for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text area is changed * -- can be null if no notification is required. * @param s the initial text displayed in the area. */ public ActiveTextEnterArea(AltingChannelInput configure, ChannelOutput event, String s) { this(configure, event, s, 0, 0, java.awt.TextArea.SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextEnterArea with configuration and event channels * and scrollbars and initial text and size. * * @param configure the AltingChannelInput for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text area is changed * -- can be null if no notification is required. * @param s the initial text displayed in the area. * @param rows the rows of the area. * @param columns the columns of the area. */ public ActiveTextEnterArea(AltingChannelInput configure, ChannelOutput event, String s, int rows, int columns) { this(configure, event, s, rows, columns, java.awt.TextArea.SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextEnterArea with configuration and event channels * and user-defined scrollbars and initial text and size. * * @param configure the AltingChannelInput for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text area is changed * -- can be null if no notification is required. * @param s the initial text displayed in the area. * @param rows the rows of the area. * @param columns the columns of the area. * @param scrollbars the columns of the area (java.awt.TextArea.SCROLLBARS_BOTH, * java.awt.TextArea.SCROLLBARS_VERTICAL_ONLY, * java.awt.TextArea.SCROLLBARS_HORIZONTAL_ONLY * or java.awt.TextArea.SCROLLBARS_NONE). */ public ActiveTextEnterArea(AltingChannelInput configure, ChannelOutput event, String s, int rows, int columns, int scrollbars) { if (configure == null) this.configure = Channel.one2one().in(); // the Plex2 process must have non-null channels else this.configure = configure; this.event = event; this.s = s; this.rows = rows; this.columns = columns; this.scrollbars = scrollbars; this.area = new ActiveTextArea(configureB.in(), textEvent.out(), s, rows, columns, scrollbars); } /** * Sets the configuration channel for this ActiveTextEnterArea. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(AltingChannelInput configure) { if (configure != null) this.configure = configure; // the Plex2 process must have non-null channels } /** * This is used to set the time during which the text area is disabled * after an ESCAPE has been entered. *

* NOTE: This may only be called before this process is run. * * @param disableTime the disable time after an ESCAPE. */ public void setDisableTime(final long disableTime) { this.disableTime = disableTime; } /** * This is used to get the ActiveTextArea within this component * so that it can be configured (using {@link java.awt.TextArea} or * {@link org.jcsp.awt.ActiveTextArea} methods) or added to some container. * For example, event channels can be added by invoking * getActiveTextArea().addXXXEventChannel(...). *

* NOTE: such configuration must be finished before this process is run. *

* NOTE: do not use this method to set a configure channel - use an appropriate * constructor or {@link #setConfigureChannel setConfigureChannel}. * * @return the ActiveTextArea within this component. */ public ActiveTextArea getActiveTextArea() { return area; } /** * The main body of this process. */ public void run() { area.addKeyEventChannel(keyEvent.out()); new Parallel(new CSProcess[] { new Plex2(configure, configureA.in(), configureB.out()), area, new CSProcess() { public void run() { CSTimer tim = new CSTimer(); Guard[] guard = {keyEvent.in(), textEvent.in()}; Alternative alt = new Alternative(guard); String text = s; ChannelInput keyEventIn = keyEvent.in(); ChannelInput textEventIn = textEvent.in(); ChannelOutput configureAOut = configureA.out(); while (true) { switch (alt.priSelect()) { case 0: final KeyEvent key = (KeyEvent) keyEventIn.read(); switch (key.getKeyCode()) { case KeyEvent.VK_ESCAPE: switch (key.getID()) { case KeyEvent.KEY_PRESSED: if (event != null) event.write(text); configureAOut.write(Boolean.FALSE); tim.after(tim.read() + disableTime); configureAOut.write(Boolean.TRUE); break; } break; } break; case 1: text = (String) textEventIn.read(); break; } } } } }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveButton.java0000644000000000000000000004172711105701167017221 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Button java.awt.Button} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveButton is a process extension of java.awt.Button * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers the current button label whenever * the ActiveButton is pressed. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myButtonEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveButton myButton =
 *     new ActiveButton (null, myButtonEvent.out (), "Press Me");
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringChange the label on the ActiveButton to the value of the String.
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the button is made active.
  2. *
  3. If this is the Boolean.FALSE object, * the button is made inactive.
  4. *
  5. Other Boolean objects are ignored.
  6. *
*
ActiveButton.ConfigureInvoke the user-defined Configure.configure method on the button.
Output Channels
eventStringThe label on the ActiveButton (when the button is pressed and released).
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveButtonExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveButton Example");
 * 
 *     final String[] label = {"Hello World", "Rocket Science", "CSP",
 *                             "Monitors", "Ignore Me", "Goodbye World"};
 * 
 *     final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveButton[] button = new ActiveButton[label.length];
 *     for (int i = 0; i < label.length; i++) {
 *       button[i] = new ActiveButton (null, event.out (), label[i]);
 *       button[i].setBackground (Color.green);
 *     }
 * 
 *     root.setSize (300, 200);
 *     root.setLayout (new GridLayout (label.length/2, 2));
 *     for (int i = 0; i < label.length; i++) {
 *       root.add (button[i]);
 *     }
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Parallel (button),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) event.in ().read ();
 *               System.out.println ("Button `" + s + "' pressed ...");
 *               running = (s != label[label.length - 1]);
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.Button * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveButton extends Button implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The Configurer. */ // private Configurer configurer = null; /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveButton with no label, configuration or * event channels. */ public ActiveButton() { this(""); } /** * Constructs a new ActiveButton with no configuration or * event channels. * * @param s the initial label displayed on the button. */ public ActiveButton(String s) { this(null, null, s); } /** * Constructs a new ActiveButton with no initial label. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current label will be output when the button is pressed * -- can be null if no notification is required. */ public ActiveButton(ChannelInput configure, ChannelOutput event) { this(configure, event, ""); } /** * Constructs a new ActiveButton. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current label will be output when the button is pressed * -- can be null if no notification is required. * @param s the initial label displayed on the button. */ public ActiveButton(ChannelInput configure, ChannelOutput event, String s) { super(s); // Only create an event handler if the event Channel is not null. if (event != null) { ActionEventHandler handler = new ActionEventHandler(event); addActionListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveButton. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * the button has been pressed. This should be used * instead of registering an ActionListener with the component. It is * possible to add more than one channel by calling this method multiple times. * If the channel passed is null, no action will be taken. * This method is an alternative to setting such a channel in the constructor. *

* NOTE: This method must be called before this process is run. * * @param event the channel down which to send the current label * when the button is pressed. */ public void addEventChannel(ChannelOutput event) { if (event != null) { ActionEventHandler handler = new ActionEventHandler(event); addActionListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one channel by calling this method multiple times. * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component * will have its configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param button the Button being configured. */ public void configure(final Button button); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message == null) { break; } else if (message instanceof String) { setLabel((String) message); } else if (message instanceof Boolean) { if (message == Boolean.TRUE) { setEnabled(true); } else if (message == Boolean.FALSE) { setEnabled(false); } } else if (message instanceof Color) { setBackground((Color) message); } else if (message instanceof Configure) { ((Configure) message).configure(this); } } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActionEventHandler.java0000644000000000000000000000560611105701167020323 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.event.*; import org.jcsp.lang.*; /** * @author P.D. Austin and P.H. Welch */ class ActionEventHandler implements ActionListener { /** The Channel down which ActionEvent commands are sent. */ private ChannelOutput event; /** * constructs a new ActionEventHandler with the specified output Channel. * * @param event The Channel to send the event notification down */ public ActionEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when an action occurs on the component. It assumes the * event channel is being serviced (e.g. by an overwriting channel). * * @param e the parameter associated with this event */ public void actionPerformed(ActionEvent e) { event.write(e.getActionCommand()); } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveChoice.java0000644000000000000000000003625411105701167017137 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Choice java.awt.Choice} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveChoice is a process extension of java.awt.Choice * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers the generated java.awt.ItemEvent whenever * an item from the ActiveChoice is selected. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myChoiceEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveChoice myChoice =
 *     new ActiveChoice (null, myChoiceEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureString * Sets the selected item in this ActiveChoice menu to be the item * whose name is equal to the specified ActiveChoice. If more than * one item matches, the one with the smallest index is selected. *
Integer * Sets the selected item in this ActiveChoice menu to be the item * at the specified position. *
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the choice is made active
  2. *
  3. If this is the Boolean.FALSE object, * the choice is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveChoice.ConfigureInvoke the user-defined Configure.configure method on the choice.
Output Channels
eventItemEvent * When the ActiveChoice is operated, * the generated java.awt.ItemEvent is written down this channel. *
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveChoiceExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveChoice Example");
 * 
 *     final One2OneChannel close = Channel.one2one (new OverWriteOldestBuffer (1));
 * 
 *     final ActiveChoice choice = new ActiveChoice (null, close.out ());
 * 
 *     final String[] menu = {"Hello World", "Rocket Science", "CSP",
 *                            "Monitors", "Ignore Me", "Goodbye World"};
 * 
 *     for (int i = 0; i < menu.length; i++) {
 *       choice.add (menu[i]);
 *     }
 * 
 *     root.setSize (200, 100);
 *     root.add (choice);
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         choice,
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               ItemEvent e = (ItemEvent) close.in ().read ();
 *               String item = (String) e.getItem ();
 *               System.out.println ("Selected ==> `" + item + "'");
 *               running = (item != menu[menu.length - 1]);
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see java.awt.Choice * @see java.awt.event.ItemEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveChoice extends Choice implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs an ActiveChoice with no configuration * or event channels. */ public ActiveChoice() { this(null, null); } /** * Constructs an ActiveChoice with configuration and event channels. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the ItemEvent will be output when the choice * is exercised -- can be null if no notification is required. */ public ActiveChoice(ChannelInput configure, ChannelOutput event) { if (event != null) { ItemEventHandler handler = new ItemEventHandler(event); addItemListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveChoice. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param choice the Choice being configured. */ public void configure(final Choice choice); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) select((String) message); else if (message instanceof Integer) select(((Integer) message).intValue()); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveDialog.java0000644000000000000000000004426611105701167017146 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Dialog java.awt.Dialog} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveDialog is a process extension of java.awt.Dialog * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers a WindowEvent whenever one is generated * on the ActiveDialog. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component – no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced – otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveDialog myDialog = new ActiveDialog ();
 *   myDialog.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureBoolean *
    *
  1. If this is the Boolean.TRUE object, * the dialog is made visible
  2. *
  3. If this is the Boolean.FALSE object, * the dialog is made invisible
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveDialog.ConfigureInvoke the user-defined Configure.configure method on the dialog.
Output Channels
eventWindowEventThe WindowEvent generated by the component
containerEventContainerEventSee the {@link #addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveDialogExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ();
 * 
 *     final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveDialog dialog = new ActiveDialog (null, event.out (), root, "ActiveDialog Example");
 * 
 *     dialog.setSize (300, 200);
 *     dialog.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         dialog,
 *         new CSProcess () {
 *           public void run () {
 *             while (true) {
 *               WindowEvent w = (WindowEvent) event.in ().read ();
 *               System.out.println (w);
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.Dialog * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveDialog extends Dialog implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new non-modal ActiveDialog with a blank title * and no configuration or event channels. * * @param parent the parent frame for the dialog. */ public ActiveDialog(Frame parent) { this(null, null, parent, "", false); } /** * Constructs a new ActiveDialog with a blank title * and no configuration or event channels. * * @param parent the parent frame for the dialog. * @param modal if true, dialog blocks input to the parent window when shown. */ public ActiveDialog(Frame parent, boolean modal) { this(null, null, parent, "", modal); } /** * Constructs a new non-modal ActiveDialog * with no configuration or event channels. * * @param parent the parent frame for the dialog. * @param title the title of the dialog. */ public ActiveDialog(Frame parent, String title) { this(null, null, parent, title, false); } /** * Constructs a new ActiveDialog * with no configuration or event channels. * * @param parent the parent frame for the dialog. * @param title the title of the dialog. * @param modal if true, dialog blocks input to the parent window when shown. */ public ActiveDialog(Frame parent, String title, boolean modal) { this(null, null, parent, title, false); } /** * Constructs a new non-modal ActiveDialog with a blank title. * * @param configure the channel for configuration events * (can be null if no configuration is required). * @param event the WindowEvent will be output whenever it occurs * (can be null if no notification is required). * @param parent the parent frame for the dialog. */ public ActiveDialog(ChannelInput configure, ChannelOutput event, Frame parent) { this(configure, event, parent, "", false); } /** * Constructs a new ActiveDialog with a blank title. * * @param configure the channel for configuration events * (can be null if no configuration is required). * @param event the WindowEvent will be output whenever it occurs * (can be null if no notification is required). * @param parent the parent frame for the dialog. * @param modal if true, dialog blocks input to the parent window when shown. */ public ActiveDialog(ChannelInput configure, ChannelOutput event, Frame parent, boolean modal) { this(configure, event, parent, "", modal); } /** * Constructs a new non-modal ActiveDialog. * * @param configure the channel for configuration events * (can be null if no configuration is required). * @param event the WindowEvent will be output whenever it occurs * (can be null if no notification is required). * @param parent the parent frame for the dialog. * @param title the title of the dialog. */ public ActiveDialog(ChannelInput configure, ChannelOutput event, Frame parent, String title) { this(configure, event, parent, title, false); } /** * Constructs a new ActiveDialog. * * @param configure the channel for configuration events * (can be null if no configuration is required). * @param event the WindowEvent will be output whenever it occurs * (can be null if no notification is required). * @param parent the parent frame for the dialog. * @param title the title of the dialog. * @param modal if true, dialog blocks input to the parent window when shown. */ public ActiveDialog(ChannelInput configure, ChannelOutput event, Frame parent, String title, boolean modal) { super(parent, title, modal); if (event != null) { WindowEventHandler handler = new WindowEventHandler(event); addWindowListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveDialog. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * (can be null if no configuration is required). */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ContainerEvent has occurred. This should be used * instead of registering a ContainerListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param containerEvent the channel down which to send ContainerEvents. */ public void addContainerEventChannel(ChannelOutput containerEvent) { if (containerEvent != null) { ContainerEventHandler handler = new ContainerEventHandler(containerEvent); addContainerListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param dialog the Dialog being configured. */ public void configure(final Dialog dialog); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Boolean) { if (message == Boolean.TRUE) setVisible(true); else if (message == Boolean.FALSE) setVisible(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveWindow.java0000644000000000000000000003610411105701167017206 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Window java.awt.Window} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveWindow is a process extension of java.awt.Window * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers a WindowEvent whenever one is generated * on the ActiveWindow. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveWindow myWindow = new ActiveWindow ();
 *   myWindow.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureBoolean *
    *
  1. If this is the Boolean.TRUE object, * the window is made visible
  2. *
  3. If this is the Boolean.FALSE object, * the window is made invisible
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveWindow.ConfigureInvoke the user-defined Configure.configure method on the window.
Output Channels
eventWindowEventThe WindowEvent generated by the component
containerEventContainerEventSee the {@link #addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveWindowExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveWindow Example");
 * 
 *     final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveWindow window = new ActiveWindow (null, event.out (), root);
 * 
 *     root.setSize (400, 400);
 *     root.setVisible (true);
 *     window.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         window,
 *         new CSProcess () {
 *           public void run () {
 *             while (true) {
 *               WindowEvent w = (WindowEvent) event.in ().read ();
 *               System.out.println (w);
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.Window * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveWindow extends Window implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveWindow. * * @param f the parent frame for the window. */ public ActiveWindow(Frame f) { this(null, null, f); } /** * Constructs a new ActiveWindow. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the WindowEvent will be output whenever it occurs * -- can be null if no notification is required. * @param f the parent frame for the window. */ public ActiveWindow(ChannelInput configure, ChannelOutput event, Frame f) { super(f); if (event != null) { WindowEventHandler handler = new WindowEventHandler(event); addWindowListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveWindow. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events. * If the channel passed is null, no action will be taken. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ContainerEvent has occurred. This should be used * instead of registering a ContainerListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param containerEvent the channel down which to send ContainerEvents. */ public void addContainerEventChannel(ChannelOutput containerEvent) { if (containerEvent != null) { ContainerEventHandler handler = new ContainerEventHandler(containerEvent); addContainerListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param window the Window being configured. */ public void configure(final Window window); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Boolean) { if (message == Boolean.TRUE) setVisible(true); else if (message == Boolean.FALSE) setVisible(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ContainerEventHandler.java0000644000000000000000000000672611105701167021034 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.event.*; import org.jcsp.lang.*; /** * @author P.D. Austin and P.H. Welch */ class ContainerEventHandler implements ContainerListener { /** * The Channel action event notifications are sent down. */ private ChannelOutput event; /** * constructs a new ContainerEventHandler with the specified event output * Channel. * * @param event The Channel to send the event notification down */ public ContainerEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when the Container the event handler is listening to has a new * Component added to it. Notifies the event process that a * ContainerEvent has occurred by sending the ContainerEvent Object. * Some notifications will be lost so there are no guarantees that all * events generated will be processed. * * @param e The parameters associated with this event */ public void componentAdded(ContainerEvent e) { event.write(e); } /** * Invoked when the Container the event handler is listening to has a new * Component removed from it. Notifies the event process that a * ContainerEvent has occurred by sending the ContainerEvent Object. * Some notifications will be lost so there are no guarantees that all * events generated will be processed. * * @param e The parameters associated with this event */ public void componentRemoved(ContainerEvent e) { event.write(e); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveComponent.java0000644000000000000000000003363511105701167017707 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Component java.awt.Component} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveComponent is a process extension of java.awt.Component * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure channel is settable from a constructor. * Event channels can be added to notify the occurrence of any type of Event * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveComponent myComponent = new ActiveComponent ();
 *   myComponent.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureActiveComponent.ConfigureInvoke the user-defined Configure.configure method on the component.
Output Channels
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.util.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveComponentExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveComponent Example");
 * 
 *     final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveComponent component = new ActiveComponent ();
 *     component.addMouseEventChannel (mouseEvent.out ());
 * 
 *     root.add (component);
 *     root.setSize (400, 400);
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         component,
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final MouseEvent event = (MouseEvent) mouseEvent.in ().read ();
 *               switch (event.getID ()) {
 *                 case MouseEvent.MOUSE_ENTERED:
 *                   System.out.println ("MOUSE_ENTERED");
 *                 break;
 *                 case MouseEvent.MOUSE_EXITED:
 *                   System.out.println ("MOUSE_EXITED");
 *                 break;
 *                 case MouseEvent.MOUSE_PRESSED:
 *                   System.out.println ("MOUSE_PRESSED");
 *                 break;
 *                 case MouseEvent.MOUSE_RELEASED:
 *                   System.out.println ("MOUSE_RELEASED");
 *                 break;
 *                 case MouseEvent.MOUSE_CLICKED:
 *                   if (event.getClickCount() > 1) {
 *                     System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!");
 *                     running = false;
 *                   } else {
 *                     System.out.println ("MOUSE_CLICKED ... *double* click to quit!");
 *                   }
 *                 break;
 *               }
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.Component * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveComponent extends Component implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveComponent with no configuration channel. */ public ActiveComponent() { this(null); } /** * Constructs a new ActiveComponent with a configuration channel. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public ActiveComponent(ChannelInput configure) { this.configure = configure; } /** * Sets the configuration channel for this ActiveComponent. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which ComponentEvents will be sent. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which FocusEvents will be sent. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which KeyEvents will be sent. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which MouseEvents will be sent. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which MouseMotionEvents will be sent. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object * implementing this interface and sent down the configure channel to * this component will have its configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param component the Component being configured. */ public void configure(final Component component); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/AdjustmentEventHandler.java0000644000000000000000000000600011105701167021211 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.event.*; import org.jcsp.lang.*; /** * @author P.D. Austin and P.H. Welch */ class AdjustmentEventHandler implements AdjustmentListener { /** * The Channel AdjustmentEvent notifications are sent down. */ private ChannelOutputInt event; /** * Constructs a new AdjustmentEventHandler with the specified event Channel. * * @param event The Channel AdjustmentEvent notifications are sent down. */ public AdjustmentEventHandler(ChannelOutputInt event) { this.event = event; } /** * Invoked when an adjustment occurs on the component the event handler is * listening to. Notifies the event process that an AdjustmentEvent has * occurred. Some notifications will be lost so there are no guarantees * that all events generated will be processed. Sets the value to the * current value of the component. * * @param e The parameters associated with this event */ public void adjustmentValueChanged(AdjustmentEvent e) { event.write(e.getValue()); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveCanvas.java0000644000000000000000000005434311105701167017157 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Canvas java.awt.Canvas} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveCanvas is a process extension of java.awt.Canvas * with channels for run-time configuration/interrogation and event notification. * The event channels should be connected to one or more application-specific server. * processes (instead of registering a passive object as a Listener * to this component). *

* All channels are optional. The toGraphics/fromGraphics channels are * set by calling the {@link ActiveCanvas#setGraphicsChannels setGraphicsChannels} method. * Event channels can be added to notify the occurrence of any type of Event * the component generates by calling the appropriate * addXXXEventChannel method. * All channel connections must be made before the process is run. *

* Messages can be sent down the toGraphics channel at any time to configure * or interrogate the component. A reply or acknowledgment is returned down * the fromGraphics channel and must be read. * See the table below and {@link GraphicsProtocol} for details. *

* Graphics operations on an ActiveCanvas are most conveniently managed * by attaching, and then setting {@link GraphicsCommand}s on, a {@link DisplayList} * (or any user-defined object implementing the {@link Paintable} interface). * This can be done either statically via the {@link #setPaintable setPaintable} * method, or dynamically * via the {@link #setGraphicsChannels toGraphics/fromGraphics} channels * (see {@link GraphicsProtocol.SetPaintable}). *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveCanvas myCanvas = new ActiveCanvas ();
 *   myCanvas.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
displayListGraphicsCommand[]See {@link org.jcsp.awt.DisplayList} and {@link org.jcsp.awt.GraphicsCommand}.
toGraphicsGraphicsProtocolSee {@link org.jcsp.awt.GraphicsProtocol}.
Output Channels
fromGraphicsObjectResponse to the fromGraphics message. See the documentation on * {@link org.jcsp.awt.GraphicsProtocol}. *
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveCanvasExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame activeClosingFrame =
 *       new ActiveClosingFrame ("ActiveCanvas Example");
 *     final Frame frame = activeClosingFrame.getActiveFrame ();
 * 
 *     final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final DisplayList displayList = new DisplayList ();
 * 
 *     final ActiveCanvas canvas = new ActiveCanvas ();
 *     canvas.addMouseEventChannel (mouseEvent.out ());
 *     canvas.setPaintable (displayList);
 *     canvas.setSize (600, 400);
 * 
 *     frame.add (canvas);
 *     frame.pack ();
 *     frame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         activeClosingFrame,
 *         canvas,
 *         new CSProcess () {
 *           public void run () {
 *             final String clickMessage = "D O U B L E - C L I C K   T H E   M O U S E   T O   E X I T";
 *             final String clickPlea = "       P L E A S E   M O V E   T H E   M O U S E   B A C K    ";
 *             final GraphicsCommand[] mouseEntered =
 *               {new GraphicsCommand.SetColor (Color.cyan),
 *                new GraphicsCommand.FillRect (0, 0, 600, 400),
 *                new GraphicsCommand.SetColor (Color.black),
 *                new GraphicsCommand.DrawString (clickMessage, 140, 200)};
 *             final GraphicsCommand[] mouseExited =
 *               {new GraphicsCommand.SetColor (Color.pink),
 *                new GraphicsCommand.FillRect (0, 0, 600, 400),
 *                new GraphicsCommand.SetColor (Color.black),
 *                new GraphicsCommand.DrawString (clickPlea, 140, 200)};
 *             final GraphicsCommand mousePressed =
 *               new GraphicsCommand.DrawString (clickMessage, 160, 220);
 *             final GraphicsCommand mouseReleased =
 *               new GraphicsCommand.DrawString (clickMessage, 140, 200);
 *             displayList.set (mouseExited);
 *             boolean running = true;
 *             while (running) {
 *               final MouseEvent event = (MouseEvent) mouseEvent.in ().read ();
 *               switch (event.getID ()) {
 *                 case MouseEvent.MOUSE_ENTERED:
 *                   System.out.println ("MOUSE_ENTERED");
 *                   displayList.set (mouseEntered);
 *                 break;
 *                 case MouseEvent.MOUSE_EXITED:
 *                   System.out.println ("MOUSE_EXITED");
 *                   displayList.set (mouseExited);
 *                 break;
 *                 case MouseEvent.MOUSE_PRESSED:
 *                   System.out.println ("MOUSE_PRESSED");
 *                   displayList.change (mousePressed, 3);
 *                 break;
 *                 case MouseEvent.MOUSE_RELEASED:
 *                   System.out.println ("MOUSE_RELEASED");
 *                   displayList.change (mouseReleased, 3);
 *                 break;
 *                 case MouseEvent.MOUSE_CLICKED:
 *                   if (event.getClickCount() > 1) {
 *                     System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!");
 *                     running = false;
 *                   }
 *                 break;
 *               }
 *             }
 *             frame.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.DisplayList * @see org.jcsp.awt.Display * @see org.jcsp.awt.GraphicsCommand * @see org.jcsp.awt.Paintable * @see org.jcsp.awt.GraphicsProtocol * @see org.jcsp.util.OverWriteOldestBuffer * @see java.awt.Canvas * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * * @author P.D. Austin and P.H. Welch */ public class ActiveCanvas extends Canvas implements CSProcess { private ChannelInput toGraphics; private ChannelOutput fromGraphics; /** * Set the toGraphics/fromGraphics channels for configuring * and/or examining this component. * A {@link GraphicsProtocol org.jcsp.awt.GraphicsProtocol} object sent down * the toGraphics channel generates the appropriate configuration or enquiry * action. A reply object is always returned down the fromGraphics channel. *

* NOTE: This method must be called before this process is run. *

* * @param toGraphics the channel down which GraphicsProtocol objects are sent. * @param fromGraphics the reply/acknowledgement channel responding to the GraphicsProtocol object. */ public void setGraphicsChannels(ChannelInput toGraphics, ChannelOutput fromGraphics) { this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; } private Paintable paintable; /** * Set the {@link Paintable Paintable} object that will be used by the {@link ActiveCanvas#paint paint} * and {@link ActiveCanvas#update update} methods of this canvas. If paintable is * null, the paint/update methods will not be overriden. *

* JCSP provides a {@link DisplayList} as an example Paintable class. * This can be thought of as a special form of channel. A user process at the other * end writes to it by setting up and/or editing an ordered list of * {@link GraphicsCommand}s. This method may be used to connect the DisplayList * to this ActiveCanvas. For example: *

    *   final ActiveCanvas myActiveCanvas = new ActiveCanvas ();
    *   
    *   final DisplayList draw = new DisplayList ();
    *   myActiveCanvas.setPaintable (draw);
    *   
    *   ...  connect other channels (toGraphics, fromGraphics, mouseEvent, etc.)
    *   
    *   // myActiveCanvas is now ready to run
    * 
*

* NOTE: If setPaintable is going to be invoked, this must happen * before this process is run. *

* Alternatively, the {@link Paintable Paintable} object may be set dynamically * by sending an appropriate {@link GraphicsProtocol.SetPaintable} object down the * {@link ActiveCanvas#setGraphicsChannels(org.jcsp.lang.ChannelInput,org.jcsp.lang.ChannelOutput) toGraphics} * channel. *

* * @param paintable the object to be used for painting/updating the canvas. */ public void setPaintable(Paintable paintable) { this.paintable = paintable; paintable.register(this); } /** * This method is used by the JVM event thread -- it is not really for public * consumption. If {@link ActiveCanvas#setPaintable setPaintable} has been invoked * on this canvas or a {@link GraphicsProtocol.SetPaintable} object has been sent down * the {@link ActiveCanvas#setGraphicsChannels(org.jcsp.lang.ChannelInput,org.jcsp.lang.ChannelOutput) toGraphics} * channel, this method uses the supplied {@link Paintable Paintable} object * to do the painting. *

*/ public void paint(Graphics g) { if (paintable == null) super.paint(g); else paintable.paint(g); } /** * This method is used by the JVM event thread -- it is not really for public * consumption. If {@link ActiveCanvas#setPaintable setPaintable} has been invoked * on this canvas or a {@link GraphicsProtocol.SetPaintable} object has been sent down * the {@link ActiveCanvas#setGraphicsChannels(org.jcsp.lang.ChannelInput,org.jcsp.lang.ChannelOutput) toGraphics} * channel, this method uses the supplied {@link Paintable Paintable} object * to do the updating. *

*/ public void update(Graphics g) { if (paintable == null) super.update(g); else paintable.update(g); } /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. *

* * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. *

* * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. *

* * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. *

* * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. *

* * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } private int requestedWidth, requestedHeight; /** * Request that the canvas takes the size given by the parameters. * The methods {@link #getPreferredSize getPreferredSize} * and {@link #getMinimumSize getMinimumSize} are * overridden to return these dimensions. *

* NOTE: This method must be called before this process is run. *

* * @param requestedWidth the requested width for the canvas. * @param requestedHeight the requested height for the canvas. */ public void setSize(int requestedWidth, int requestedHeight) { this.requestedWidth = requestedWidth; this.requestedHeight = requestedHeight; } /** * This method is used by system classes -- it is not really for public consumption! *

*/ public Dimension getPreferredSize() { return new Dimension(requestedWidth, requestedHeight); } /** * This method is used by system classes -- it is not really for public consumption! *

*/ public Dimension getMinimumSize() { return new Dimension(requestedWidth, requestedHeight); } /** * The main body of this process. */ public void run() { if (toGraphics != null) { while (true) { final GraphicsProtocol gp = (GraphicsProtocol) toGraphics.read(); if (gp == null) break; else { switch (gp.tag) { case GraphicsProtocol.GET_DIMENSION_TAG: fromGraphics.write(getSize()); break; case GraphicsProtocol.GET_COMPONENT_TAG: fromGraphics.write(this); break; case GraphicsProtocol.GET_BACKGROUND_TAG: fromGraphics.write(getBackground()); break; case GraphicsProtocol.SET_BACKGROUND_TAG: final GraphicsProtocol.SetBackground sbc = (GraphicsProtocol.SetBackground) gp; setBackground(sbc.color); fromGraphics.write(Boolean.TRUE); break; case GraphicsProtocol.REQUEST_FOCUS_TAG: requestFocus(); fromGraphics.write(Boolean.TRUE); break; case GraphicsProtocol.MAKE_MIS_IMAGE_TAG: final GraphicsProtocol.MakeMISImage mmi = (GraphicsProtocol.MakeMISImage) gp; fromGraphics.write(createImage(mmi.mis)); break; case GraphicsProtocol.SET_PAINTABLE_TAG: final GraphicsProtocol.SetPaintable sp = (GraphicsProtocol.SetPaintable) gp; paintable = sp.paintable; paintable.register(this); fromGraphics.write(Boolean.TRUE); break; case GraphicsProtocol.GENERAL_TAG: final GraphicsProtocol.General general = (GraphicsProtocol.General) gp; fromGraphics.write(general.c.configure(this)); break; } } } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/Display.java0000644000000000000000000001153611105701167016212 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; /** * Objects implementing this interface provide graphics services to a {@link org.jcsp.lang.CSProcess}. *

Description

* Display is an interface to a passive object providing graphics * services on behalf of a {@link org.jcsp.lang.CSProcess}. Such an object provides * an occam3-like CALL channel between the application * CSProcess and the active graphics component (such as * {@link ActiveCanvas ActiveCanvas}) on which it wishes to draw. * * @see org.jcsp.awt.DisplayList * * @author P.H. Welch */ public interface Display { /** * Sets the array of GraphicsCommands to be interpreted. The commands will * be interpreted in ascending order of index. *

* * @param c the array of GraphicsCommands to be interpreted. */ public void set (final GraphicsCommand[] c); /** * Sets the GraphicsCommand to be interpreted. *

* * @param c the array of GraphicsCommands to be interpreted. */ public void set (final GraphicsCommand c); /** * Extends the array of GraphicsCommands to be interpreted. *

* * @param c the extra GraphicsCommands to be interpreted. * @return the start index of the extension. */ public int extend (final GraphicsCommand[] c); /** * Extends the array of GraphicsCommands to be executed by one command. *

* * @param c the extra GraphicsCommand to be interpreted. * @return the start index of the extension. */ public int extend (final GraphicsCommand c); /** * Changes the array of GraphicsCommands to be interpreted by replacing elements * i onwards with the new ones. There must be at least (i + c.length) * elements in the original array -- else this method will not change anything and will * return false. *

* * @param c the new GraphicsCommands to be interpreted. * @param i the start index for the replacement. * @return true if and only if the changes are successfully made. */ public boolean change (final GraphicsCommand[] c, final int i); /** * Changes the array of GraphicsCommands to be executed by replacing element * i with the new one. There must be at least (i + 1) * elements in the original array -- else this method will not change anything and will * return false. *

* * @param c the new GraphicsCommand to be interpreted. * @param i the index for the replacement. * @return true if and only if the changes are successfully made. */ public boolean change (final GraphicsCommand c, final int i); /** * Returns a copy of the array of GraphicsCommands currently held. *

* * @return a copy of the array of GraphicsCommands currently held. */ public GraphicsCommand[] get (); } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveMenuItem.java0000644000000000000000000003131311105701167017457 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.MenuItem java.awt.MenuItem} * with a channel interface. *

Process Diagram

*

*

*

Description

* ActiveMenuItem is a process extension of java.awt.MenuItem * with channels for run-time configuration and event notification. The event channel * should be connected to an application-specific server process (instead * of registering a passive object as a Listener to this component). *

* The configure and event channels are * settable from a constructor. * The event channel delivers the current label on the * ActiveMenuItem whenever it is selected. * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service the event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that a (non-null) event channel from this process is * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMenuItemEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveMenuItem myMenuItem =
 *     new ActiveMenuItem (null, myMenuItemEvent.out (), "Choose Me");
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringChange the label on the ActiveMenuItem to the value of the String
java.awt.MenuShortcutSets the MenuShortcut for the ActiveMenuItem
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the menuItem is made active
  2. *
  3. If this is the Boolean.FALSE object, * the menuItem is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveMenuItem.ConfigureInvoke the user-defined Configure.configure method on the menuItem.
Output Channels
eventStringThe label on the ActiveMenuItem (when the item is selected)
*
*

Example

*
 * import java.awt.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveMenuItemExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame activeClosingFrame =
 *       new ActiveClosingFrame ("ActiveMenuItem Example");
 * 
 *     final ActiveFrame frame = activeClosingFrame.getActiveFrame ();
 * 
 *     final MenuBar menuBar = new MenuBar ();
 *     frame.setMenuBar (menuBar);
 * 
 *     final Menu fileMenu = new Menu ("File");
 *     final Menu langMenu = new Menu ("Language");
 *     menuBar.add (fileMenu);
 *     menuBar.add (langMenu);
 * 
 *     final String[] fileOptions = {"Hello World", "Rocket Science", "CSP",
 *                                   "Monitors", "Ignore Me", "Goodbye World"};
 *     final String[] langOptions = {"occam-pi", "Java", "Smalltalk", "Algol-60",
 *                                   "Pascal", "Haskell", "SML", "Lisp"};
 * 
 *     final Any2OneChannel event[] = Channel.any2oneArray (2, new OverWriteOldestBuffer (10));
 * 
 *     final ActiveMenuItem[] fileMenuItem = new ActiveMenuItem[fileOptions.length];
 *     for (int i = 0; i < fileOptions.length; i++) {
 *       fileMenuItem[i] = new ActiveMenuItem (null, event[0].out (), fileOptions[i]);
 *       fileMenu.add (fileMenuItem[i]);
 *     }
 * 
 *     final ActiveMenuItem[] langMenuItem = new ActiveMenuItem[langOptions.length];
 *     for (int i = 0; i < langOptions.length; i++) {
 *       langMenuItem[i] = new ActiveMenuItem (null, event[1].out (), langOptions[i]);
 *       langMenu.add (langMenuItem[i]);
 *     }
 * 
 *     frame.setSize (300, 200);
 *     frame.setBackground (Color.green);
 *     frame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         activeClosingFrame,
 *         new Parallel (fileMenuItem),
 *         new Parallel (langMenuItem),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) event[0].in ().read ();
 *               System.out.println ("File ==> `" + s + "' selected ...");
 *               running = (s != fileOptions[fileOptions.length - 1]);
 *             }
 *             frame.setVisible (false);
 *             System.exit (0);
 *           }
 *         },
 *         new CSProcess () {
 *           public void run () {
 *             while (true) {
 *               final String s = (String) event[1].in ().read ();
 *               System.out.println ("Language ==> `" + s + "' selected ...");
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see java.awt.MenuItem * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveMenuItem extends MenuItem implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveMenuItem with no label and no shortcut * and no configuration or event channels. * */ public ActiveMenuItem() { this(null, null, "", null); } /** * Constructs a new ActiveMenuItem with no shortcut * and no configuration or event channels. * * @param s the initial label displayed on the menuItem. */ public ActiveMenuItem(String s) { this(null, null, s, null); } /** * Constructs a new ActiveMenuItem * with no configuration or event channels. * * @param s the initial label displayed on the menuItem. * @param ms the MenuShortcut for the menuItem. */ public ActiveMenuItem(String s, MenuShortcut ms) { this(null, null, s, ms); } /** * Constructs a new ActiveMenuItem with no label and no shortcut. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current label will be output when the menuItem is selected * -- can be null if no notification is required. */ public ActiveMenuItem(ChannelInput configure, ChannelOutput event) { this(configure, event, "", null); } /** * Constructs a new ActiveMenuItem with no shortcut. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current label will be output when the menuItem is selected * -- can be null if no notification is required. * @param s the initial label displayed on the menuItem. */ public ActiveMenuItem(ChannelInput configure, ChannelOutput event, String s) { this(configure, event, s, null); } /** * Constructs a new ActiveMenuItem. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current label will be output when the menuItem is selected * -- can be null if no notification is required. * @param s the initial label displayed on the menuItem. * @param ms the MenuShortcut for the menuItem. */ public ActiveMenuItem(ChannelInput configure, ChannelOutput event, String s, MenuShortcut ms) { super(s, ms); if (event != null) { ActionEventHandler handler = new ActionEventHandler(event); addActionListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveMenuItem. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param menuItem the MenuItem being configured. */ public void configure(final MenuItem menuItem); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) setLabel((String) message); else if (message instanceof MenuShortcut) setShortcut((MenuShortcut) message); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/MouseMotionEventHandler.java0000644000000000000000000000662311105701167021364 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import org.jcsp.lang.*; import java.awt.event.*; /** * @author P.D. Austin and P.H. Welch */ class MouseMotionEventHandler implements MouseMotionListener { /** * The Channel action event notifications are sent down. */ private ChannelOutput event; /** * constructs a new MouseMotionEventHandler with the specified output Channel. * * @param event The Channel to send the event notification down */ public MouseMotionEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when the Component the event handler is listening to has a mouse * dragged. Notifies the event process that a MouseEvent has * occurred by sending the MouseEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void mouseDragged(MouseEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to has a mouse * moved. Notifies the event process that a MouseEvent has * occurred by sending the MouseEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void mouseMoved(MouseEvent e) { event.write(e); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/GraphicsProtocol.java0000644000000000000000000002077411105701167020073 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.awt.image.*; import org.jcsp.lang.TaggedProtocol; /** * This is the tagged protocol for use over the toGraphics * configuration channel of an active graphics component. *

Description

* GraphicsProtocol is the tagged protocol for use over the toGraphics * configuration channel of an active graphics component (for example, see * {@link ActiveCanvas#setGraphicsChannels ActiveCanvas.setGraphicsChannels}). *

* It is a collection of static immutable enquiry/configuration * objects and static configuration classes. An enquiry sent down the toGraphics * channel generates an appropriate reply on the fromGraphics channel. * A configuration class may be used to construct an immutable configuration object * that may be sent down the toGraphics channel to configure some property of the graphics * component. A configuration message is always acknowledged with a Boolean.TRUE * returned on the fromGraphics channel (once the configuration has happened). * * @see org.jcsp.awt.ActiveCanvas * @see org.jcsp.lang.TaggedProtocol * * @author P.H. Welch */ public abstract class GraphicsProtocol extends TaggedProtocol { GraphicsProtocol(final int tag) { super(tag); } static final int GET_DIMENSION_TAG = 0; static final int GET_COMPONENT_TAG = 1; static final int GET_BACKGROUND_TAG = 2; static final int SET_BACKGROUND_TAG = 3; static final int REQUEST_FOCUS_TAG = 4; static final int MAKE_MIS_IMAGE_TAG = 5; static final int SET_PAINTABLE_TAG = 6; static final int GENERAL_TAG = 7; static private final class GetDimension extends GraphicsProtocol { public GetDimension() { super(GET_DIMENSION_TAG); } } /** * This is an enquiry object to find the size of the active graphics component. * The java.awt.Dimension * will be returned down the fromGraphics channel. */ static public final GraphicsProtocol GET_DIMENSION = new GetDimension(); static private final class GetComponent extends GraphicsProtocol { public GetComponent() { super(GET_COMPONENT_TAG); } } /** * This is an enquiry object to obtain the active graphics component. * The java.awt.Component * will be returned down the fromGraphics channel. */ static public final GraphicsProtocol GET_COMPONENT = new GetComponent(); static private final class GetBackground extends GraphicsProtocol { public GetBackground() { super(GET_BACKGROUND_TAG); } } /** * This is an enquiry object to find the background colour of the active graphics component. * The background java.awt.Color * will be returned down the fromGraphics channel. */ static public final GraphicsProtocol GET_BACKGROUND = new GetBackground(); /** * This is a configuration class for setting the background java.awt.Color * of the active graphics component. A Boolean.TRUE will be returned down * the fromGraphics channel. */ static public final class SetBackground extends GraphicsProtocol { final Color color; /** * * @param color the new background colour for the graphics component. */ public SetBackground(final Color color) { super(SET_BACKGROUND_TAG); this.color = color; } } static private final class RequestFocus extends GraphicsProtocol { public RequestFocus() { super(REQUEST_FOCUS_TAG); } } /** * This is a configuration object to request input focus on the graphics component * for keyboard and mouse evnts. A Boolean.TRUE will be returned down * the fromGraphics channel. */ static public final GraphicsProtocol REQUEST_FOCUS = new RequestFocus(); /** * This is a configuration class to associate a java.awt.image.MemoryImageSource * with the graphics component. The component uses this to create a java.awt.Image, * which is returned down the fromGraphics channel. */ static public final class MakeMISImage extends GraphicsProtocol { final MemoryImageSource mis; /** * @param mis the MemoryImageSource for the graphics component. */ public MakeMISImage(final MemoryImageSource mis) { super(MAKE_MIS_IMAGE_TAG); this.mis = mis; } } /** * This is a configuration class to register a org.jcsp.awt.Paintable object * with the graphics component. A Boolean.TRUE will be returned down * the fromGraphics channel. */ static public final class SetPaintable extends GraphicsProtocol { final Paintable paintable; /** * @param paintable the Paintable object to which the graphics component * will delegate its paint/update methods. */ public SetPaintable(final Paintable paintable) { super(SET_PAINTABLE_TAG); this.paintable = paintable; } } /** * This is the interface for general configuration of the graphics component. * See the {@link GraphicsProtocol.General General} class. */ static public interface Configure { /** * @param c the Component being configured. */ public Object configure(final Component c); } /** * This is a general configuration class for the graphics component. * The user constructs an instance of this class, supplying an object * implementing the {@link GraphicsProtocol.Configure Configure} * interface, and writes it down the toGraphics channel. * The graphics component invokes the configure method * of the enclosed Configure object and * returns the Object result down the fromGraphics channel. */ static public final class General extends GraphicsProtocol { final Configure c; /** * @param c the object implementing the user's configuration requirements * for the graphics component. */ public General(final Configure c) { super(GENERAL_TAG); this.c = c; } } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActivePanel.java0000644000000000000000000003552011105701167016777 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Panel java.awt.Panel} * with a channel interface. *

Process Diagram

*

*

Description

* ActivePanel is a process extension of java.awt.Panel * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure channel is settable from a constructor. * Event channels can be added to notify the occurrence of any type of Event * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActivePanel myPanel = new ActivePanel ();
 *   myPanel.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureActivePanel.ConfigureInvoke the user-defined Configure.configure method on the panel.
Output Channels
containerEventContainerEventSee the {@link #addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.util.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActivePanelExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActivePanel Example");
 * 
 *     final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActivePanel panel = new ActivePanel ();
 *     panel.addMouseEventChannel (mouseEvent.out ());
 * 
 *     root.add (panel);
 *     root.setSize (400, 400);
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         panel,
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final MouseEvent event = (MouseEvent) mouseEvent.in ().read ();
 *               switch (event.getID ()) {
 *                 case MouseEvent.MOUSE_ENTERED:
 *                   System.out.println ("MOUSE_ENTERED");
 *                 break;
 *                 case MouseEvent.MOUSE_EXITED:
 *                   System.out.println ("MOUSE_EXITED");
 *                 break;
 *                 case MouseEvent.MOUSE_PRESSED:
 *                   System.out.println ("MOUSE_PRESSED");
 *                 break;
 *                 case MouseEvent.MOUSE_RELEASED:
 *                   System.out.println ("MOUSE_RELEASED");
 *                 break;
 *                 case MouseEvent.MOUSE_CLICKED:
 *                   if (event.getClickCount() > 1) {
 *                     System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!");
 *                     running = false;
 *                   } else {
 *                     System.out.println ("MOUSE_CLICKED ... *double* click to quit!");
 *                   }
 *                 break;
 *               }
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.Panel * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActivePanel extends Panel implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActivePanel with no configuration channel. */ public ActivePanel() { this(null); } /** * Constructs a new ActivePanel with a configuration channel. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public ActivePanel(ChannelInput configure) { this.configure = configure; } /** * Sets the configuration channel for this ActivePanel. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ContainerEvent has occurred. This should be used * instead of registering a ContainerListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param containerEvent the channel down which to send ContainerEvents. */ public void addContainerEventChannel(ChannelOutput containerEvent) { if (containerEvent != null) { ContainerEventHandler handler = new ContainerEventHandler(containerEvent); addContainerListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param panel the Panel being configured. */ public void configure(final Panel panel); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveTextField.java0000644000000000000000000004276711105701167017643 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.TextField java.awt.TextField} * with a channel interface. *

Process Diagram

*

*

*

Description

* ActiveTextField is a process extension of java.awt.TextField * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers updated text whenever * the ActiveTextField is changed. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myTextFieldEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveTextField myTextField =
 *     new ActiveTextField (null, myTextFieldEvent.out (), "Edit Me");
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringSet the text in this ActiveTextField to the value of the String
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the text field is made active
  2. *
  3. If this is the Boolean.FALSE object, * the text field is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveTextField.ConfigureInvoke the user-defined Configure.configure method on the textField.
otherwiseAppend the toString form of the object to the text in this ActiveTextField.
Output Channels
eventStringThe text in the ActiveTextField (whenever the text field is altered)
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * import java.awt.*;
 * 
 * public class ActiveTextFieldExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame frame =
 *       new ActiveClosingFrame ("ActiveTextFieldExample Example");
 * 
 *     final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final String[] string =
 *       {"Entia Non Sunt Multiplicanda Praeter Necessitatem",
 *        "Less is More ... More or Less",
 *        "Everything we do, we do it to you",
 *        "Race Hazards - What Rice Hozzers?",
 *        "Cogito Ergo Occam"};
 * 
 *     final String goodbye = "Goodbye World";
 * 
 *     final ActiveTextField[] activeText =
 *       new ActiveTextField[string.length];
 * 
 *     for (int i = 0; i < string.length; i++) {
 *       activeText[i] = new ActiveTextField (null, event.out (), string[i]);
 *     }
 * 
 *     Panel panel = new Panel (new GridLayout (string.length, 1));
 *     for (int i = 0; i < string.length; i++) {
 *       panel.add (activeText[i]);
 *     }
 * 
 *     final Frame realFrame = frame.getActiveFrame ();
 *     realFrame.setBackground (Color.green);
 *     realFrame.add (panel);
 *     realFrame.pack ();
 *     realFrame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         frame,
 *         new Parallel (activeText),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               String s = (String) event.in ().read ();
 *               System.out.println (s);
 *               running = (! s.equals (goodbye));
 *             }
 *             realFrame.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveTextEnterField * @see java.awt.TextField * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveTextField extends TextField implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveTextField with no initial text, * configuration or event channels. * */ public ActiveTextField() { this(null, null, "", 0); } /** * Constructs a new ActiveTextField with initial text and default width, * but no configuration or event channels. * * @param s the initial text displayed in the field. */ public ActiveTextField(String s) { this(null, null, s, s.length()); } /** * Constructs a new ActiveTextField with initial text and width, * but no configuration or event channels. * * @param s the initial text displayed in the field. * @param columns the width of the field. */ public ActiveTextField(String s, int columns) { this(null, null, s, columns); } /** * Constructs a new ActiveTextField with configuration and event channels, * but no initial text. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text field is changed * -- can be null if no notification is required. */ public ActiveTextField(ChannelInput configure, ChannelOutput event) { this(configure, event, "", 0); } /** * Constructs a new ActiveTextField with configuration and event channels, * initial text and default width. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text field is changed * -- can be null if no notification is required. * @param s the initial text displayed in the field. */ public ActiveTextField(ChannelInput configure, ChannelOutput event, String s) { this(configure, event, s, s.length()); } /** * Constructs a new ActiveTextField with configuration and event channels, * initial text and width. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text field is changed * -- can be null if no notification is required. * @param s the initial text displayed in the field. * @param columns the width of the field. */ public ActiveTextField(ChannelInput configure, ChannelOutput event, String s, int columns) { super(s, columns); // Only create an event handler if the event Channel is not null. if (event != null) { TextEventHandler handler = new TextEventHandler(event); addTextListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveTextField. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events. * If the channel passed is null, no action will be taken. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param textField the TextField being configured. */ public void configure(final TextField textField); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) setText((String) message); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); else setText(message.toString()); } } } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveCheckbox.java0000644000000000000000000004604311105701167017470 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Checkbox java.awt.Checkbox} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveCheckbox is a process extension of java.awt.Checkbox * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers the generated java.awt.ItemEvent whenever * the ActiveCheckbox is operated. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myCheckboxEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveCheckbox myCheckbox =
 *     new ActiveCheckbox (null, myCheckboxEvent);
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureString * Change the label for the ActiveCheckbox to the value of the String. *
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the checkbox is made active
  2. *
  3. If this is the Boolean.FALSE object, * the checkbox is made inactive
  4. *
  5. Other Boolean objects are used to set * the on/off state of the checkbox
  6. *
*
ActiveCheckbox.ConfigureInvoke the user-defined Configure.configure method on the checkbox.
Output Channels
eventItemEvent * When the ActiveCheckbox is operated, * the generated java.awt.ItemEvent is written down this channel. *
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveCheckboxExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveCheckbox Example");
 * 
 *     final String[] box = {"Hello World", "Rocket Science", "CSP",
 *                           "Monitors", "Ignore Me", "Goodbye World"};
 * 
 *     final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveCheckbox[] check = new ActiveCheckbox[box.length];
 *     for (int i = 0; i < box.length; i++) {
 *       check[i] = new ActiveCheckbox (null, event.out (), box[i]);
 *     }
 * 
 *     root.setSize (300, 200);
 *     root.setLayout (new GridLayout (box.length, 1));
 *     for (int i = 0; i < box.length; i++) {
 *      root.add (check[i]);
 *     }
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Parallel (check),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final ItemEvent e = (ItemEvent) event.in ().read ();
 *               final String item = (String) e.getItem ();
 *               if (e.getStateChange () == ItemEvent.SELECTED) {
 *                 System.out.println ("Checked ==> `" + item + "'");
 *                 running = (item != box[box.length - 1]);
 *               } else {
 *                 System.out.println ("Unchecked ==> `" + item + "'");
 *               }
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see java.awt.Checkbox * @see java.awt.CheckboxGroup * @see java.awt.event.ItemEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveCheckbox extends Checkbox implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The Configurer. */ // private Configurer configurer = null; /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs an ActiveCheckbox with no label, initial state false * and no configuration or event channels. */ public ActiveCheckbox() { this(""); } /** * Constructs an ActiveCheckbox with the label s, initial state false * and no configuration or event channels. * * @param s the label displayed on the ActiveCheckbox. */ public ActiveCheckbox(String s) { this(s, false); } /** * Constructs an ActiveCheckbox with the label s, * initial state and no configuration or event channels. * * @param s the label displayed on the ActiveCheckbox. * @param state the initial state of the ActiveCheckbox * (true => on, false => off). */ public ActiveCheckbox(String s, boolean state) { this(s, state, null); } /** * Constructs an ActiveCheckbox in the CheckboxGroup * group with the label s, * initial state and no configuration or event channels. * * @param s the label displayed on the ActiveCheckbox. * @param state the initial state of the ActiveCheckbox. * (true => on, false => off) * @param group the CheckboxGroup for the ActiveCheckbox. */ public ActiveCheckbox(String s, boolean state, CheckboxGroup group) { this(null, null, s, state, group); } /** * Constructs an ActiveCheckbox with no label, initial state false * and configuration and event channels. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the ItemEvent will be output when the choice * is exercised -- can be null if no notification is required. */ public ActiveCheckbox(ChannelInput configure, ChannelOutput event) { this(configure, event, ""); } /** * Constructs a ActiveCheckbox with the label s, * initial state false and configuration and event channels. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the ItemEvent will be output when the choice * is exercised -- can be null if no notification is required. * @param s the label displayed on the ActiveCheckbox. */ public ActiveCheckbox(ChannelInput configure, ChannelOutput event, String s) { this(configure, event, s, false); } /** * Constructs an ActiveCheckbox with the label s, * initial state and configuration and event channels. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the ItemEvent will be output when the choice * is exercised -- can be null if no notification is required. * @param s the label displayed on the ActiveCheckbox. * @param state the initial state of the ActiveCheckbox. * (true => on, false => off) */ public ActiveCheckbox(ChannelInput configure, ChannelOutput event, String s, boolean state) { this(configure, event, s, state, null); } /** * Constructs an ActiveCheckbox in the CheckboxGroup * group with the label s, initial state * and configuration and event channels. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the ItemEvent will be output when the choice * is exercised -- can be null if no notification is required. * @param s the label displayed on the ActiveCheckbox. * @param state the initial state of the ActiveCheckbox. * (true => on, false => off) * @param group the CheckboxGroup for the ActiveCheckbox. */ public ActiveCheckbox(ChannelInput configure, ChannelOutput event, String s, boolean state, CheckboxGroup group) { super(s, state, group); if (event !=null) { ItemEventHandler handler = new ItemEventHandler(event); addItemListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveCheckbox. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param checkbox the Checkbox being configured. */ public void configure(final Checkbox checkbox); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) setLabel((String) message); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); else setState(((Boolean) message).booleanValue()); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ItemEventHandler.java0000644000000000000000000000560311105701167020001 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.event.*; import org.jcsp.lang.*; /** * @author P.D. Austin and P.H. Welch */ class ItemEventHandler implements ItemListener { /** * The Channel down which ItemEvent notifications are sent. */ private ChannelOutput event; /** * constructs a new ItemEventHandler with the specified event Channel. * * @param event The Channel ItemEvent notifications are sent down. */ public ItemEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when an item change occurs on the component the event handler is * listening to. Notifies the event process that an ItemEvent has * occurred. Some notifications will be lost so there are no guarantees * that all events generated will be processed. * * @param e The parameters associated with this event */ public void itemStateChanged(ItemEvent e) { event.write(e); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveTextArea.java0000644000000000000000000004671511105701167017465 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.TextArea java.awt.TextArea} * with a channel interface. *

Process Diagram

*

*

*

Description

* ActiveTextArea is a process extension of java.awt.TextArea * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers updated text whenever * the ActiveTextArea is changed. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addxxxEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myTextAreaEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveTextArea myTextArea =
 *     new ActiveTextArea (null, myTextAreaEvent.out (), "Edit Me", 5, 20);
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringAppend the string to the text in this ActiveTextArea
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the text area is made active
  2. *
  3. If this is the Boolean.FALSE object, * the text area is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveTextArea.ConfigureInvoke the user-defined Configure.configure method on the textArea.
otherwise ...Append the toString form of the object to the text in this ActiveTextArea.
Output Channels
eventStringThe text in the ActiveTextArea (whenever the text area is altered)
componentEventComponentEventSee the {@link ActiveTextArea#addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link ActiveTextArea#addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link ActiveTextArea#addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link ActiveTextArea#addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link ActiveTextArea#addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * import java.awt.*;
 * 
 * public class ActiveTextAreaExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame frame =
 *       new ActiveClosingFrame ("ActiveTextAreaExample Example");
 * 
 *     final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final String[] string =
 *       {"Entia Non Sunt Multiplicanda Praeter Necessitatem",
 *        "Everything we do, we do it to you",
 *        "Race Hazards - What Rice Hozzers?",
 *        "Cogito Ergo Occam"};
 * 
 *     final String goodbye = "Goodbye World";
 * 
 *     final ActiveTextArea[] activeText =
 *       new ActiveTextArea[string.length];
 * 
 *     for (int i = 0; i < string.length; i++) {
 *       activeText[i] = new ActiveTextArea (null, event.out (), string[i], 5, 40);
 *     }
 * 
 *     Panel panel = new Panel (new GridLayout (string.length/2, 2));
 *     for (int i = 0; i < string.length; i++) {
 *       panel.add (activeText[i]);
 *     }
 * 
 *     final Frame realFrame = frame.getActiveFrame ();
 *     realFrame.setBackground (Color.green);
 *     realFrame.add (panel);
 *     realFrame.pack ();
 *     realFrame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         frame,
 *         new Parallel (activeText),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               String s = (String) event.in ().read ();
 *               System.out.println (s);
 *               running = (! s.equals (goodbye));
 *             }
 *             realFrame.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveTextEnterArea * @see java.awt.TextArea * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveTextArea extends TextArea implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveTextArea with scrollbars, but with no configuration * or event channels or initial text or size. */ public ActiveTextArea() { this(null, null, "", 0, 0, SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextArea with scrollbars and initial text, * but with no configuration or event channels or initial size. * * @param s the initial text displayed in the area. */ public ActiveTextArea(String s) { this(null, null, s, 0, 0, SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextArea with scrollbars and initial text and size, * but with no configuration or event channels. * * @param s the initial text displayed in the area. * @param rows the rows of the area. * @param columns the columns of the area. */ public ActiveTextArea(String s, int rows, int columns) { this(null, null, s, rows, columns, SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextArea with user-defined scrollbars and initial text and size, * but with no configuration or event channels. * * @param s the initial text displayed in the area. * @param rows the rows of the area. * @param columns the columns of the area. * @param scrollbars the columns of the area (java.awt.TextArea.SCROLLBARS_BOTH, * java.awt.TextArea.SCROLLBARS_VERTICAL_ONLY, * java.awt.TextArea.SCROLLBARS_HORIZONTAL_ONLY * or java.awt.TextArea.SCROLLBARS_NONE). */ public ActiveTextArea(String s, int rows, int columns, int scrollbars) { this(null, null, s, rows, columns, scrollbars); } /** * Constructs a new ActiveTextArea with configuration and event channels and scrollbars, * but with no initial text or size. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text area is changed * -- can be null if no notification is required. */ public ActiveTextArea(ChannelInput configure, ChannelOutput event) { this(configure, event, "", 0, 0, SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextArea with configuration and event channels * and scrollbars and initial text, but with no initial size. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text area is changed * -- can be null if no notification is required. * @param s the initial text displayed in the area. */ public ActiveTextArea(ChannelInput configure, ChannelOutput event, String s) { this(configure, event, s, 0, 0, SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextArea with configuration and event channels * and scrollbars and initial text and size. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text area is changed * -- can be null if no notification is required. * @param s the initial text displayed in the area. * @param rows the rows of the area. * @param columns the columns of the area. */ public ActiveTextArea(ChannelInput configure, ChannelOutput event, String s, int rows, int columns) { this(configure, event, s, rows, columns, SCROLLBARS_BOTH); } /** * Constructs a new ActiveTextArea with configuration and event channels * and user-defined scrollbars and initial text and size. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current text will be output when the text area is changed * -- can be null if no notification is required. * @param s the initial text displayed in the area. * @param rows the rows of the area. * @param columns the columns of the area. * @param scrollbars the columns of the area (java.awt.TextArea.SCROLLBARS_BOTH, * java.awt.TextArea.SCROLLBARS_VERTICAL_ONLY, * java.awt.TextArea.SCROLLBARS_HORIZONTAL_ONLY * or java.awt.TextArea.SCROLLBARS_NONE). */ public ActiveTextArea(ChannelInput configure, ChannelOutput event, String s, int rows, int columns, int scrollbars) { super(s, rows, columns, scrollbars); if (event != null) { TextEventHandler handler = new TextEventHandler(event); addTextListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveTextArea. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param textArea the TextArea being configured. */ public void configure(final TextArea textArea); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) append((String) message); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); else append(message.toString()); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveScrollbar.java0000644000000000000000000004621311105701167017664 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Scrollbar java.awt.Scrollbar} * with a channel interface. *

Process Diagram

*

*

*

Description

* ActiveScrollbar is a process extension of java.awt.Scrollbar * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers the adjusted value whenever * the ActiveScrollbar is moved. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannelInt myScrollbarEvent = Channel.one2oneInt (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveScrollbar myScrollbar =
 *     new ActiveScrollbar (null, myScrollbarEvent.out (), Scrollbar.HORIZONTAL, 0, 10, 0, 110);
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureIntegerSets the value of the scrollbar to the value received
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the scrollbar is made active
  2. *
  3. If this is the Boolean.FALSE object, * the scrollbar is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveScrollbar.ConfigureInvoke the user-defined Configure.configure method on the scrollbar.
Output Channels
eventint * The new value of the scrollbar *
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.ints.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveScrollbarExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame activeFrame = new ActiveClosingFrame ("ActiveScrollbar Example");
 * 
 *     final One2OneChannel configure = Channel.one2one ();
 *     final One2OneChannelInt scrollEvent = Channel.one2oneInt (new OverWriteOldestBufferInt (10));
 * 
 *     final ActiveScrollbar scrollBar =
 *       new ActiveScrollbar (
 *         null, scrollEvent.out (), Scrollbar.HORIZONTAL, 0, 10, 0, 110
 *       );
 * 
 *     final Frame realFrame = activeFrame.getActiveFrame ();
 *     realFrame.setSize (400, 75);
 *     realFrame.add (scrollBar);
 *     realFrame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         activeFrame,
 *         scrollBar,
 *         new CSProcess () {
 *           public void run () {
 *             final long FREE_TIME = 10000, BUSY_TIME = 250;
 *             CSTimer tim = new CSTimer ();
 *             Alternative alt = new Alternative (new Guard[] {tim, scrollEvent.in ()});
 *             final int TIM = 0, SCROLL = 1;
 *             long timeout = tim.read ();
 *             tim.setAlarm (timeout + FREE_TIME);
 *             boolean running = true;
 *             while (running) {
 *               switch (alt.priSelect ()) {
 *                 case TIM:                                     // timeout happened
 *                   configure.out ().write (Boolean.FALSE);     // disable scrollbar
 *                   for (int i = 40; i > 0; i--) {
 *                     System.out.println ("*** busy busy busy ... " + i);
 *                     timeout = tim.read ();
 *                     tim.after (timeout + BUSY_TIME);
 *                   }
 *                   System.out.println ("*** free free free ... 0");
 *                   configure.out ().write (Boolean.TRUE);      // enable scrollbar
 *                   timeout = tim.read ();
 *                   tim.setAlarm (timeout + FREE_TIME);
 *                 break;
 *                 case SCROLL:                                  // scrollEvent happened
 *                   int position = scrollEvent.in ().read ();
 *                   System.out.println ("ScrollBar ==> " + position);
 *                   running = (position != 100);
 *                 break;
 *               }
 *             }
 *             realFrame.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.Scrollbar * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveScrollbar extends Scrollbar implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a vertical ActiveScrollbar with no configuration * or event channels. */ public ActiveScrollbar() { this(Scrollbar.VERTICAL); } /** * Constructs a ActiveScrollbar with the specified orientation, but still with no * configuration or event channels. The minimum and maximum values default to 0 and 100, * with the initial setting at 0. * * @param orientation indicates the orientation of the scroll bar * (Scrollbar.VERTICAL, Scrollbar.HORIZONTAL). */ public ActiveScrollbar(int orientation) { this(orientation, 0, 10, 0, 110); } /** * Constructs a ActiveScrollbar with all its options, but still with no * configuration or event channels. * * @param orientation indicates the orientation of the scroll bar * (Scrollbar.VERTICAL, Scrollbar.HORIZONTAL). * @param value the initial value of the scroll bar. * @param visible the size of the scroll bar's bubble, representing the visible portion; the scroll bar uses this value when paging up or down by a page. * @param minimum the minimum value of the scroll bar. * @param maximum the maximum value of the scroll bar. */ public ActiveScrollbar(int orientation, int value, int visible, int minimum, int maximum) { this(null, null, orientation, value, visible, minimum, maximum); } /** * Constructs a vertical ActiveScrollbar with configuration and event channels. * The minimum and maximum values default to 0 and 100, with the initial setting at 0. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the adjusted value will be output when the scrollbar is moved * -- can be null if no notification is required. */ public ActiveScrollbar(ChannelInput configure, ChannelOutputInt event) { this(configure, event, Scrollbar.VERTICAL); } /** * Constructs a ActiveScrollbar with configuration and event channels and * the specified orientation. * The minimum and maximum values default to 0 and 100, with the initial setting at 0. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the adjusted value will be output when the scrollbar is moved * -- can be null if no notification is required. * @param orientation indicates the orientation of the scroll bar * (Scrollbar.VERTICAL, Scrollbar.HORIZONTAL). */ public ActiveScrollbar(ChannelInput configure, ChannelOutputInt event, int orientation) { this(configure, event, orientation, 0, 10, 0, 110); } /** * Constructs a ActiveScrollbar with configuration and event channels and * all its options. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the adjusted value will be output when the scrollbar is moved * -- can be null if no notification is required. * @param orientation indicates the orientation of the scroll bar * (Scrollbar.VERTICAL, Scrollbar.HORIZONTAL). * @param value the initial value of the scroll bar. * @param visible the size of the scroll bar's bubble, representing the visible portion; the scroll bar uses this value when paging up or down by a page. * @param minimum the minimum value of the scroll bar. * @param maximum the maximum value of the scroll bar. */ public ActiveScrollbar(ChannelInput configure, ChannelOutputInt event, int orientation, int value, int visible, int minimum, int maximum) { super(orientation, value, visible, minimum, maximum); if (event != null) { AdjustmentEventHandler handler = new AdjustmentEventHandler(event); addAdjustmentListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveScrollbar. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param scrollbar the Scrollbar being configured. */ public void configure(final Scrollbar scrollbar); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Integer) setValue(((Integer) message).intValue()); else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/FocusEventHandler.java0000644000000000000000000000657711105701167020175 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import org.jcsp.lang.*; import java.awt.event.*; /** * @author P.D. Austin and P.H. Welch */ class FocusEventHandler implements FocusListener { /** * The Channel action event notifications are sent down. */ private ChannelOutput event; /** * constructs a new FocusEventHandler with the specified output Channel. * * @param event The Channel to send the event notification down */ public FocusEventHandler(ChannelOutput event) { this.event = event; } /** * Invoked when the Component the event handler is listening to Gains the * input Focus. Notifies the event process that a FocusEvent has * occurred by sending the FocusEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void focusGained(FocusEvent e) { event.write(e); } /** * Invoked when the Component the event handler is listening to Gains the * input Focus. Notifies the event process that a FocusEvent has * occurred by sending the FocusEvent Object. Some notifications will be * lost so there are no guarantees that all events generated will be * processed. * * @param e The parameters associated with this event */ public void focusLost(FocusEvent e) { event.write(e); } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/GraphicsCommand.java0000644000000000000000000006170311105701167017645 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import org.jcsp.lang.TaggedProtocol; /** * This is the tagged protocol interpreted by objects * (such as {@link DisplayList}) that implement the {@link Display} interface. *

Description

* GraphicsCommand is the {@link org.jcsp.lang.TaggedProtocol} interpreted by * objects (such as {@link DisplayList}) that implement the {@link Display} interface. * It is a collection of static graphics command classes * and a couple of immutable graphics command objects. * The constructors for each command class set the parameters for the command. * The immutable objects are commands that take no parameters. *

* A Display object provides a secure interface between an active user * process and an active graphics component (such as {@link ActiveCanvas}). * It enables all methods of java.awt.graphics * to be executed on the active graphics component. * User processes send an array of GraphicsCommands * by invoking {@link Display#set set}, * {@link Display#extend extend} or {@link Display#change change} * on the Display. *

* The meaning of each command is defined by the corresponding method * in java.awt.graphics. For example, the {@link GraphicsCommand.DrawImage} * constructors correspond to the java.awt.graphics.drawImage methods. * * @see org.jcsp.awt.Display * @see org.jcsp.awt.DisplayList * @see org.jcsp.awt.ActiveCanvas * @see org.jcsp.lang.TaggedProtocol * * @author P.H. Welch */ public abstract class GraphicsCommand extends TaggedProtocol { GraphicsCommand(final int tag) { super(tag); } static final int NULL_TAG = 0; static final int TRANSLATE = 1; static final int SET_COLOR = 2; static final int SET_PAINT_MODE_TAG = 3; static final int SET_XOR_MODE = 4; static final int SET_FONT = 5; static final int CLIP_RECT = 6; static final int SET_CLIP = 7; static final int COPY_AREA = 8; static final int DRAW_LINE = 9; static final int FILL_RECT = 10; static final int DRAW_RECT = 11; static final int CLEAR_RECT = 12; static final int DRAW_ROUND_RECT = 13; static final int FILL_ROUND_RECT = 14; static final int DRAW_3D_RECT = 15; static final int FILL_3D_RECT = 16; static final int DRAW_OVAL = 17; static final int FILL_OVAL = 18; static final int DRAW_ARC = 19; static final int FILL_ARC = 20; static final int DRAW_POLYLINE = 21; static final int DRAW_POLYGON = 22; static final int FILL_POLYGON = 23; static final int DRAW_STRING = 24; static final int DRAW_CHARS = 25; static final int DRAW_BYTES = 26; static final int DRAW_IMAGE = 27; static final int GENERAL = 28; static private final class Null extends GraphicsCommand { public Null() { super(NULL_TAG); } } /** * This is the null command whose interpretation is a no-op. */ static public final GraphicsCommand NULL = new Null(); /** * This is the (immutable) command object for * {@link java.awt.Graphics#translate java.awt.Graphics.translate}. */ static public final class Translate extends GraphicsCommand { final int x; final int y; public Translate(final int x, final int y) { super(TRANSLATE); this.x = x; this.y = y; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#setColor java.awt.Graphics.setColor}. */ static public final class SetColor extends GraphicsCommand { final Color c; public SetColor(final Color c) { super(SET_COLOR); this.c = c; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#setPaintMode java.awt.Graphics.setPaintMode}. */ static private final class SetPaintMode extends GraphicsCommand { public SetPaintMode() { super(SET_PAINT_MODE_TAG); } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#setPaintMode java.awt.Graphics.setPaintMode}. */ static public final GraphicsCommand SET_PAINT_MODE = new SetPaintMode(); /** * This is the (immutable) command object for * {@link java.awt.Graphics#setXORMode java.awt.Graphics.setXORMode}. */ static public final class SetXORMode extends GraphicsCommand { final Color c; public SetXORMode(final Color c) { super(SET_XOR_MODE); this.c = c; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#setFont java.awt.Graphics.setFont}. */ static public final class SetFont extends GraphicsCommand { final Font f; public SetFont(final Font f) { super(SET_FONT); this.f = f; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#clipRect java.awt.Graphics.clipRect}. */ static public final class ClipRect extends GraphicsCommand { final int x; final int y; final int width; final int height; public ClipRect(final int x, final int y, final int width, final int height) { super(CLIP_RECT); this.x = x; this.y = y; this.width = width; this.height = height; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#setClip java.awt.Graphics.setClip}. */ static public final class SetClip extends GraphicsCommand { final int cliptag; final int x; final int y; final int width; final int height; final Shape s; public SetClip(final int x, final int y, final int width, final int height) { super(SET_CLIP); this.cliptag = 0; this.x = x; this.y = y; this.width = width; this.height = height; this.s = null; } public SetClip(final Shape s) { super(SET_CLIP); this.cliptag = 1; this.s = s; this.x = 0; this.y = 0; this.width = 0; this.height = 0; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#copyArea java.awt.Graphics.copyArea}. */ static public final class CopyArea extends GraphicsCommand { final int x; final int y; final int width; final int height; final int dx; final int dy; public CopyArea(final int x, final int y, final int width, final int height, final int dx, final int dy) { super(COPY_AREA); this.x = x; this.y = y; this.width = width; this.height = height; this.dx = dx; this.dy = dy; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawLine java.awt.Graphics.drawLine}. */ static public final class DrawLine extends GraphicsCommand { final int x1; final int y1; final int x2; final int y2; public DrawLine(final int x1, final int y1, final int x2, final int y2) { super(DRAW_LINE); this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#fillRect java.awt.Graphics.fillRect}. */ static public final class FillRect extends GraphicsCommand { final int x; final int y; final int width; final int height; public FillRect(final int x, final int y, final int width, final int height) { super(FILL_RECT); this.x = x; this.y = y; this.width = width; this.height = height; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawRect java.awt.Graphics.drawRect}. */ static public final class DrawRect extends GraphicsCommand { final int x; final int y; final int width; final int height; public DrawRect(final int x, final int y, final int width, final int height) { super(DRAW_RECT); this.x = x; this.y = y; this.width = width; this.height = height; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#clearRect java.awt.Graphics.clearRect}. */ static public final class ClearRect extends GraphicsCommand { final int x; final int y; final int width; final int height; public ClearRect(final int x, final int y, final int width, final int height) { super(CLEAR_RECT); this.x = x; this.y = y; this.width = width; this.height = height; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawRoundRect java.awt.Graphics.drawRoundRect}. */ static public final class DrawRoundRect extends GraphicsCommand { final int x; final int y; final int width; final int height; final int arcWidth; final int arcHeight; public DrawRoundRect(final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) { super(DRAW_ROUND_RECT); this.x = x; this.y = y; this.width = width; this.height = height; this.arcWidth = arcWidth; this.arcHeight = arcHeight; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#fillRoundRect java.awt.Graphics.fillRoundRect}. */ static public final class FillRoundRect extends GraphicsCommand { final int x; final int y; final int width; final int height; final int arcWidth; final int arcHeight; public FillRoundRect(final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) { super(FILL_ROUND_RECT); this.x = x; this.y = y; this.width = width; this.height = height; this.arcWidth = arcWidth; this.arcHeight = arcHeight; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#draw3DRect java.awt.Graphics.draw3DRect}. */ static public final class Draw3DRect extends GraphicsCommand { final int x; final int y; final int width; final int height; final boolean raised; public Draw3DRect(final int x, final int y, final int width, final int height, final boolean raised) { super(DRAW_3D_RECT); this.x = x; this.y = y; this.width = width; this.height = height; this.raised = raised; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#translate java.awt.Graphics.translate}. */ static public final class Fill3DRect extends GraphicsCommand { final int x; final int y; final int width; final int height; final boolean raised; public Fill3DRect(final int x, final int y, final int width, final int height, final boolean raised) { super(FILL_3D_RECT); this.x = x; this.y = y; this.width = width; this.height = height; this.raised = raised; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawOval java.awt.Graphics.drawOval}. */ static public final class DrawOval extends GraphicsCommand { final int x; final int y; final int width; final int height; public DrawOval(final int x, final int y, final int width, final int height) { super(DRAW_OVAL); this.x = x; this.y = y; this.width = width; this.height = height; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#fillOval java.awt.Graphics.fillOval}. */ static public final class FillOval extends GraphicsCommand { final int x; final int y; final int width; final int height; public FillOval(final int x, final int y, final int width, final int height) { super(FILL_OVAL); this.x = x; this.y = y; this.width = width; this.height = height; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawArc java.awt.Graphics.drawArc}. */ static public final class DrawArc extends GraphicsCommand { final int x; final int y; final int width; final int height; final int startAngle; final int arcAngle; public DrawArc(final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) { super(DRAW_ARC); this.x = x; this.y = y; this.width = width; this.height = height; this.startAngle = startAngle; this.arcAngle = arcAngle; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#fillArc java.awt.Graphics.fillArc}. */ static public final class FillArc extends GraphicsCommand { final int x; final int y; final int width; final int height; final int startAngle; final int arcAngle; public FillArc(final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) { super(FILL_ARC); this.x = x; this.y = y; this.width = width; this.height = height; this.startAngle = startAngle; this.arcAngle = arcAngle; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawPolyline java.awt.Graphics.drawPolyline}. */ static public final class DrawPolyline extends GraphicsCommand { final int[] xPoints; final int[] yPoints; final int nPoints; public DrawPolyline(final int[] xPoints, final int[] yPoints, final int nPoints) { super(DRAW_POLYLINE); this.xPoints = xPoints; this.yPoints = yPoints; this.nPoints = nPoints; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawPolygon java.awt.Graphics.drawPolygon}. */ static public final class DrawPolygon extends GraphicsCommand { final int polytag; final int[] xPoints; final int[] yPoints; final int nPoints; final Polygon p; public DrawPolygon(final int[] xPoints, final int[] yPoints, final int nPoints) { super(DRAW_POLYGON); this.polytag = 0; this.xPoints = xPoints; this.yPoints = yPoints; this.nPoints = nPoints; this.p = null; } public DrawPolygon(final Polygon p) { super(DRAW_POLYGON); this.polytag = 1; this.p = p; this.xPoints = null; this.yPoints = null; this.nPoints = 0; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#fillPolygon java.awt.Graphics.fillPolygon}. */ static public final class FillPolygon extends GraphicsCommand { final int polytag; final int[] xPoints; final int[] yPoints; final int nPoints; final Polygon p; public FillPolygon(final int[] xPoints, final int[] yPoints, final int nPoints) { super(FILL_POLYGON); this.polytag = 0; this.xPoints = xPoints; this.yPoints = yPoints; this.nPoints = nPoints; this.p = null; } public FillPolygon(final Polygon p) { super(FILL_POLYGON); this.polytag = 1; this.p = p; this.xPoints = null; this.yPoints = null; this.nPoints = 0; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawString java.awt.Graphics.drawString}. */ static public final class DrawString extends GraphicsCommand { final String string; final int x; final int y; public DrawString(final String string, final int x, final int y) { super(DRAW_STRING); this.string = string; this.x = x; this.y = y; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawChars java.awt.Graphics.drawChars}. */ static public final class DrawChars extends GraphicsCommand { final char[] data; final int offset; final int length; final int x; final int y; public DrawChars(final char[] data, final int offset, final int length, final int x, final int y) { super(DRAW_CHARS); this.data = data; this.offset = offset; this.length = length; this.x = x; this.y = y; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawBytes java.awt.Graphics.drawBytes}. */ static public final class DrawBytes extends GraphicsCommand { final byte[] data; final int offset; final int length; final int x; final int y; public DrawBytes(final byte[] data, final int offset, final int length, final int x, final int y) { super(DRAW_BYTES); this.data = data; this.offset = offset; this.length = length; this.x = x; this.y = y; } } /** * This is the (immutable) command object for * {@link java.awt.Graphics#drawImage java.awt.Graphics.drawImage}. */ static public final class DrawImage extends GraphicsCommand { final int drawtag; final Image image; final int x; final int y; final int width; final int height; final Color bgcolor; final int dx1, dy1, dx2, dy2; final int sx1, sy1, sx2, sy2; public DrawImage(final Image image, final int x, final int y) { super(DRAW_IMAGE); this.drawtag = 0; this.image = image; this.x = x; this.y = y; this.width = 0; this.height = 0; this.bgcolor = null; this.dx1 = 0; this.dy1 = 0; this.dx2 = 0; this.dy2 = 0; this.sx1 = 0; this.sy1 = 0; this.sx2 = 0; this.sy2 = 0; } public DrawImage(final Image image, final int x, final int y, final int width, final int height) { super(DRAW_IMAGE); this.drawtag = 1; this.image = image; this.x = x; this.y = y; this.width = width; this.height = height; this.bgcolor = null; this.dx1 = 0; this.dy1 = 0; this.dx2 = 0; this.dy2 = 0; this.sx1 = 0; this.sy1 = 0; this.sx2 = 0; this.sy2 = 0; } public DrawImage(final Image image, final int x, final int y, final Color bgcolor) { super(DRAW_IMAGE); this.drawtag = 2; this.image = image; this.x = x; this.y = y; this.bgcolor = bgcolor; this.width = 0; this.height = 0; this.dx1 = 0; this.dy1 = 0; this.dx2 = 0; this.dy2 = 0; this.sx1 = 0; this.sy1 = 0; this.sx2 = 0; this.sy2 = 0; } public DrawImage(final Image image, final int x, final int y, final int width, final int height, final Color bgcolor) { super(DRAW_IMAGE); this.drawtag = 3; this.image = image; this.x = x; this.y = y; this.width = width; this.height = height; this.bgcolor = bgcolor; this.dx1 = 0; this.dy1 = 0; this.dx2 = 0; this.dy2 = 0; this.sx1 = 0; this.sy1 = 0; this.sx2 = 0; this.sy2 = 0; } public DrawImage(final Image image, final int dx1, final int dy1, final int dx2, final int dy2, final int sx1, final int sy1, final int sx2, final int sy2) { super(DRAW_IMAGE); this.drawtag = 4; this.image = image; this.dx1 = dx1; this.dy1 = dy1; this.dx2 = dx2; this.dy2 = dy2; this.sx1 = sx1; this.sy1 = sy1; this.sx2 = sx2; this.sy2 = sy2; this.x = 0; this.y = 0; this.width = 0; this.height = 0; this.bgcolor = null; } public DrawImage(final Image image, final int dx1, final int dy1, final int dx2, final int dy2, final int sx1, final int sy1, final int sx2, final int sy2, final Color bgcolor) { super(DRAW_IMAGE); this.drawtag = 5; this.image = image; this.dx1 = dx1; this.dy1 = dy1; this.dx2 = dx2; this.dy2 = dy2; this.sx1 = sx1; this.sy1 = sy1; this.sx2 = sx2; this.sy2 = sy2; this.bgcolor = bgcolor; this.x = 0; this.y = 0; this.width = 0; this.height = 0; } } /** * This is the interface allowing any set of {@link java.awt.Graphics} * operations to be wrapped up in an object and sent down a {@link Display} * channel to an Active graphics component. See {@link GraphicsCommand.General} */ static public interface Graphic { public void doGraphic(final Graphics g, final Component c); } /** * This is the command object holding a {@link GraphicsCommand.Graphic} object * implementing an arbitrary set of graphics operations. */ static public final class General extends GraphicsCommand { final Graphic g; public General(final Graphic g) { super(GENERAL); this.g = g; } } }jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveButtonControl.java0000644000000000000000000005634511105701167020564 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import org.jcsp.lang.*; /** * This is a user-programmable finite state machine for * controlling an array of {@link ActiveButton}s. *

Process Diagram

*

*

Description

* ActiveButtonControl is a user-programmable finite state machine for * controlling an array of {@link ActiveButton}s. It is connected to the array * by its event and configure channels, matching pairs of which * must be attached to individual buttons. A button push generates a message down * the attached event channel, which triggers a state transition in the * ActiveButtonControl and a report that is sent down its report * channel. The report consists of the new state just reached (an Integer) * and, optionally, the channel index identifying which button was pushed (also an * Integer) and the message generated by the button (the String * that was labelling it). Also, the labels on all the buttons may be reset on * entry to a new state, together with their enable/disable status (via messages * sent back by ActiveButtonControl on its configure channels). *

* All external channels must be supplied as parameters to a constructor. * The constructor must also be passed an array of String arrays * (one String array defining the labels allowed for each attached button), * the state table and a starting state. *

* The state table is an array of {@link ActiveButtonState}s. Each * ActiveButtonState has three arrays, all of size equal to the number * of buttons being controlled. The first array holds the indices defining the * label to be displayed on each button when in that state. The second array * holds the booleans defining the enable/disable status for each button for * that state. The third array holds the states to change into if the corresponding * button is pushed when in that state. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
event[i]StringThe label on the attached {@link ActiveButton} (when it is pressed and released).
Output Channels
configure[i]StringDefines the label on the attached {@link ActiveButton}.
BooleanDefines the enable/disable status on the attached {@link ActiveButton}.
reportInteger * The new state (after a state transition). Note: depending on the state * transition table, this may be the same as the previous state.. *
Integer * The channel index identifying which button caused the state transition. * Note: this will be output after the above state information only if * requested - see {@link #setReportButtonIndex setReportButtonIndex}. *
String * The label on the button that caused the state transition. * Note: this will be output after the above information only if * requested - see {@link #setReportButtonLabel setReportButtonLabel}. *
*
*

Example

*
 * import java.awt.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveButtonControlExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveButtonControl Example");
 * 
 *     final String[][] labels = {
 *       new String[] {"Hello World", "JCSP", "Restart"},
 *       new String[] {"Rocket Science", "JCSP", "occam"},
 *       new String[] {"Deadlock", "JCSP", "occam"},
 *       new String[] {"Race Hazard", "JCSP", "occam"},
 *       new String[] {"Starvation", "JCSP", "Quit", "Back"},
 *       new String[] {"Threads", "JCSP", "occam"},
 *       new String[] {"Livelock", "JCSP", "occam"},
 *       new String[] {"Monitors", "JCSP", "occam"},
 *       new String[] {"Alchemy", "JCSP", "Smile"}
 *     };
 * 
 *     final int nButtons = labels.length;
 * 
 *     final One2OneChannel[] fromButton = Channel.one2oneArray (nButtons, new OverWriteOldestBuffer (1));
 *     final Any2OneChannel[] toButton = Channel.any2oneArray (nButtons);
 * 
 *     final One2OneChannel report = Channel.one2one ();
 * 
 *     final ActiveButton[] button = new ActiveButton[nButtons];
 *     for (int i = 0; i < nButtons; i++) {
 *       button[i] = new ActiveButton (toButton[i].in (), fromButton[i].out (), "XXXXXXXXX");
 *       button[i].setBackground (Color.green);
 *     }
 * 
 *     root.setSize (450, 200);
 *     root.setLayout (new GridLayout (nButtons/3, 3));
 *     for (int i = 0; i < nButtons; i++) {
 *       root.add (button[i]);
 *     }
 *     root.setVisible (true);
 * 
 *     final int initial   = 0;                    // state names
 *     final int diagonal  = 1;
 *     final int opposite  = 2;
 *     final int centre    = 3;
 *     final int full      = 4;
 *     final int terminal  = 5;
 * 
 *     final String[] stateName = {
 *       "initial", "diagonal", "opposite", "centre", "full", "terminal"
 *     };
 * 
 *     final ActiveButtonState[] state = new ActiveButtonState[stateName.length];
 * 
 *     try {
 * 
 *       state[initial] =
 *         new ActiveButtonState (
 *           new int[] {
 *             0, 0, 1,
 *             0, 1, 1,                              // label index
 *             1, 1, 1
 *           },
 *           new boolean[] {
 *             true,  true,  false,
 *             true,  false, false,                  // enable/disable
 *             false, false, false
 *           },
 *           new int[] {
 *             diagonal, initial,  initial,
 *             initial,  initial,  initial,          // next state
 *             initial,  initial,  initial
 *           }
 *         );
 * 
* [In this example, nine buttons are laid out in a 3x3 grid in the root frame. * The layout of the above state definition reflects this grid. Note that this code * is enclosed within a try-catch block since the ActiveButtonState * {@link ActiveButtonState#ActiveButtonState(int[],boolean[],int[]) constructor} * performs numerous consistency checks on its parameters and may throw an exception. *

* The label index array specifies that, in this initial state, the north-west * button and its east and south neighbours display their 0-index labels (i.e. * "Hello World", "Rocket Science" and "Race Hazard" respectively). All the other * buttons display their 1-index labels (which all happen to be "JCSP"). *

* The enable/disable array specifies that, in this initial state, all those * buttons displaying "JCSP" are disabled and all the others are enabled. *

* The next state array specifies that, in this initial state, if the top-left * button is pushed, then the state should change to diagonal. However, if any * other button is pushed, the state remains as initial. Note that it doesn't * actually matter what is defined for those buttons that are disabled in this * state. *

* The diagonal, opposite, centre and full states are defined similarly. We pick * up the program for the definition of its terminal state (where all the labels * are "JCSP" and all the buttons are disabled).] *

 *       state[terminal] =
 *         new ActiveButtonState (
 *           new int[] {
 *             1, 1, 1,
 *             1, 1, 1,                              // label index
 *             1, 1, 1
 *           },
 *           new boolean[] {
 *             false, false, false,
 *             false, false, false,                  // enable/disable
 *             false, false, false
 *           },
 *           new int[] {
 *             terminal, terminal, terminal,
 *             terminal, terminal, terminal,         // next state
 *             terminal, terminal, terminal
 *           }
 *         );
 * 
 *     } catch (ActiveButtonState.BadArguments e) {
 * 
 *      System.out.println (e);
 *      System.exit (0);
 * 
 *     };
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Parallel (button),
 *         new CSProcess () {
 *           public void run () {
 *             final ActiveButtonControl control;
 *             try {
 *               control = new ActiveButtonControl (
 *                 fromButton.in (), toButton.out (), report.out (), labels, state, initial
 *               );
 *               control.setReportButtonIndex (true);
 *               control.setReportButtonLabel (true);
 *               control.run ();
 *             } catch (ActiveButtonControl.BadArguments e) {
 *               System.out.println (e);
 *               System.exit (0);
 *             }
 *           }
 *         },
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final int newState = ((Integer) report.in ().read ()).intValue ();
 *               final int buttonIndex = ((Integer) report.in ().read ()).intValue ();
 *               final String buttonString = (String) report.in ().read ();
 *               System.out.println (
 *                 "Button " + buttonIndex +
 *                 " (" + buttonString + ") pressed ==> " + stateName[newState]
 *               );
 *               running = (newState != terminal);
 *             }
 *             final CSTimer tim = new CSTimer ();        // countdown to exit
 *             final long interval = 1000;            // one second
 *             long timeout = tim.read ();
 *             for (int i = 10; i >= 0; i--) {
 *               timeout += interval;
 *               tim.after (timeout);
 *               final String iString = (new Integer (i)).toString ();
 *               for (int j = 0; j < nButtons; j++) {
 *                 toButton[j].write (iString);
 *               }
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* The countdown to exit sequence is just for fun. In its terminal state, * this ActiveButtonControl disables all its buttons and will never * change state again. This leaves the buttons free to be configured by * some other process, such as the last one above once it has detected that * the controller is dead. This is why the toButton configure * channels were created as Any2OneChannelImpl, rather than the more * usual One2OneChannelImpl. *

* @see org.jcsp.awt.ActiveButton * @see org.jcsp.awt.ActiveButtonState * * @author P.H. Welch */ public class ActiveButtonControl implements CSProcess { private AltingChannelInput[] event; // from buttons ... private ChannelOutput[] configure; // to buttons ... private ChannelOutput report; // to whoever is out there ... private String[][] label; // button labels (each may have several) private ActiveButtonState[] state; private int startState; private Integer[] stateId; private Integer[] buttonId; private boolean verbose; private boolean reportButtonIndex = false; private boolean reportButtonString = false; /** * Constructs a new ActiveButtonControl, performing consistency * checks on its supplied arguments. * * @param event equal-indexed elements of event and configure * must be connected to the same {@link ActiveButton}. * @param configure equal-indexed elements of event and configure * must be connected to the same {@link ActiveButton}. * @param report the channel on which state transitions are reported. A report has * up to three messages: the new state, the index of the button triggering * the transition ({@link #setReportButtonIndex optional}) and its label * ({@link #setReportButtonLabel optional}). * @param label an array of string arrays (one for each controlled botton). Each * string array defines the label set allowed for each button. * @param state the state transition table. * @param startState the starting state for this finite state machine. * @throws ActiveButtonControl.BadArguments if the consistency check fails. * The exception contains details of the error. */ public ActiveButtonControl(AltingChannelInput[] event, ChannelOutput[] configure, ChannelOutput report, String[][] label, ActiveButtonState[] state, int startState) throws ActiveButtonControl.BadArguments { this(event, configure, report, label, state, startState, false); } /** * Constructs a new ActiveButtonControl, performing consistency * checks on its supplied arguments, with a verbose reporting option. * * @param event equal-indexed elements of event and configure * must be connected to the same {@link ActiveButton}. * @param configure equal-indexed elements of event and configure * must be connected to the same {@link ActiveButton}. * @param report the channel on which state transitions are reported. A report has * up to three messages: the new state, the index of the button triggering * the transition ({@link #setReportButtonIndex optional}) and its label * ({@link #setReportButtonLabel optional}). * @param label an array of string arrays (one for each controlled botton). Each * string array defines the label set allowed for each button. * @param state the state transition table. * @param startState the starting state for this finite state machine. * @param verbose if true, a running commentary is printed on the consistency checks * and state transitions as they occur. * @throws ActiveButtonControl.BadArguments if the consistency check fails. * The exception contains details of the error. */ public ActiveButtonControl(AltingChannelInput[] event, ChannelOutput[] configure, ChannelOutput report, String[][] label, ActiveButtonState[] state, int startState, boolean verbose) throws ActiveButtonControl.BadArguments { if (verbose) System.out.println("ActiveButtonControl creating ..."); // sanity checks if (event == null) throw new ActiveButtonControl.BadArguments("event == null"); if (configure == null) throw new ActiveButtonControl.BadArguments("configure == null"); if (label == null) throw new ActiveButtonControl.BadArguments("label == null"); if (state == null) throw new ActiveButtonControl.BadArguments("state == null"); if (verbose) System.out.println("ActiveButtonControl: arguments not null"); if (event.length != configure.length) throw new ActiveButtonControl.BadArguments("event.length != configure.length"); if (verbose) System.out.println("event.length == configure.length"); if (event.length != label.length) throw new ActiveButtonControl.BadArguments("event.length != label.length"); if (verbose) System.out.println("event.length == label.length"); for (int i = 0; i < label.length; i++) { if (event[i] == null) throw new ActiveButtonControl.BadArguments("event " + i + " channel is null"); if (verbose) System.out.println("event " + i + " channel is not null"); if (configure[i] == null) throw new ActiveButtonControl.BadArguments("configure " + i + " channel is null"); if (verbose) System.out.println("configure " + i + " channel is not null"); if (label[i] == null) throw new ActiveButtonControl.BadArguments("button " + i + " has no labels"); if (verbose) System.out.println("button " + i + " labels are not null"); for (int j = 0; j < label[i].length; j++) { if (label[i][j] == null) throw new ActiveButtonControl.BadArguments("label " + j + ", button " + i + ", is null"); if (verbose) System.out.println("label " + j + ", button " + i + ", is not null"); } } if (report == null) throw new ActiveButtonControl.BadArguments("no report channel"); if (verbose) System.out.println("ActiveButtonControl simple checks completed ..."); for (int i = 0; i < state.length; i++) { if (state[i] == null) throw new ActiveButtonControl.BadArguments("state " + i + " is null"); state[i].check(i, event.length, state.length, label); } if (verbose) System.out.println("ActiveButtonControl all checks completed ..."); // sanity checks complete this.event = event; this.configure = configure; this.report = report; this.label = label; this.state = state; this.startState = startState; this.verbose = verbose; stateId = new Integer[state.length]; for (int i = 0; i < stateId.length; i++) stateId[i] = new Integer(i); buttonId = new Integer[event.length]; for (int i = 0; i < buttonId.length; i++) buttonId[i] = new Integer(i); if (verbose) System.out.println("ActiveButtonControl created OK"); } /** * Defines whether the index of the pushed button causing a state transition should * be included in the report. The default is that it should not be reported. * * @param condition if true, the button index is reported - otherwise it is not reported. */ public void setReportButtonIndex(final boolean condition) { reportButtonIndex = condition; } /** * Defines whether the label on the pushed button causing a state transition should * be included in the report. The default is that it should not be reported. * * @param condition if true, the button label is reported - otherwise it is not reported. */ public void setReportButtonLabel(final boolean condition) { reportButtonString = condition; } private boolean[] setState(int currentState) { ActiveButtonState cState = state[currentState]; for (int i = 0; i < configure.length; i++) { if (cState.enable[i]) configure[i].write(Boolean.TRUE); else configure[i].write(Boolean.FALSE); } for (int i = 0; i < configure.length; i++) configure[i].write(label[i][cState.labelId[i]]); return cState.enable; } private boolean[] setState(int currentState, int lastState) { ActiveButtonState cState = state[currentState]; ActiveButtonState lState = state[lastState]; for (int i = 0; i < configure.length; i++) { if (cState.enable[i] != lState.enable[i]) { if (cState.enable[i]) configure[i].write(Boolean.TRUE); else configure[i].write(Boolean.FALSE); } } for (int i = 0; i < configure.length; i++) if (cState.labelId[i] != lState.labelId[i]) configure[i].write(label[i][cState.labelId[i]]); return cState.enable; } /** * Main body of the process. */ public void run() { if (verbose) System.out.println("ActiveButtonControl starting ..."); Alternative alt = new Alternative(event); int currentState = startState; int lastState; int button; boolean[] enable = setState(currentState); String string; while (true) { button = alt.fairSelect(enable); string = (String)event[button].read(); if (verbose) System.out.println(string + " " + button); lastState = currentState; currentState = state[currentState].next[button]; enable = setState(currentState, lastState); report.write(stateId[currentState]); if (reportButtonIndex) report.write(buttonId[button]); if (reportButtonString) report.write(string); } } /** * This gets thrown if a consistency check fails in the {@link ActiveButtonControl} * constructor. */ public static class BadArguments extends Exception { /** * * @param s details of the consistency failure. */ public BadArguments(String s) { super(s); } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveCheckboxMenuItem.java0000644000000000000000000003642311105701167021135 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.CheckboxMenuItem java.awt.CheckboxMenuItem} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveCheckboxMenuItem is a process extension of java.awt.CheckboxMenuItem * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers the generated java.awt.ItemEvent whenever * the ActiveCheckboxMenuItem is selected. * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myCheckboxMenuItemEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveCheckboxMenuItem myCheckboxMenuItem =
 *     new ActiveCheckboxMenuItem (null, myCheckboxMenuItemEvent.out (), "Choose Me");
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureStringChange the label on the ActiveCheckboxMenuItem to the value of the String
java.awt.MenuShortcutSets the MenuShortcut for the ActiveCheckboxMenuItem *
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the checkboxMenuItem is made active
  2. *
  3. If this is the Boolean.FALSE object, * the checkboxMenuItem is made inactive
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveCheckboxMenuItem.ConfigureInvoke the user-defined Configure.configure method on the checkboxMenuItem.
Output Channels
eventjava.awt.ItemEventThe generated java.awt.ItemEvent is written down this channel * (when the checkboxMenuItem is selected or deslected) *
actionEventActionEventSee the {@link #addActionEventChannel * addActionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveCheckboxMenuItemExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final ActiveClosingFrame activeClosingFrame =
 *       new ActiveClosingFrame ("ActiveCheckboxMenuItem Example");
 * 
 *     final ActiveFrame frame = activeClosingFrame.getActiveFrame ();
 * 
 *     final MenuBar menuBar = new MenuBar ();
 *     frame.setMenuBar (menuBar);
 * 
 *     final Menu fileMenu = new Menu ("File");
 *     final Menu langMenu = new Menu ("Language");
 *     menuBar.add (fileMenu);
 *     menuBar.add (langMenu);
 * 
 *     final String[] fileOptions = {"Hello World", "Rocket Science", "CSP",
 *                                   "Monitors", "Ignore Me", "Goodbye World"};
 *     final String[] langOptions = {"occam-pi", "Java", "Smalltalk", "Algol-60",
 *                                   "Pascal", "Haskell", "SML", "Lisp"};
 * 
 *     final Any2OneChannel event[] = Channel.any2oneArray (2, new OverWriteOldestBuffer (10));
 * 
 *     final ActiveMenuItem[] fileMenuItem =
 *       new ActiveMenuItem[fileOptions.length];
 *     for (int i = 0; i < fileOptions.length; i++) {
 *       fileMenuItem[i] = new ActiveMenuItem (null, event[0].out (), fileOptions[i]);
 *       fileMenu.add (fileMenuItem[i]);
 *     }
 * 
 *     final ActiveCheckboxMenuItem[] langCheckboxMenuItem =
 *       new ActiveCheckboxMenuItem[langOptions.length];
 *     for (int i = 0; i < langOptions.length; i++) {
 *       langCheckboxMenuItem[i] =
 *         new ActiveCheckboxMenuItem (null, event[1].out (), langOptions[i]);
 *       langMenu.add (langCheckboxMenuItem[i]);
 *     }
 * 
 *     frame.setSize (300, 200);
 *     frame.setBackground (Color.green);
 *     frame.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         activeClosingFrame,
 *         new Parallel (fileMenuItem),
 *         new Parallel (langCheckboxMenuItem),
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) event[0].in ().read ();
 *               System.out.println ("File ==> `" + s + "' selected ...");
 *               running = (s != fileOptions[fileOptions.length - 1]);
 *             }
 *             frame.setVisible (false);
 *             System.exit (0);
 *           }
 *         },
 *         new CSProcess () {
 *           public void run () {
 *             while (true) {
 *               final ItemEvent e = (ItemEvent) event[1].in ().read ();
 *               final String item = (String) e.getItem ();
 *               System.out.print ("Language ==> `" + item);
 *               if (e.getStateChange () == ItemEvent.SELECTED) {
 *                 System.out.println ("' selected ...");
 *               } else {
 *                 System.out.println ("' deselected ...");
 *               }
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see java.awt.CheckboxMenuItem * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveCheckboxMenuItem extends CheckboxMenuItem implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The Configurer. */ // private Configurer configurer = null; /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new unchecked ActiveCheckboxMenuItem with no initial label * and no configuration or event channels. * */ public ActiveCheckboxMenuItem() { this(null, null, "", false); } /** * Constructs a new unchecked ActiveCheckboxMenuItem * with no configuration or event channels. * * @param s the initial label displayed on the checkboxMenuItem. */ public ActiveCheckboxMenuItem(String s) { this(null, null, s, false); } /** * Constructs a new ActiveCheckboxMenuItem * with no configuration or event channels. * * @param s the initial label displayed on the checkboxMenuItem. * @param state the initial state of the checkboxMenuItem. */ public ActiveCheckboxMenuItem(String s, boolean state) { this(null, null, s, state); } /** * Constructs a new unchecked ActiveCheckboxMenuItem with no initial label. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current label will be output when the checkboxMenuItem is selected * -- can be null if no notification is required. */ public ActiveCheckboxMenuItem(ChannelInput configure, ChannelOutput event) { this(configure, event, "", false); } /** * Constructs a new unchecked ActiveCheckboxMenuItem. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current label will be output when the checkboxMenuItem is selected * -- can be null if no notification is required. * @param s the initial label displayed on the checkboxMenuItem. */ public ActiveCheckboxMenuItem(ChannelInput configure, ChannelOutput event, String s) { this(configure, event, s, false); } /** * Constructs a new ActiveCheckboxMenuItem. * * @param configure the channel for configuration events * -- can be null if no configuration is required. * @param event the current label will be output when the checkboxMenuItem is selected * -- can be null if no notification is required. * @param s the initial label displayed on the checkboxMenuItem. * @param state the initial state of the checkboxMenuItem. */ public ActiveCheckboxMenuItem(ChannelInput configure, ChannelOutput event, String s, boolean state) { super(s, state); if (event != null) { ItemEventHandler handler = new ItemEventHandler(event); addItemListener(handler); vec.addElement(handler); } this.configure = configure; } /** * Sets the configuration channel for this ActiveCheckboxMenuItem. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * an ActionEvent has occurred. This should be used * instead of registering a ActionListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param actionEvent the channel down which to send ActionEvents. */ public void addActionEventChannel(ChannelOutput actionEvent) { if (actionEvent != null) { ActionEventHandler handler = new ActionEventHandler(actionEvent); addActionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param checkboxMenuItem the CheckboxMenuItem being configured. */ public void configure(final CheckboxMenuItem checkboxMenuItem); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof String) setLabel((String) message); else if (message instanceof MenuShortcut) setShortcut((MenuShortcut) message); else if (message instanceof Character) { switch (((Character) message).charValue()) { case 'S': setState(true); break; case 's': setState(false); break; } } else if (message instanceof Boolean) { if (message == Boolean.TRUE) setEnabled(true); else if (message == Boolean.FALSE) setEnabled(false); } else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveContainer.java0000644000000000000000000003571011105701167017663 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.Container java.awt.Container} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveContainer is a process extension of java.awt.Container * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure channel is settable from a constructor. * Event channels can be added to notify the occurrence of any type of Event * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component -- no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myMouseEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveContainer myContainer = new ActiveContainer ();
 *   myContainer.addMouseEventChannel (myMouseEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureActiveContainer.ConfigureInvoke the user-defined Configure.configure method on the container.
Output Channels
containerEventContainerEventSee the {@link #addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import java.awt.event.*;
 * import org.jcsp.util.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveContainerExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ("ActiveContainer Example");
 * 
 *     final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveContainer container = new ActiveContainer ();
 *     container.addMouseEventChannel (mouseEvent.out ());
 * 
 *     root.add (container);
 *     root.setSize (400, 400);
 *     root.setVisible (true);
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         container,
 *         new CSProcess () {
 *           public void run () {
 *             boolean running = true;
 *             while (running) {
 *               final MouseEvent event = (MouseEvent) mouseEvent.in ().read ();
 *               switch (event.getID ()) {
 *                 case MouseEvent.MOUSE_ENTERED:
 *                   System.out.println ("MOUSE_ENTERED");
 *                 break;
 *                 case MouseEvent.MOUSE_EXITED:
 *                   System.out.println ("MOUSE_EXITED");
 *                 break;
 *                 case MouseEvent.MOUSE_PRESSED:
 *                   System.out.println ("MOUSE_PRESSED");
 *                 break;
 *                 case MouseEvent.MOUSE_RELEASED:
 *                   System.out.println ("MOUSE_RELEASED");
 *                 break;
 *                 case MouseEvent.MOUSE_CLICKED:
 *                   if (event.getClickCount() > 1) {
 *                     System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!");
 *                     running = false;
 *                   } else {
 *                     System.out.println ("MOUSE_CLICKED ... *double* click to quit!");
 *                   }
 *                 break;
 *               }
 *             }
 *             root.setVisible (false);
 *             System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.Container * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveContainer extends Container implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * Constructs a new ActiveContainer with no configuration channel. */ public ActiveContainer() { this(null); } /** * Constructs a new ActiveContainer with a configuration channel. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public ActiveContainer(ChannelInput configure) { this.configure = configure; } /** * Sets the configuration channel for this ActiveContainer. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * -- can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a ContainerEvent has occurred. This should be used * instead of registering a ContainerListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param containerEvent the channel down which to send ContainerEvents. */ public void addContainerEventChannel(ChannelOutput containerEvent) { if (containerEvent != null) { ContainerEventHandler handler = new ContainerEventHandler(containerEvent); addContainerListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param container the Container being configured. */ public void configure(final Container container); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/awt/ActiveFileDialog.java0000644000000000000000000005133511105701167017741 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.awt; import java.awt.*; import java.util.Vector; import org.jcsp.lang.*; /** * {@link java.awt.FileDialog java.awt.FileDialog} * with a channel interface. *

Process Diagram

*

*

Description

* ActiveFileDialog is a process extension of java.awt.FileDialog * with channels for run-time configuration and event notification. The event channels * should be connected to one or more application-specific server processes (instead * of registering a passive object as a Listener to this component). *

* All channels are optional. The configure and event channels are * settable from a constructor. * The event channel delivers directory and file names (see next paragraph). * Other event channels can be added to notify the occurrence of any other events * the component generates (by calling the appropriate * addXXXEventChannel method before the process is run). * Messages can be sent down the configure channel at any time to configure * the component. See the table below for details. *

* The ActiveFileDialog is made visible by sending a Boolean.TRUE down * its configure channel. A modal dialogue takes place to select a file * and the selected directory and file names are output down its event channel. *

* All channels are managed by independent internal handler processes. It is, therefore, * safe for a serial application process both to service an event channel and configure * the component – no deadlock can occur. *

* IMPORTANT: it is essential that event channels from this process are * always serviced – otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myFileDialogConfigure = Channel.one2one ();
 *   final One2OneChannel myFileDialogEvent = Channel.one2one (new OverWriteOldestBuffer (n));
 * 
 *   final ActiveFileDialog myFileDialog =
 *     new ActiveFileDialog (myFileDialogConfigure.in (), myFileDialogEvent.out ());
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Channel Protocols

*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Input Channels
configureString * The start directory for the fileDialog *
Boolean *
    *
  1. If this is the Boolean.TRUE object, * the fileDialog is made visible
  2. *
  3. If this is the Boolean.FALSE object, * the fileDialog is made invisible
  4. *
  5. Other Boolean objects are ignored
  6. *
*
ActiveFileDialog.ConfigureInvoke the user-defined Configure.configure method on the activeFileDialog.
Output Channels
eventString, StringThe directory and file names generated by the fileDialog – these may be null
windowEventWindowEventSee the {@link #addWindowEventChannel * addWindowEventChannel} method.
containerEventContainerEventSee the {@link #addContainerEventChannel * addContainerEventChannel} method.
componentEventComponentEventSee the {@link #addComponentEventChannel * addComponentEventChannel} method.
focusEventFocusEventSee the {@link #addFocusEventChannel * addFocusEventChannel} method.
keyEventKeyEventSee the {@link #addKeyEventChannel * addKeyEventChannel} method.
mouseEventMouseEventSee the {@link #addMouseEventChannel * addMouseEventChannel} method.
mouseMotionEventMouseEventSee the {@link #addMouseMotionEventChannel * addMouseMotionEventChannel} method.
*
*

Example

*
 * import java.awt.*;
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.awt.*;
 * 
 * public class ActiveFileDialogExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     final Frame root = new Frame ();
 * 
 *     final One2OneChannel configure = Channel.one2one ();
 * 
 *     final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     final ActiveFileDialog fileDialog =
 *       new ActiveFileDialog (configure.in (), event.out (), root, "ActiveFileDialog Example");
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         fileDialog,
 *         new CSProcess () {
 *           public void run () {
 *             String dir = ".";           // start directory for the file dialogue
 *             String file = "";
 *             while (file != null) {
 *               configure.out ().write (dir);
 *               configure.out ().write (Boolean.TRUE);
 *               dir = (String) event.in ().read ();
 *               file = (String) event.in ().read ();
 *               if (file != null)
 *                 System.out.println ("Chosen file = `" + dir + file + "'");
 *             }
 *           System.exit (0);
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see java.awt.FileDialog * @see java.awt.event.WindowEvent * @see java.awt.event.ContainerEvent * @see java.awt.event.ComponentEvent * @see java.awt.event.FocusEvent * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent * @see org.jcsp.util.OverWriteOldestBuffer * * @author P.D. Austin and P.H. Welch */ public class ActiveFileDialog extends FileDialog implements CSProcess { /** * The Vector construct containing the handlers. */ private Vector vec = new Vector(); /** * The channel from which configuration messages arrive. */ private ChannelInput configure; /** * The channel to which the selected directory and file names are sent. */ private ChannelOutput event; /** * Constructs a new ActiveDialog with a blank title for loading a file * and with no configuration or event channels. * Constructs a new ActiveFileDialog. * * @param parent the parent frame for the fileDialog. */ public ActiveFileDialog(Frame parent) { this(null, null, parent, "", LOAD); } /** * Constructs a new ActiveFileDialog with a blank title * and no configuration or event channels. * * @param parent the parent frame for the fileDialog. * @param mode java.awt.FileDialog.LOAD or java.awt.FileDialog.SAVE. */ public ActiveFileDialog(Frame parent, int mode) { this(null, null, parent, "", mode); } /** * Constructs a new ActiveFileDialog for loading a file * and no configuration or event channels. * * @param parent the parent frame for the fileDialog. * @param title the title of the fileDialog. */ public ActiveFileDialog(Frame parent, String title) { this(null, null, parent, title, LOAD); } /** * Constructs a new ActiveFileDialog * with no configuration or event channels. * * @param parent the parent frame for the fileDialog. * @param title the title of the fileDialog. * @param mode java.awt.FileDialog.LOAD or java.awt.FileDialog.SAVE. */ public ActiveFileDialog(Frame parent, String title, int mode) { this(null, null, parent, title, mode); } /** * Constructs a new ActiveFileDialog with a blank title for loading a file. * * @param configure the channel for configuration events * – can be null if no configuration is required. * @param event the directory and file names will be output whenever selected * – can be null if no notification is required. * @param parent the parent frame for the fileDialog. */ public ActiveFileDialog(ChannelInput configure, ChannelOutput event, Frame parent) { this(configure, event, parent, "", LOAD); } /** * Constructs a new ActiveFileDialog with a blank title. * * @param configure the channel for configuration events * – can be null if no configuration is required. * @param event the directory and file names will be output whenever selected * – can be null if no notification is required. * @param parent the parent frame for the fileDialog. * @param mode java.awt.FileDialog.LOAD or java.awt.FileDialog.SAVE. */ public ActiveFileDialog(ChannelInput configure, ChannelOutput event, Frame parent, int mode) { this(configure, event, parent, "", mode); } /** * Constructs a new ActiveFileDialog for loading a file. * * @param configure the channel for configuration events * – can be null if no configuration is required. * @param event the directory and file names will be output whenever selected * – can be null if no notification is required. * @param parent the parent frame for the fileDialog. * @param title the title of the fileDialog. */ public ActiveFileDialog(ChannelInput configure, ChannelOutput event, Frame parent, String title) { this(configure, event, parent, title, LOAD); } /** * Constructs a new ActiveFileDialog. * * @param configure the channel for configuration events * – can be null if no configuration is required. * @param event the directory and file names will be output whenever selected * – can be null if no notification is required. * @param parent the parent frame for the fileDialog. * @param title the title of the fileDialog. * @param mode java.awt.FileDialog.LOAD or java.awt.FileDialog.SAVE. * */ public ActiveFileDialog(ChannelInput configure, ChannelOutput event, Frame parent, String title, int mode) { super(parent, title, mode); this.configure = configure; this.event = event; } /** * Sets the configuration channel for this ActiveFileDialog. * This method overwrites any configuration channel set in the constructor. * * @param configure the channel for configuration events * – can be null if no configuration is required. */ public void setConfigureChannel(ChannelInput configure) { this.configure = configure; } /** * Add a new channel to this component that will be used to notify that * a WindowEvent has occurred. This should be used * instead of registering a WindowListener with the component. It is * possible to add more than one channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param windowEvent the channel down which to send ContainerEvents. */ public void addWindowEventChannel(ChannelOutput windowEvent) { if (windowEvent != null) { WindowEventHandler handler = new WindowEventHandler(windowEvent); addWindowListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ContainerEvent has occurred. This should be used * instead of registering a ContainerListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param containerEvent the channel down which to send ContainerEvents. */ public void addContainerEventChannel(ChannelOutput containerEvent) { if (containerEvent != null) { ContainerEventHandler handler = new ContainerEventHandler(containerEvent); addContainerListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a ComponentEvent has occurred. This should be used * instead of registering a ComponentListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param componentEvent the channel down which to send ComponentEvents. */ public void addComponentEventChannel(ChannelOutput componentEvent) { if (componentEvent != null) { ComponentEventHandler handler = new ComponentEventHandler(componentEvent); addComponentListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a FocusEvent has occurred. This should be used * instead of registering a FocusListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param focusEvent the channel down which to send FocusEvents. */ public void addFocusEventChannel(ChannelOutput focusEvent) { if (focusEvent != null) { FocusEventHandler handler = new FocusEventHandler(focusEvent); addFocusListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a KeyEvent has occurred. This should be used * instead of registering a KeyListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param keyEvent the channel down which to send KeyEvents. */ public void addKeyEventChannel(ChannelOutput keyEvent) { if (keyEvent != null) { KeyEventHandler handler = new KeyEventHandler(keyEvent); addKeyListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseEvent has occurred. This should be used * instead of registering a MouseListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseEvent the channel down which to send MouseEvents. */ public void addMouseEventChannel(ChannelOutput mouseEvent) { if (mouseEvent != null) { MouseEventHandler handler = new MouseEventHandler(mouseEvent); addMouseListener(handler); vec.addElement(handler); } } /** * Add a new channel to this component that will be used to notify that * a MouseMotionEvent has occurred. This should be used * instead of registering a MouseMotionListener with the component. It is * possible to add more than one Channel by calling this method multiple times * If the channel passed is null, no action will be taken. *

* NOTE: This method must be called before this process is run. * * @param mouseMotionEvent the channel down which to send MouseMotionEvents. */ public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent) { if (mouseMotionEvent != null) { MouseMotionEventHandler handler = new MouseMotionEventHandler(mouseMotionEvent); addMouseMotionListener(handler); vec.addElement(handler); } } /** * This enables general configuration of this component. Any object implementing * this interface and sent down the configure channel to this component will have its * configure method invoked on this component. *

* For an example, see {@link ActiveApplet.Configure}. */ static public interface Configure { /** * @param fileDialog the FileDialog being configured. */ public void configure(final FileDialog fileDialog); } /** * The main body of this process. */ public void run() { if (configure != null) { while (true) { Object message = configure.read(); if (message instanceof Boolean) { if (message == Boolean.TRUE) { setVisible(true); if (event != null) { event.write(getDirectory()); event.write(getFile()); } } else if (message == Boolean.FALSE) setVisible(false); } else if (message instanceof String) setDirectory((String) message); else if (message instanceof Configure) ((Configure) message).configure(this); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/0000755000000000000000000000000011410045052014002 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetChannelEndFactory.java0000644000000000000000000006024711072626250020665 0ustar package org.jcsp.net2; /** * This interface defines the methods that any networked channel factory must implement. For a concrete implementation, * see StandardNetChannelEndFactory * * @see StandardNetChannelEndFactory * @author Kevin Chalmers (updated from Quickstone Technologies) */ public interface NetChannelEndFactory { /** * Creates a new NetAltingChannelInput * * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(); /** * Creates a new NetAltingChannelInput with the given immunity level for poison * * @param immunityLevel * The immunity level for poison * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(int immunityLevel); /** * Creates a new NetAltingChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(NetworkMessageFilter.FilterRx filter); /** * Creates a new NetAltingChannelInput with the given poison immunity level which uses the given filter to decode * incoming messages * * @param immunityLevel * The immunity level to poison for the created channel * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(int immunityLevel, NetworkMessageFilter.FilterRx filter); /** * Creates a new NetSharedChannelInput * * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(); /** * Creates a new NetSharedChannelInput with the given poison immunity level * * @param immunityLevel * The immunity level to poison for this channel * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(int immunityLevel); /** * Creates a new NetSharedChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(NetworkMessageFilter.FilterRx filter); /** * Creates a new NetSharedChannelInput with the given poison immunity level, which uses the given filter to decode * messages * * @param immunityLevel * The immunity level to poison for this channel * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(int immunityLevel, NetworkMessageFilter.FilterRx filter); /** * Creates a new NetAltingChannelInput with the given index * * @param index * The index to create the channel with * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index) throws IllegalArgumentException; /** * Creates a new NetAltingChannelInput with the given index and the given poison immunity level * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index, int immunityLevel) throws IllegalArgumentException; /** * Creates a new NetAltingChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException; /** * Creates a new NetAltingChannelInput with the given index and given poison immunity, which uses the given filter * to decode incoming messages * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException; /** * Creates a new NetSharedChannelInput with the given index * * @param index * The index to create the channel with * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetSharedChannelInput numberedNet2Any(int index) throws IllegalArgumentException; /** * Creates a new NetSharedChannelInput with the given index and poison immunity level * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison the channel has * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetSharedChannelInput numberedNet2Any(int index, int immunityLevel) throws IllegalArgumentException; /** * Creates a new NetSharedChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetSharedChannelInput numberedNet2Any(int index, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException; /** * Creates a new NetSharedChannelInput with the given index and poison immunity level, which uses the given filter * to decode incoming messages. * * @param index * The index to create the channel with * @param immunityLevel * The immunity level to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists. */ public NetSharedChannelInput numberedNet2Any(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException; /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation * * @param loc * The location of the input end of the channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NetChannelLocation loc) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and having the given * poison immunity level * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and uses the given * filter to encode outgoing messages * * @param loc * The location of the input end of the channel * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the given location with the given poison immunity level, and uses the * given filter to encode outgoing messages. * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the input end at the given location * * @param loc * The location of the input end of the channel * @return A new NetSharedChannelInput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NetChannelLocation loc) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the input end at the given location and with the given poison * immunity level * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelInput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the input end with the given location, and uses the given * filter to encode outgoing messages * * @param loc * The location of the input end of the channel * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the input end with the given location and with the given * immunity level, which uses the given filter to encode outgoing messages. * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeID * The NodeID of the node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeID nodeID, int vcn) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, and with the given * poison immunity level * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison of the channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, which uses the * given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong with the underlying architecture */ public NetChannelOutput one2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, with the given * poison immunity level and uses the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter that encodes the outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong with the underlying architecture */ public NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeID nodeID, int vcn) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node and the given * poison immunity * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeID nodeID, int vcn, int immunityLevel) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, which uses * the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter used to encode the outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, with the * given poison immunity level, which uses the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node with the given * poison immunity * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison the channel has * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which uses the given * filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which has the given * poison immunity and uses the given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which has the * given poison immunity * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which uses the * given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node that has the * given poison immunity level and uses the given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ChannelDataState.java0000644000000000000000000000304211072626250020020 0ustar package org.jcsp.net2; /** * Represents the state of the networked channel. For information on networked channels, see the relevant documentation. * * @see org.jcsp.net2.NetChannelInput * @see org.jcsp.net2.NetChannelOutput * @author Kevin Chalmers */ final class ChannelDataState { /** * Private default constructor. */ private ChannelDataState() { // Empty constructor } /** * Signifies that the channel has not been activated yet. */ static final byte INACTIVE = 0; /** * Signifies that the channel has been started and is a input end. */ static final byte OK_INPUT = 1; /** * Signified that the channel has been started and is a output end. */ static final byte OK_OUTPUT = 2; /** * Signifies that the channel has been destroyed. */ static final byte DESTROYED = 3; /** * Signifies that the channel is broken. This is from the original JCSP model, and may be unnecessary as Destroyed * and Poisoned may cover this. */ static final byte BROKEN = 4; /** * Signifies that the channel has recently moved and has yet to be reestablished at a new location. */ static final byte MOVING = 5; /** * Signifies that the channel has moved to a new location and that this new location is available. */ static final byte MOVED = 6; /** * Signifies that the channel has been poisoned. */ static final byte POISONED = 7; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ObjectNetworkMessageFilter.java0000644000000000000000000001175411072626250022121 0ustar package org.jcsp.net2; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; /** * This class is the standard encoding and decoding filter for networked JCSP channels. It uses standard Java * serialization to operate. * * @author Kevin Chalmers */ public final class ObjectNetworkMessageFilter { /* * Size of the internal buffer of the memory stream */ public static int BUFFER_SIZE = 8192; /** * The receiving (decoding) filter for Objects * * @author Kevin Chalmers */ public static final class FilterRX implements NetworkMessageFilter.FilterRx { /** * These four bytes represent the normal header expected in Java for object streams */ static final byte[] objectStreamHeader = { -84, -19, 0, 5 }; /** * The byte array stream used to connect to the ObjectInputStream */ private final ResettableByteArrayInputStream bais; /** * The ObjectInputStream used to read the objects from. */ private final ObjectInputStream ois; /** * Creates a new incoming object filter */ public FilterRX() { try { // We need to put the header down the stream first to create the ObjectInputStream this.bais = new ResettableByteArrayInputStream(ObjectNetworkMessageFilter.FilterRX.objectStreamHeader); // Now hook the ObjectInputStream to the byte array stream. Should work fine. this.ois = new ObjectInputStream(this.bais); } catch (IOException ioe) { // Should never really happen, however... throw new RuntimeException( "Failed to create the required streams for ObjectNetwrokMessageFilter.FilterRX"); } } /** * Decodes an incoming byte array, converting it back into an Object * * @param bytes * The byte representation of the object * @return The recreated Object * @throws IOException * Thrown of something goes wrong during the decoding */ public Object filterRX(byte[] bytes) throws IOException { try { // Reset the byte array stream with the incoming bytes this.bais.reset(bytes); // Return the object read from the input stream return this.ois.readObject(); } catch (ClassNotFoundException cnfe) { // Not an exception thrown by other filters, so we convert into an IOException throw new IOException("Class not found"); } } } /** * The sending (encoding) filter for Object channels * * @author Kevin Chalmers */ public static final class FilterTX implements NetworkMessageFilter.FilterTx { /** * The output stream to get the bytes from */ private final ResettableByteArrayOutputStream baos; /** * The ObjectOutputStream connected to the byte stream to allow the serialization of objects */ private final ObjectOutputStream oos; /** * Creates a new encoding object filter */ public FilterTX() { try { // We use an 8Kb buffer to serialize into as default, although this could can adjusted this.baos = new ResettableByteArrayOutputStream(ObjectNetworkMessageFilter.BUFFER_SIZE); this.oos = new ObjectOutputStream(this.baos); } catch (IOException ioe) { throw new RuntimeException( "Failed to create the required streams for ObjectNetworkMessageFilter.FilterTX"); } } /** * Encodes an object into bytes by using Object serialization * * @param obj * The Object to serialize * @return The byte array equivalent of the object * @throws IOException * Thrown if something goes wrong during the serialization */ public byte[] filterTX(Object obj) throws IOException { // First we reset the byte buffer to the buffer size, just in case a previous message caused it to grow this.baos.reset(ObjectNetworkMessageFilter.BUFFER_SIZE); // Now reset the object stream. This clears any remembered messages this.oos.reset(); // Write the object to the stream this.oos.writeObject(obj); // Get the bytes return this.baos.toByteArray(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/BarrierData.java0000644000000000000000000000146711072626250017046 0ustar package org.jcsp.net2; import org.jcsp.lang.ChannelOutput; /** * Contains the data that relates to a networked Barrier. This is an external data structure within JCSP networking, and * is held by both the NetBarrier and the BarrierManager. For information on the operation of the NetBarrier, see the * relevant documentation. * * @see org.jcsp.net2.NetBarrier * @author Kevin Chalmers */ final class BarrierData { /** * The virtual Barrier number that uniquely identifies the Barrier within the Node */ int vbn = -1; /** * The current state of the Barrier */ byte state = BarrierDataState.INACTIVE; /** * The connection to the Barrier for connecting to the NetBarrier object from the Link */ ChannelOutput toBarrier = null; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/tcpip/0000755000000000000000000000000011410045052015121 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net2/tcpip/TCPIPLink.java0000644000000000000000000003134511072626250017500 0ustar package org.jcsp.net2.tcpip; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.Inet4Address; import java.net.InetAddress; import java.net.Socket; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.Link; import org.jcsp.net2.Node; import org.jcsp.net2.NodeAddress; import org.jcsp.net2.NodeID; /** * A concrete implementation of a Link that operates over a TCP/IP based socket connection. For information on Link, see * the relative documentation. *

* It is perfectly possible for a user to create a TCPIPLink without going through the standard LinkFactory approach, * although this is not recommended. For example: *

*

* * TCPIPLink link = new TCPIPLink(address);
* link.connect(); * link.registerLink();
* new ProcessManager(link).start();
*
*

*

* Can be achieved using the LinkFactory: *

*

* * link = LinkFactory.getLink(address); * *

*

* The LinkFactory will create and start the Link automatically if required. *

* * @see Link * @see TCPIPNodeAddress * @author Kevin Chalmers */ public final class TCPIPLink extends Link { /** * Defines the size of the buffer to place on the incoming and outgoing streams. This is a rather large size, and * for certain implementations, this may be reduced. It is unlikely that any sent object will be this large. */ public static int BUFFER_SIZE = 8192; /** * Flag to determine whether the Nagle algorithm should be activated. Default is false (off). */ public static boolean NAGLE = false; /** * The socket connected to the remote Node. */ private Socket sock; /** * The address of the remote Node. */ private TCPIPNodeAddress remoteAddress; /** * Creates a new TCPIPLink * * @param address * The address of the remote Node to connect to * @throws JCSPNetworkException * Thrown if something goes wrong during the creation process */ public TCPIPLink(TCPIPNodeAddress address) throws JCSPNetworkException { try { // First check if we have an ip address in the string. If not, we assume that this is to be connected // to the local machine but to a different JVM if (address.getIpAddress().equals("")) { // Get the local IP addresses InetAddress[] local = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); InetAddress toUse = InetAddress.getLocalHost(); // We basically have four types of addresses to worry about. Loopback (127), link local (169), // local (192) and (possibly) global. Grade each 1, 2, 3, 4 and use highest scoring address. In all // cases use first address of that score. int current = 0; // Loop until we have checked all the addresses for (int i = 0; i < local.length; i++) { // Ensure we have an IPv4 address if (local[i] instanceof Inet4Address) { // Get the first byte of the address byte first = local[i].getAddress()[0]; // Now check the value if (first == (byte)127 && current < 1) { // We have a Loopback address current = 1; // Set the address to use toUse = local[i]; } else if (first == (byte)169 && current < 2) { // We have a link local address current = 2; // Set the address to use toUse = local[i]; } else if (first == (byte)192 && current < 3) { // We have a local address current = 3; // Set the address to use toUse = local[i]; } else { // Assume the address is globally accessible and use by default. toUse = local[i]; // Break from the loop break; } } } // Now set the IP address of the address address.setIpAddress(toUse.getHostAddress()); // Set the address part. address.setAddress(address.getIpAddress() + ":" + address.getPort()); } // Connect the socket to the server socket on the remote Node this.sock = new Socket(address.getIpAddress(), address.getPort()); // Set TcpNoDelay. Off should improve performance for smaller packet sizes, which JCSP should have in // general this.sock.setTcpNoDelay(!TCPIPLink.NAGLE); // Create the input and output streams for the Link this.rxStream = new DataInputStream(new BufferedInputStream(this.sock.getInputStream(), TCPIPLink.BUFFER_SIZE)); this.txStream = new DataOutputStream(new BufferedOutputStream(this.sock.getOutputStream(), TCPIPLink.BUFFER_SIZE)); // Set the remote address this.remoteAddress = address; // We are not connected, so set connected to false. this.connected = false; // Log Node connection Node.log.log(this.getClass(), "Link created to " + address.toString()); } catch (IOException ioe) { // Something went wrong during connection. Log and throw exception Node.err.log(this.getClass(), "Failed to create Link to " + address.toString()); throw new JCSPNetworkException("Failed to create TCPIPLink to: " + address.getAddress()); } } /** * Creates new TCPIPLink from a Socket. This is used internally by JCSP * * @param socket * The socket to create the TCPIPLink with * @param nodeID * The NodeID of the remote Node * @throws JCSPNetworkException * Thrown if there is a problem during the connection */ TCPIPLink(Socket socket, NodeID nodeID) throws JCSPNetworkException { try { // Set the sock property this.sock = socket; // Set TcpNoDelay socket.setTcpNoDelay(!TCPIPLink.NAGLE); // Set the input and output streams for the Link this.rxStream = new DataInputStream(new BufferedInputStream(socket.getInputStream(), TCPIPLink.BUFFER_SIZE)); this.txStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), TCPIPLink.BUFFER_SIZE)); // Set the NodeID this.remoteID = nodeID; // Set the remote address this.remoteAddress = (TCPIPNodeAddress)this.remoteID.getNodeAddress(); // Set connected to true this.connected = true; // Log Link creation and Link connection Node.log.log(this.getClass(), "Link created to " + nodeID.toString()); Node.log.log(this.getClass(), "Link to " + nodeID.toString() + " connected"); } catch (IOException ioe) { // Something went wrong during the creation. Log and throw exception Node.err.log(this.getClass(), "Failed to create Link to " + nodeID.toString()); throw new JCSPNetworkException("Failed to create TCPIPLink to: " + nodeID.getNodeAddress().getAddress()); } } /** * Connects the Link to the remote Node. Exchanges the NodeIDs * * @return True if the Link successfully connected to the remote Link * @throws JCSPNetworkException * Thrown if something goes wrong during the connection */ public boolean connect() throws JCSPNetworkException { // First check if we are connected. if (this.connected) return true; // Flag to determine if we are connected at the end of the process. boolean toReturn = false; try { // Write the string representation of our NodeID to the remote Node this.txStream.writeUTF(Node.getInstance().getNodeID().toString()); this.txStream.flush(); // Read in the response from the opposite Node String response = this.rxStream.readUTF(); // Either the connection has been accepted (no connection to this Node exists on the opposite Node) or // it has not. The opposite Node sends OK in the first instance. if (response.equalsIgnoreCase("OK")) { // The connection is to be kept. Log, and set toReturn to true Node.log.log(this.getClass(), "Link to " + this.remoteAddress.toString() + " connected"); toReturn = true; } // Read in Remote NodeID as string String nodeIDString = this.rxStream.readUTF(); NodeID otherID = NodeID.parse(nodeIDString); // First check we have a tcpip Node connection. This should always be the case if (otherID.getNodeAddress() instanceof TCPIPNodeAddress) { // Set address and NodeID. If we are not connected then this NodeID can be used to // get the actual Link from the LinkManager this.remoteAddress = (TCPIPNodeAddress)otherID.getNodeAddress(); this.remoteID = otherID; // Set connected to toReturn this.connected = toReturn; return toReturn; } // We do not have a tcpip? Should never really happen however. Log and throw Exception Node.err.log(this.getClass(), "Tried to connect a TCPIPLink to a non TCPIP connection"); throw new JCSPNetworkException("Tried to connect a TCPIPLink to a non TCPIP connection"); } catch (IOException ioe) { // Something went wrong during the connection process. Log and throw exception. Node.err.log(this.getClass(), "Failed to connect TCPIPLink to: " + this.remoteAddress.getAddress()); throw new JCSPNetworkException("Failed to connect TCPIPLink to: " + this.remoteAddress.getAddress()); } } /** * Creates any required resources. For TCP/IP there is none. * * @return True if all resources were created OK. Always the case in TCP/IP * @throws JCSPNetworkException * Thrown if anything goes wrong during the creation process. */ protected boolean createResources() throws JCSPNetworkException { // Just return true return true; } /** * Destroys any resources used by the Link */ protected void destroyResources() { try { // We must ensure only one process can call destroy at any time synchronized (this) { // Check that the socket is still in existence if (this.sock != null) { // Close the streams this.txStream.close(); this.rxStream.close(); // Close the socket this.sock.close(); // Set the socket to null this.sock = null; // Remove the Link from the LinkManager this.lostLink(); } } } catch (Exception e) { // Hopefully nothing bad has happened. If it has, we still need to // register the Link as lost this.lostLink(); } } /** * Gets the NodeAddress of the Node that this Link is connected to * * @return The NodeAddress of the remotely connected Node */ public NodeAddress getRemoteAddress() { return this.remoteAddress; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/tcpip/TCPIPNodeServer.java0000644000000000000000000000561611072626250020661 0ustar package org.jcsp.net2.tcpip; import java.net.Inet4Address; import java.net.InetAddress; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Parallel; import org.jcsp.net2.Node; import org.jcsp.net2.bns.BNS; import org.jcsp.net2.cns.CNS; /** * The new name for the TCPIPCNSServer. Use this class instead. * * @author Kevin Chalmers */ public final class TCPIPNodeServer { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { Node.getInstance().setLog(System.out); Node.getInstance().setErr(System.err); // Get the local IP addresses InetAddress[] local = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); InetAddress toUse = InetAddress.getLocalHost(); // We basically have four types of addresses to worry about. Loopback (127), link local (169), // local (192) and (possibly) global. Grade each 1, 2, 3, 4 and use highest scoring address. In all // cases use first address of that score. int current = 0; // Loop until we have checked all the addresses for (int i = 0; i < local.length; i++) { // Ensure we have an IPv4 address if (local[i] instanceof Inet4Address) { // Get the first byte of the address byte first = local[i].getAddress()[0]; // Now check the value if (first == (byte)127 && current < 1) { // We have a Loopback address current = 1; // Set the address to use toUse = local[i]; } else if (first == (byte)169 && current < 2) { // We have a link local address current = 2; // Set the address to use toUse = local[i]; } else if (first == (byte)192 && current < 3) { // We have a local address current = 3; // Set the address to use toUse = local[i]; } else { // Assume the address is globally accessible and use by default. toUse = local[i]; // Break from the loop break; } } } // Create a local address object TCPIPNodeAddress localAddr = new TCPIPNodeAddress(toUse.getHostAddress(), 7890); // Initialise the Node Node.getInstance().init(localAddr); // Start CNS and BNS CSProcess[] processes = { CNS.getInstance(), BNS.getInstance() }; new Parallel(processes).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/tcpip/TCPIPNodeAddress.java0000644000000000000000000000745511072626250021003 0ustar package org.jcsp.net2.tcpip; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.Link; import org.jcsp.net2.LinkServer; import org.jcsp.net2.NodeAddress; import org.jcsp.net2.ProtocolID; /** * A concrete implementation of a NodeAddress that is designed for TCP/IP connections. * * @see NodeAddress * @author Kevin Chalmers */ public final class TCPIPNodeAddress extends NodeAddress { /** * The SUID for this class */ private static final long serialVersionUID = 1L; /** * The IP address part of the address */ private String ip; /** * The port part of the address */ private int port; /** * Creates a new TCPIPNodeAddress from an IP address and port * * @param ipAddress * The IP address part of the NodeAddress * @param portNumber * The port number part of the NodeAddress */ public TCPIPNodeAddress(String ipAddress, int portNumber) { this.ip = ipAddress; this.port = portNumber; this.protocol = "tcpip"; this.address = ipAddress + ":" + portNumber; } /** * Creates a new TCPIPNodeAddress using the local IP address and a given port number. Allows a * * @param portNumber * The port number to use */ public TCPIPNodeAddress(int portNumber) { this.port = portNumber; this.ip = ""; this.protocol = "tcpip"; } /** * Creates a new TCPIPNodeAddress */ public TCPIPNodeAddress() { this.port = 0; this.ip = ""; this.protocol = "tcpip"; } /** * Gets the port number part of this address * * @return The port number part of the address */ public final int getPort() { return this.port; } /** * Sets the port part of the address. Used internally in JCSP * * @param portNumber * The port number to use */ void setPort(int portNumber) { this.port = portNumber; } /** * Gets the IP address part of the address * * @return The IP Address part of the address */ public final String getIpAddress() { return this.ip; } /** * Sets the IP address part of the NodeAddress. Used internally in JCSP * * @param ipAddr * The IP address to use */ void setIpAddress(String ipAddr) { this.ip = ipAddr; } /** * Sets the address String. Used internally within JCSP * * @param str * The String to set as the address */ void setAddress(String str) { this.address = str; } /** * Creates a new TCPIPLink connected to a Node with this address * * @return A new TCPIPLink connected to this address * @throws JCSPNetworkException * Thrown if something goes wrong during the creation of the Link */ protected Link createLink() throws JCSPNetworkException { return new TCPIPLink(this); } /** * Creates a new TCPIPLinkServer listening on this address * * @return A new TCPIPLinkServer listening on this address * @throws JCSPNetworkException * Thrown if something goes wrong during the creation of the LinkServer */ protected LinkServer createLinkServer() throws JCSPNetworkException { return new TCPIPLinkServer(this); } /** * Returns the TCPIPProtocolID * * @return TCPIPProtocolID */ protected ProtocolID getProtocolID() { return TCPIPProtocolID.getInstance(); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/tcpip/TCPIPProtocolID.java0000644000000000000000000000315611072626250020620 0ustar package org.jcsp.net2.tcpip; import org.jcsp.net2.NodeAddress; import org.jcsp.net2.ProtocolID; /** * Concrete implementation of a ProtocolID used to parse a string representation of a TCPIPNodeAddress into a * TCPIPNodeAddress object. * * @author Kevin Chalmers */ public final class TCPIPProtocolID extends ProtocolID { /** * Singleton instance of this class */ private static TCPIPProtocolID instance = new TCPIPProtocolID(); /** * Gets the singleton instance of this class * * @return A new singleton instance of this class */ public static TCPIPProtocolID getInstance() { return instance; } /** * Default private constructor */ private TCPIPProtocolID() { // Empty constructor } /** * Parses a string to recreate a TCPIPNodeAddress object * * @param addressString * String representing the address * @return A new TCPIPNodeAddress object * @throws IllegalArgumentException * Thrown if the address is not in a correct form */ protected NodeAddress parse(String addressString) throws IllegalArgumentException { // Split address into IP and port int index = addressString.indexOf("\\\\"); String temp = addressString.substring(index + 2); index = temp.indexOf(":"); String address = temp.substring(0, index); int port = Integer.parseInt(temp.substring(index + 1, temp.length())); return new TCPIPNodeAddress(address, port); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/tcpip/TCPIPNodeFactory.java0000644000000000000000000001143611072626250021017 0ustar package org.jcsp.net2.tcpip; import java.io.IOException; import java.net.Inet4Address; import java.net.InetAddress; import java.net.ServerSocket; import java.net.UnknownHostException; import org.jcsp.lang.ProcessManager; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.Node; import org.jcsp.net2.NodeAddress; import org.jcsp.net2.NodeFactory; /** * Used to initialise a Node. This is kept for backward compatibility. See Node for more information. * * @see Node * @see NodeFactory * @deprecated This method of Node initialisation should no longer be used. See Node for more information * @author Kevin Chalmers */ public final class TCPIPNodeFactory extends NodeFactory { /** * Creates a new TCPIPNodeFactory * * @param addr * The address of the CNS / BNS */ public TCPIPNodeFactory(TCPIPNodeAddress addr) { this.cnsAddress = addr; } /** * Creates a new TCPIPNodeFactory * * @param serverIP * The IP address of the CNS / BNS */ public TCPIPNodeFactory(String serverIP) { this.cnsAddress = new TCPIPNodeAddress(serverIP, 7890); } /** * Initialises the Node, connecting to the CNS / BNS * * @param node * The Node to initialise * @return A new NodeAddress which the Node is registered at * @throws JCSPNetworkException * Thrown if something goes wrong during the Node initialisation process */ protected NodeAddress initNode(Node node) throws JCSPNetworkException { // First install TCPIPProtocolID NodeAddress.installProtocol("tcpip", TCPIPProtocolID.getInstance()); try { // Get the local IP addresses InetAddress[] local = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); InetAddress toUse = InetAddress.getLocalHost(); // We basically have four types of addresses to worry about. Loopback (127), link local (169), // local (192) and (possibly) global. Grade each 1, 2, 3, 4 and use highest scoring address. In all // cases use first address of that score. int current = 0; // Loop until we have checked all the addresses for (int i = 0; i < local.length; i++) { // Ensure we have an IPv4 address if (local[i] instanceof Inet4Address) { // Get the first byte of the address byte first = local[i].getAddress()[0]; // Now check the value if (first == (byte)127 && current < 1) { // We have a Loopback address current = 1; // Set the address to use toUse = local[i]; } else if (first == (byte)169 && current < 2) { // We have a link local address current = 2; // Set the address to use toUse = local[i]; } else if (first == (byte)192 && current < 3) { // We have a local address current = 3; // Set the address to use toUse = local[i]; } else { // Assume the address is globally accessible and use by default. toUse = local[i]; // Break from the loop break; } } } // Create a new ServerSocket listening on this address ServerSocket serv = new ServerSocket(0, 10, toUse); // Create the local address TCPIPNodeAddress localAddr = new TCPIPNodeAddress(toUse.getHostAddress(), serv.getLocalPort()); // Create and start the LinkServer TCPIPLinkServer server = new TCPIPLinkServer(serv); new ProcessManager(server).start(); // Return the NodeAddress return localAddr; } catch (UnknownHostException uhe) { throw new JCSPNetworkException("Failed to start TCPIPLinkServer. Could not get local IP address.\n" + uhe.getMessage()); } catch (IOException ioe) { throw new JCSPNetworkException("Failed to open new Server Socket.\n" + ioe.getMessage()); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/tcpip/TCPIPCNSServer.java0000644000000000000000000000560411072626250020414 0ustar package org.jcsp.net2.tcpip; import java.net.Inet4Address; import java.net.InetAddress; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Parallel; import org.jcsp.net2.Node; import org.jcsp.net2.bns.BNS; import org.jcsp.net2.cns.CNS; /** * This is the original (now deprecated) server program for use by * * @author Kevin Chalmers (updated from Quickstone Technologies) * @deprecated Use TCPIPNodeFactory instead */ public final class TCPIPCNSServer { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { // Get the local IP addresses InetAddress[] local = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); InetAddress toUse = InetAddress.getLocalHost(); // We basically have four types of addresses to worry about. Loopback (127), link local (169), // local (192) and (possibly) global. Grade each 1, 2, 3, 4 and use highest scoring address. In all // cases use first address of that score. int current = 0; // Loop until we have checked all the addresses for (int i = 0; i < local.length; i++) { // Ensure we have an IPv4 address if (local[i] instanceof Inet4Address) { // Get the first byte of the address byte first = local[i].getAddress()[0]; // Now check the value if (first == (byte)127 && current < 1) { // We have a Loopback address current = 1; // Set the address to use toUse = local[i]; } else if (first == (byte)169 && current < 2) { // We have a link local address current = 2; // Set the address to use toUse = local[i]; } else if (first == (byte)192 && current < 3) { // We have a local address current = 3; // Set the address to use toUse = local[i]; } else { // Assume the address is globally accessible and use by default. toUse = local[i]; // Break from the loop break; } } } // Create a local address object TCPIPNodeAddress localAddr = new TCPIPNodeAddress(toUse.getHostAddress(), 7890); // Initialise the Node Node.getInstance().init(localAddr); // Start CNS and BNS CSProcess[] processes = { CNS.getInstance(), BNS.getInstance() }; new Parallel(processes).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/tcpip/TCPIPLinkServer.java0000644000000000000000000002416711072626250020673 0ustar package org.jcsp.net2.tcpip; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.Inet4Address; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import org.jcsp.lang.ProcessManager; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.LinkServer; import org.jcsp.net2.Node; import org.jcsp.net2.NodeID; /** * Concrete implementation of a LinkServer that listens on a TCP/IP based ServerSocket. For information on LinkServer, * see the relevant documentation. *

* It is possible for an advanced user to create this object themselves, although it is not recommended. For example: *

*

* * TCPIPLinkServer serv = new TCPIPLinkServer(address);
* new ProcessManager(serv).start(); *
*

*

* This is done automatically during Node initialisation. However, if the machine used has multiple interfaces, this can * be used to listen on another interface also. *

* * @see LinkServer * @author Kevin Chalmers */ public final class TCPIPLinkServer extends LinkServer { /** * The ServerSocket that this class wraps around. The process listens on this connection */ private final ServerSocket serv; /** * The NodeAddress that this LinkServer is listening on. This should be the same as the Node's address. */ final TCPIPNodeAddress listeningAddress; /** * Creates LinkServer by wrapping round an existing ServerSocket. Used internally by JCSP * * @param serverSocket * The ServerSocket to create the LinkServer with */ TCPIPLinkServer(ServerSocket serverSocket) { // We need to set the NodeAddress. Create from ServerSocket address and port this.listeningAddress = new TCPIPNodeAddress(serverSocket.getInetAddress().getHostAddress(), serverSocket .getLocalPort()); this.serv = serverSocket; } /** * Creates a new TCPIPLinkServer listening on the given address * * @param address * The address to listen on for new connections * @throws JCSPNetworkException * Thrown if something goes wrong during the creation of the ServerSocket */ public TCPIPLinkServer(TCPIPNodeAddress address) throws JCSPNetworkException { try { // First check if we have an ip address in the string if (address.getIpAddress().equals("")) { // Get the local IP addresses InetAddress[] local = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); InetAddress toUse = InetAddress.getLocalHost(); // We basically have four types of addresses to worry about. Loopback (127), link local (169), // local (192) and (possibly) global. Grade each 1, 2, 3, 4 and use highest scoring address. In all // cases use first address of that score. int current = 0; // Loop until we have checked all the addresses for (int i = 0; i < local.length; i++) { // Ensure we have an IPv4 address if (local[i] instanceof Inet4Address) { // Get the first byte of the address byte first = local[i].getAddress()[0]; // Now check the value if (first == (byte)127 && current < 1) { // We have a Loopback address current = 1; // Set the address to use toUse = local[i]; } else if (first == (byte)169 && current < 2) { // We have a link local address current = 2; // Set the address to use toUse = local[i]; } else if (first == (byte)192 && current < 3) { // We have a local address current = 3; // Set the address to use toUse = local[i]; } else { // Assume the address is globally accessible and use by default. toUse = local[i]; // Break from the loop break; } } } // Now set the IP address of the address address.setIpAddress(toUse.getHostAddress()); // Set the address part now, but it may change if we have to get a port number address.setAddress(address.getIpAddress() + ":" + address.getPort()); } // Now check if the address has a port number if (address.getPort() == 0) { // No port number supplied. Get one as we create the ServerSocket InetAddress socketAddress = InetAddress.getByName(address.getIpAddress()); // Create the server socket with a random port this.serv = new ServerSocket(0, 0, socketAddress); // Assign the port to the address address.setPort(this.serv.getLocalPort()); // And set the address address.setAddress(address.getIpAddress() + ":" + address.getPort()); // Set the listening address this.listeningAddress = address; } else { // Create an IP address from the NodeAddress InetAddress inetAddress = InetAddress.getByName(address.getIpAddress()); // Now create the ServerSocket this.serv = new ServerSocket(address.getPort(), 10, inetAddress); // Set listeningAddress this.listeningAddress = address; } } catch (IOException ioe) { throw new JCSPNetworkException("Failed to create TCPIPLinkServer on: " + address.getAddress()); } } /** * The run method for the TCPIPLinkServer process */ public void run() { // Log start of Link Server Node.log.log(this.getClass(), "TCPIP Link Server started on " + this.listeningAddress.getAddress()); try { // Now we loop until something goes wrong while (true) { // Receive incoming connection Socket incoming = this.serv.accept(); // Log Node.log.log(this.getClass(), "Received new incoming connection"); // Set TcpNoDelay incoming.setTcpNoDelay(true); // Now we want to receive the connecting Node's NodeID DataInputStream inStream = new DataInputStream(incoming.getInputStream()); // Receive remote NodeID and parse String otherID = inStream.readUTF(); NodeID remoteID = NodeID.parse(otherID); // First check we have a tcpip Node connection if (remoteID.getNodeAddress() instanceof TCPIPNodeAddress) { // Create an output stream from the Socket DataOutputStream outStream = new DataOutputStream(incoming.getOutputStream()); // Now Log that we have received a connection Node.log.log(this.getClass(), "Received connection from: " + remoteID.toString()); // Check if already connected if (requestLink(remoteID) == null) { // No existing connection to incoming Node exists. Keep connection // Write OK to the connecting Node outStream.writeUTF("OK"); outStream.flush(); // Send out our NodeID outStream.writeUTF(Node.getInstance().getNodeID().toString()); outStream.flush(); // Create Link, register, and start. TCPIPLink link = new TCPIPLink(incoming, remoteID); registerLink(link); new ProcessManager(link).start(); } else { // We already have a connection to the incoming Node // Log failed connection Node.log.log(this.getClass(), "Connection to " + remoteID + " already exists. Informing remote Node."); // Write EXISTS to the remote Node outStream.writeUTF("EXISTS"); outStream.flush(); // Send out NodeID. We do this so the opposite Node can find its own connection outStream.writeUTF(Node.getInstance().getNodeID().toString()); outStream.flush(); // Close socket incoming.close(); } } // Address is not a TCPIP address. Close socket. This will cause an exception on the opposite Node else incoming.close(); } } catch (IOException ioe) { // We can't really recover from this. This may happen if the network connection was lost. // Log and fail Node.err.log(this.getClass(), "TCPIPLinkServer failed. " + ioe.getMessage()); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ProtocolID.java0000644000000000000000000000150311072626250016673 0ustar package org.jcsp.net2; import org.jcsp.net.tcpip.TCPIPProtocolID; /** * This abstract class must be defined in concrete protocol implementations. Its main usage is to allow installation and * correct parsing of relevant address strings into correct address objects. See TCPIPProtocolID for an example. * * @see TCPIPProtocolID * @author Kevin Chalmers */ public abstract class ProtocolID { /** * Parses an address string into an address object * * @param addressString * String representation of an address * @return A new NodeAddress object * @throws IllegalArgumentException * Thrown if the string is in an incorrect form */ protected abstract NodeAddress parse(String addressString) throws IllegalArgumentException; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/LinkManager.java0000644000000000000000000001130611072626250017047 0ustar package org.jcsp.net2; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.Channel; import org.jcsp.lang.ChannelOutput; import org.jcsp.lang.One2OneChannel; import org.jcsp.util.InfiniteBuffer; /** * Class for managing Links. Ensures that only one Link is only ever created for each individual Node that the hosting * Node may be connected to. This is an internal management class of JCSP. For information on how to create Links, see * LinkFactory. * * @see Link * @see LinkFactory * @author Kevin Chalmers (updated from Quickstone Technologies) */ final class LinkManager { /** * A table containing the links currently in operation within the Node. The key is a NodeID and the value is the * Link itself for that specific NodeID. */ private static final Hashtable links = new Hashtable(); /** * These event channels are used by the LinkManager to inform any process that may be interested in Link Lost * events. */ private static ArrayList eventChans = new ArrayList(); /** * Singleton instance of the LinkManager. */ private static LinkManager instance = new LinkManager(); /** * Private default constructor for singleton instance. */ private LinkManager() { // Empty constructor } /** * Gets the singleton instance of the LinkManager * * @return The singleton instance of the LinkManager */ static LinkManager getInstance() { return instance; } /** * Handles a Link Lost event. This is done by sending messages over the event channels registered in the eventChans * ArrayList. This is possible in the current thread as each event channel is infinitely buffered, so no blocking * can occur. * * @param link * The Link that has been lost. */ synchronized void lostLink(Link link) { // First remove the Link from the links table, using the Link's NodeID Link removed = (Link)links.remove(link.remoteID); // Now check if the Link was indeed removed. Unlikely to happened, but the Link may have been previously removed // meaning we have achieved nothing if (removed != null) { // Log the Link Lost Node.log.log(this.getClass(), "Link lost to: " + removed.remoteID); // Now inform any process listening on a Link Lost channel for (Iterator iter = eventChans.iterator(); iter.hasNext();) ((ChannelOutput)iter.next()).write(removed.remoteID); } } /** * Registers a new Link with the LinkManager. * * @param link * The Link to register. * @return True if a Link to the Node does not yet exist, false otherwise. */ synchronized boolean registerLink(Link link) { // Log the registration attempt Node.log.log(this.getClass(), "Trying to register Link to: " + link.remoteID); // Retrieve the NodeID for the Link NodeID remoteID = link.remoteID; // Now check whether the key has been registered in the Links table if (links.containsKey(remoteID)) { // Connection to the Node already exists. Log. Node.err.log(this.getClass(), "Failed to register Link to " + link.remoteID + ". Connection to Node already exists"); // Return false. return false; } // Link registration successful. Log. Node.log.log(this.getClass(), "Link established to: " + link.remoteID); // Add the Link to the links table links.put(link.remoteID, link); // Return true return true; } /** * Returns the Link for the given NodeID * * @param id * The NodeID of the remote node * @return The Link for the given NodeID */ synchronized Link requestLink(NodeID id) { return (Link)links.get(id); } /** * Gets a channel input end for receiving Link Lost events. * * @return A input end for receiving Link Lost Events. */ synchronized AltingChannelInput getLinkLostEventChannel() { // Create a new infinitely buffered one to one channel final One2OneChannel eventChan = Channel.one2one(new InfiniteBuffer()); // Add the output end to the list of event channels eventChans.add(eventChan.out()); // Return the input end return eventChan.in(); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ResettableByteArrayInputStream.java0000644000000000000000000000163211072626250022771 0ustar package org.jcsp.net2; import java.io.ByteArrayInputStream; /** * This class is used by the ObjectNetworkMessageFilter. It acts as a ByteArrayInputStream, but allows the internal byte * array to be replaced by another. This stops unnecessary object creation * * @author Kevin Chalmers */ final class ResettableByteArrayInputStream extends ByteArrayInputStream { /** * Creates a new ResettableByteArrayInputStream * * @param bytes * The byte array to read data from */ ResettableByteArrayInputStream(byte[] bytes) { super(bytes); } /** * Replaces the internal byte array * * @param bytes * The byte array to replace the existing internal one */ void reset(byte[] bytes) { this.buf = bytes; this.count = bytes.length; this.pos = 0; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/Net2AnyChannel.java0000644000000000000000000002103211072626250017425 0ustar package org.jcsp.net2; import org.jcsp.net2.NetworkMessageFilter.FilterRx; /** * This class is a concrete implementation of a NetSharedChannelInput, and acts as a wrapper to a Net2OneChannel, * allowing safe shared access. This class is internal to the JCSP architecture. To create an instance of this class, * use the NetChannel factory, or the CNS. * * @see NetChannelInput * @see NetSharedChannelInput * @see NetChannel * @author Kevin Chalmers (updated from Quickstone Technologies) * @author Neil Brown (for the extended read operations) */ final class Net2AnyChannel implements NetSharedChannelInput { /** * The underlying Net2OneChannel that this object wraps around */ private final Net2OneChannel actualChannel; /** * A mutual exclusion lock, allowing only one process access to perform a read operation at a time */ private final Mutex mutex = new Mutex(); /** * A static factory method to create a new Net2AnyChannel object * * @param poisonImmunity * The immunity level of the channel * @param filter * The filter used to convert an incoming byte array into an object * @return A new Net2AnyChannel * @throws JCSPNetworkException * Thrown if there is a problem creating the underlying channel */ static Net2AnyChannel create(int poisonImmunity, NetworkMessageFilter.FilterRx filter) throws JCSPNetworkException { // Create the underlying channel Net2OneChannel chan = Net2OneChannel.create(poisonImmunity, filter); // Return a new instance of this object return new Net2AnyChannel(chan); } /** * Static factory method for creating a new instance of Net2AnyChannel, given a particular index * * @param index * The index to create the channel with * @param poisonImmunity * the immunity level of the channels * @param filter * The filter used to convert the byte array back into an object * @return A new Net2AnyChannel * @throws IllegalArgumentException * Thrown if a channel with the given index already exists * @throws JCSPNetworkException * Thrown if something goes wrong during the creation of the underlying channel */ static Net2AnyChannel create(int index, int poisonImmunity, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException, JCSPNetworkException { // Create the underlying channel Net2OneChannel chan = Net2OneChannel.create(index, poisonImmunity, filter); // Return a new instance of Net2AnyChannel return new Net2AnyChannel(chan); } /** * Constructor for Net2AnyChannel * * @param chan * The underlying channel that this object will wrap around */ private Net2AnyChannel(Net2OneChannel chan) { this.actualChannel = chan; } /** * Ends an extended read operation * * @throws IllegalStateException * Thrown if the channel is not in an extended read state * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying network architecture * @throws NetworkPoisonException * Thrown if the underlying channel has been poisoned */ public void endRead() throws IllegalStateException, JCSPNetworkException, NetworkPoisonException { // Acquire lock on the channel to ensure exclusive access synchronized (this) { // We now try and end the read operation. There are a number of possible exceptions // that can be thrown, so we must catch them and re-throw them. What we must ensure is // done is that the mutex is released. try { this.actualChannel.endRead(); } catch (IllegalStateException ise) { throw ise; } catch (JCSPNetworkException jne) { throw jne; } catch (NetworkPoisonException npe) { throw npe; } finally { this.mutex.release(); } } } /** * Reads the next message from the channel * * @return Message read from the channel * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws IllegalStateException * Thrown if the channel is in an extended read state * @throws NetworkPoisonException * Thrown if the channel has been poisoned */ public Object read() throws JCSPNetworkException, IllegalStateException, NetworkPoisonException { // First, we must endure that only one process is trying to perform a read operations this.mutex.claim(); // Now ensure that we are the only process operating on the underlying channel synchronized (this) { // We now try and perform the read operation. There are a number of possible exceptions, which we must // catch and then re-throw again. Finally, we must ensure that the read operation is finished by // releasing the mutex. try { Object toReturn = this.actualChannel.read(); return toReturn; } catch (JCSPNetworkException jne) { throw jne; } catch (IllegalStateException ise) { throw ise; } catch (NetworkPoisonException npe) { throw npe; } finally { this.mutex.release(); } } } /** * Begins an extended read operation on the channel * * @return The message read from the channel * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws NetworkPoisonException * Thrown if the channel has been poisoned * @throws IllegalStateException * Thrown if the channel is in an extended read state */ public Object startRead() throws JCSPNetworkException, NetworkPoisonException, IllegalStateException { // First ensure we have exclusive read access this.mutex.claim(); // Now ensure we have exclusive access to the channel synchronized (this) { // Now return the message read from the channel. We could encounter a number of exceptions here, in which // case we must re-throw the exception, remembering to release to release the read lock prior to doing so. try { return this.actualChannel.startRead(); } catch (JCSPNetworkException jne) { this.mutex.release(); throw jne; } catch (NetworkPoisonException npe) { this.mutex.release(); throw npe; } catch (IllegalStateException ise) { this.mutex.release(); throw ise; } } } /** * Poisons the underlying channel * * @param strength * The strength of the poison */ public void poison(int strength) { synchronized (this) { this.actualChannel.poison(strength); } } /** * Gets the channel location of this channel * * @return Location of this channel */ public NetLocation getLocation() { return this.actualChannel.getLocation(); } /** * Destroys the channel */ public void destroy() { synchronized (this) { this.actualChannel.destroy(); } } /** * Sets the underlying message filter * * @param decoder * The new message filter to use */ public void setDecoder(FilterRx decoder) { synchronized (this) { this.actualChannel.setDecoder(decoder); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/0000755000000000000000000000000011410045051015250 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/CodeLoadingChannelFilter.java0000644000000000000000000000674611072626250022751 0ustar package org.jcsp.net2.mobile; import java.io.ByteArrayInputStream; import java.io.IOException; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetworkMessageFilter; import org.jcsp.net2.Node; import org.jcsp.net2.ObjectNetworkMessageFilter; /** * @author Kevin */ public final class CodeLoadingChannelFilter { public static final class FilterRX implements NetworkMessageFilter.FilterRx { private final ObjectNetworkMessageFilter.FilterRX objectFilter = new ObjectNetworkMessageFilter.FilterRX(); public FilterRX() { // Do nothing } public Object filterRX(byte[] bytes) throws IOException { try { Object message = this.objectFilter.filterRX(bytes); if (!(message instanceof DynamicClassLoaderMessage)) { return message; } DynamicClassLoaderMessage loaderMessage = (DynamicClassLoaderMessage)message; byte[] bytesWithHeader = new byte[4 + loaderMessage.bytes.length]; byte[] header = { -84, -19, 0, 5 }; System.arraycopy(header, 0, bytesWithHeader, 0, 4); System.arraycopy(loaderMessage.bytes, 0, bytesWithHeader, 4, loaderMessage.bytes.length); ByteArrayInputStream bais = new ByteArrayInputStream(bytesWithHeader); DynamicClassLoader loader = (DynamicClassLoader)ClassManager.classLoaders .get(loaderMessage.originatingNode); if (loader == null) { loader = new DynamicClassLoader(loaderMessage.originatingNode, loaderMessage.requestLocation); ClassManager.classLoaders.put(loaderMessage.originatingNode, loader); } DynamicObjectInputStream dois = new DynamicObjectInputStream(bais, loader); Object toReturn = dois.readObject(); return toReturn; } catch (ClassNotFoundException cnfe) { throw new IOException("Failed to load class"); } } } public static final class FilterTX implements NetworkMessageFilter.FilterTx { private final ObjectNetworkMessageFilter.FilterTX internalFilter = new ObjectNetworkMessageFilter.FilterTX(); public FilterTX() { } public byte[] filterTX(Object obj) throws IOException { ClassLoader loader = obj.getClass().getClassLoader(); byte[] bytes = this.internalFilter.filterTX(obj); if (loader == ClassLoader.getSystemClassLoader() || loader == null) { DynamicClassLoaderMessage message = new DynamicClassLoaderMessage(Node.getInstance().getNodeID(), (NetChannelLocation)ClassManager.in.getLocation(), bytes); byte[] wrappedData = this.internalFilter.filterTX(message); return wrappedData; } DynamicClassLoader dcl = (DynamicClassLoader)loader; DynamicClassLoaderMessage message = new DynamicClassLoaderMessage(dcl.originatingNode, (NetChannelLocation)ClassManager.in.getLocation(), bytes); byte[] wrappedData = this.internalFilter.filterTX(message); return wrappedData; } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/MessageBox.java0000644000000000000000000001046211072626250020165 0ustar package org.jcsp.net2.mobile; import org.jcsp.lang.Alternative; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Guard; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.NetAltingChannelInput; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.NetworkMessageFilter; import org.jcsp.net2.Node; final class MessageBox implements CSProcess { private final NetAltingChannelInput in; private final NetAltingChannelInput fromInputEnd; private NetChannelOutput toInputEnd = null; private final NetworkMessageFilter.FilterTx encoder; private final NetChannelLocation inputEndLoc = null; MessageBox(NetAltingChannelInput intoBox, NetAltingChannelInput requestChannel, NetworkMessageFilter.FilterTx encodingFilter) { this.in = intoBox; this.fromInputEnd = requestChannel; this.encoder = encodingFilter; } public void run() { try { while (true) { MobileChannelMessage msg = (MobileChannelMessage)fromInputEnd.read(); if (msg.type == MobileChannelMessage.REQUEST) { if (!msg.inputLocation.equals(this.inputEndLoc)) { if (this.toInputEnd != null) { this.toInputEnd.destroy(); } this.toInputEnd = NetChannel.one2net(msg.inputLocation, this.encoder); } Object obj = this.in.read(); this.toInputEnd.write(obj); } else if (msg.type == MobileChannelMessage.CHECK) { if (!msg.inputLocation.equals(this.inputEndLoc)) { if (this.toInputEnd != null) { this.toInputEnd.destroy(); } this.toInputEnd = NetChannel.one2net(msg.inputLocation, this.encoder); } MobileChannelMessage response = new MobileChannelMessage(); response.type = MobileChannelMessage.CHECK_RESPONSE; if (this.in.pending()) { response.ready = true; this.toInputEnd.write(response); } else { this.toInputEnd.write(response); Guard[] guards = { this.fromInputEnd, this.in }; Alternative alt = new Alternative(guards); int selected = alt.priSelect(); if (selected == 1) { MobileChannelMessage resp = new MobileChannelMessage(); resp.type = MobileChannelMessage.CHECK_RESPONSE; resp.ready = true; try { // Try and write to the input end this.toInputEnd.write(response); } catch (JCSPNetworkException ex) { // The channel input end is no longer there. // Quietly ignore and wait for request. } } // If a new message from the input end has been received, then deal with // that message separately. Go into the main loop again. } } } } catch (JCSPNetworkException jne) { // Something went wrong during comms. Kill the message box and all channels. this.in.destroy(); this.fromInputEnd.destroy(); if (this.toInputEnd != null) { this.toInputEnd.destroy(); } Node.err.log(this.getClass(), "Message box threw exception during comms. Destroying"); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/MobileChannelInput.java0000644000000000000000000000757411072626250021662 0ustar package org.jcsp.net2.mobile; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jcsp.lang.ProcessManager; import org.jcsp.net2.NetAltingChannelInput; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelInput; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.NetLocation; import org.jcsp.net2.NetworkMessageFilter; import org.jcsp.net2.ObjectNetworkMessageFilter; import org.jcsp.net2.NetworkMessageFilter.FilterRx; public final class MobileChannelInput implements NetChannelInput, Serializable { private NetChannelLocation messageBoxLoc; private NetChannelLocation msgBoxReqLoc; private transient NetChannelInput actualIn; private transient NetChannelOutput toMessageBox; public MobileChannelInput() { NetAltingChannelInput toMsgBox = NetChannel.net2one(); NetAltingChannelInput msgBoxReq = NetChannel.net2one(); MessageBox msgBox = new MessageBox(toMsgBox, msgBoxReq, new ObjectNetworkMessageFilter.FilterTX()); new ProcessManager(msgBox).start(); this.messageBoxLoc = (NetChannelLocation)toMsgBox.getLocation(); this.msgBoxReqLoc = (NetChannelLocation)msgBoxReq.getLocation(); this.actualIn = NetChannel.net2one(); this.toMessageBox = NetChannel.one2net(this.msgBoxReqLoc); } public MobileChannelInput(NetworkMessageFilter.FilterTx encoder, NetworkMessageFilter.FilterRx decoder) { NetAltingChannelInput toMsgBox = NetChannel.net2one(decoder); NetAltingChannelInput msgBoxReq = NetChannel.net2one(); MessageBox msgBox = new MessageBox(toMsgBox, msgBoxReq, encoder); new ProcessManager(msgBox).start(); this.messageBoxLoc = (NetChannelLocation)toMsgBox.getLocation(); this.msgBoxReqLoc = (NetChannelLocation)msgBoxReq.getLocation(); this.actualIn = NetChannel.net2one(decoder); this.toMessageBox = NetChannel.one2net(this.msgBoxReqLoc); } public void endRead() { this.actualIn.endRead(); } public Object read() { MobileChannelMessage msg = new MobileChannelMessage(); msg.type = MobileChannelMessage.REQUEST; msg.inputLocation = (NetChannelLocation)this.actualIn.getLocation(); this.toMessageBox.write(msg); Object toReturn = this.actualIn.read(); return toReturn; } public Object startRead() { MobileChannelMessage msg = new MobileChannelMessage(); msg.type = MobileChannelMessage.REQUEST; msg.inputLocation = (NetChannelLocation)this.actualIn.getLocation(); this.toMessageBox.write(msg); Object toReturn = this.actualIn.startRead(); return toReturn; } public void poison(int strength) { this.actualIn.poison(strength); } public void destroy() { this.actualIn.destroy(); this.toMessageBox.destroy(); } public NetLocation getLocation() { return this.messageBoxLoc; } public void setDecoder(FilterRx decoder) { this.actualIn.setDecoder(decoder); } private void writeObject(ObjectOutputStream output) throws IOException { output.writeObject(this.messageBoxLoc); output.writeObject(this.msgBoxReqLoc); this.actualIn.destroy(); this.toMessageBox.destroy(); } private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { this.messageBoxLoc = (NetChannelLocation)input.readObject(); this.msgBoxReqLoc = (NetChannelLocation)input.readObject(); this.actualIn = NetChannel.net2one(); this.toMessageBox = NetChannel.one2net(this.messageBoxLoc); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/DynamicObjectInputStream.java0000644000000000000000000000117711072626250023042 0ustar package org.jcsp.net2.mobile; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectStreamClass; /** * @author Kevin */ final class DynamicObjectInputStream extends ObjectInputStream { final DynamicClassLoader dcl; DynamicObjectInputStream(InputStream is, DynamicClassLoader loader) throws IOException { super(is); this.dcl = loader; } protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { return dcl.loadClass(desc.getName()); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/ClassData.java0000644000000000000000000000051611072626250017766 0ustar package org.jcsp.net2.mobile; import java.io.Serializable; /** * @author Kevin */ final class ClassData implements Serializable { final String className; final byte[] bytes; ClassData(String name, byte[] classBytes) { this.className = name; this.bytes = classBytes; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/DynamicClassLoader.java0000644000000000000000000000536611072626250021640 0ustar package org.jcsp.net2.mobile; import java.util.Hashtable; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelInput; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.NodeID; /** * @author Kevin */ final class DynamicClassLoader extends ClassLoader { final NodeID originatingNode; NetChannelOutput requestClassData; NetChannelInput classDataResponse = NetChannel.net2one(); final Hashtable classes = new Hashtable(); DynamicClassLoader(NodeID originator, NetChannelLocation requestLocation) { super(ClassLoader.getSystemClassLoader()); this.originatingNode = originator; this.requestClassData = NetChannel.one2net(requestLocation); } protected Class findClass(String className) throws ClassNotFoundException, JCSPNetworkException { try { Class clazz = Class.forName(className, false, ClassLoader.getSystemClassLoader()); return clazz; } catch (ClassNotFoundException cnfe) { try { byte[] bytes = this.requestClass(className); Class toReturn = this.defineClass(className, bytes, 0, bytes.length); this.resolveClass(toReturn); return toReturn; } catch (ClassNotFoundException cnf) { throw cnf; } } } synchronized byte[] requestClass(String className) throws ClassNotFoundException { try { byte[] bytes = (byte[])classes.get(className); if (bytes != null) { return bytes; } if (this.requestClassData == null) { throw new ClassNotFoundException(className); } ClassRequest req = new ClassRequest(this.originatingNode, className, (NetChannelLocation)this.classDataResponse.getLocation()); this.requestClassData.write(req); ClassData data = (ClassData)classDataResponse.read(); if (data.bytes == null) { throw new ClassNotFoundException(className); } this.classes.put(className, data.bytes); return data.bytes; } catch (JCSPNetworkException jne) { this.classDataResponse.destroy(); this.classDataResponse = null; this.requestClassData.destroy(); this.requestClassData = null; throw new ClassNotFoundException(className); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/ClassRequest.java0000644000000000000000000000104611072626250020544 0ustar package org.jcsp.net2.mobile; import java.io.Serializable; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NodeID; /** * @author Kevin */ final class ClassRequest implements Serializable { final NodeID originatingNode; final String className; final NetChannelLocation returnLocation; ClassRequest(NodeID originator, String name, NetChannelLocation response) { this.originatingNode = originator; this.className = name; this.returnLocation = response; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/MobileChannelMessage.java0000644000000000000000000000064411072626250022136 0ustar package org.jcsp.net2.mobile; import java.io.Serializable; import org.jcsp.net2.NetChannelLocation; /** * @author Kevin */ final class MobileChannelMessage implements Serializable { static final int REQUEST = 1; static final int CHECK = 2; static final int CHECK_RESPONSE = 3; int type = -1; boolean ready = false; NetChannelLocation inputLocation = null; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/ClassManager.java0000644000000000000000000000766011072626250020476 0ustar package org.jcsp.net2.mobile; import java.io.IOException; import java.io.InputStream; import java.util.Hashtable; import org.jcsp.lang.CSProcess; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelInput; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.Node; /** * @author Kevin */ final class ClassManager implements CSProcess { static Hashtable classLoaders = new Hashtable(); static NetChannelInput in = NetChannel.numberedNet2One(10); public void run() { while (true) { try { ClassRequest req = (ClassRequest)in.read(); if (req.originatingNode.equals(Node.getInstance().getNodeID())) { String className = req.className.replace('.', '/') + ".class"; InputStream is = ClassLoader.getSystemResourceAsStream(className); try { if (is != null) { int read = 0; byte[] bytes = new byte[is.available()]; while (read < bytes.length) read += is.read(bytes, read, bytes.length - read); ClassData resp = new ClassData(req.className, bytes); NetChannelOutput out = NetChannel.one2net(req.returnLocation); out.asyncWrite(resp); out.destroy(); out = null; } else { ClassData resp = new ClassData(req.className, null); NetChannelOutput out = NetChannel.one2net(req.returnLocation); out.asyncWrite(resp); out.destroy(); out = null; } } catch (IOException ioe) { ClassData resp = new ClassData(req.className, null); NetChannelOutput out = NetChannel.one2net(req.returnLocation); out.asyncWrite(resp); out.destroy(); } } else { DynamicClassLoader loader = (DynamicClassLoader)ClassManager.classLoaders.get(req.originatingNode); if (loader == null) { ClassData resp = new ClassData(req.className, null); NetChannelOutput out = NetChannel.one2net(req.returnLocation); out.asyncWrite(resp); out.destroy(); } else { try { byte[] bytes = loader.requestClass(req.className); ClassData resp = new ClassData(req.className, bytes); NetChannelOutput out = NetChannel.one2net(req.returnLocation); out.asyncWrite(resp); out.destroy(); } catch (ClassNotFoundException cnf) { ClassData resp = new ClassData(req.className, null); NetChannelOutput out = NetChannel.one2net(req.returnLocation); out.asyncWrite(resp); out.destroy(); } } } } catch (JCSPNetworkException jne) { // Do nothing } } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/MobileChannelOutput.java0000644000000000000000000000407411072626250022053 0ustar package org.jcsp.net2.mobile; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.NetLocation; import org.jcsp.net2.NetworkPoisonException; import org.jcsp.net2.NetworkMessageFilter.FilterTx; /** * @author Kevin */ public final class MobileChannelOutput implements NetChannelOutput, Serializable { private NetChannelLocation msgBoxLocation; private transient NetChannelOutput actualOut; public MobileChannelOutput(NetChannelLocation loc) { this.msgBoxLocation = loc; this.actualOut = NetChannel.one2net(loc); } public MobileChannelOutput(NetChannelLocation loc, FilterTx encoder) { this.msgBoxLocation = loc; this.actualOut = NetChannel.one2net(loc, encoder); } public void write(Object object) { this.actualOut.write(object); } public void destroy() { this.actualOut.destroy(); } public NetLocation getLocation() { return this.actualOut.getLocation(); } public void poison(int strength) { this.actualOut.poison(strength); } public void asyncWrite(Object obj) throws JCSPNetworkException, NetworkPoisonException { this.actualOut.asyncWrite(obj); } public void setEncoder(FilterTx encoder) { this.actualOut.setEncoder(encoder); } private void writeObject(ObjectOutputStream output) throws IOException { output.writeObject(this.msgBoxLocation); this.actualOut.destroy(); } private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { this.msgBoxLocation = (NetChannelLocation)input.readObject(); this.actualOut = NetChannel.one2net(this.msgBoxLocation); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/mobile/DynamicClassLoaderMessage.java0000644000000000000000000000136011072626250023133 0ustar package org.jcsp.net2.mobile; import java.io.Serializable; import org.jcsp.lang.ProcessManager; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NodeID; /** * @author Kevin */ final class DynamicClassLoaderMessage implements Serializable { static { ClassManager classManager = new ClassManager(); new ProcessManager(classManager).start(); } final NodeID originatingNode; final NetChannelLocation requestLocation; final byte[] bytes; DynamicClassLoaderMessage(NodeID originator, NetChannelLocation request, byte[] classData) { this.originatingNode = originator; this.requestLocation = request; this.bytes = classData; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ResettableByteArrayOutputStream.java0000644000000000000000000000161211072626250023170 0ustar package org.jcsp.net2; import java.io.ByteArrayOutputStream; /** * This class is used by the ObjectNetworkMessageFilter. It acts as a normal ByteArrayOutputStream, but allows the * internal buffer to be reset in size, thereby regaining some resources. * * @author Kevin Chalmers */ final class ResettableByteArrayOutputStream extends ByteArrayOutputStream { /** * Creates a new ResettableByteArrayOutputStream * * @param size * The size of the internal buffer */ ResettableByteArrayOutputStream(int size) { super(size); } /** * Resets the internal buffer * * @param size * The size to reset the internal buffer to */ void reset(int size) { this.reset(); if (this.buf.length != size) this.buf = new byte[size]; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/StandardNetChannelEndFactory.java0000644000000000000000000007725111072626250022351 0ustar package org.jcsp.net2; /** * A concrete implementation of a NetChannelEndFactory, used to create networked channel ends * * @see NetChannelEndFactory * @see NetChannel * @author Kevin Chalmers (updated from Quickstone Technologies) */ public final class StandardNetChannelEndFactory implements NetChannelEndFactory { /** * Creates a new NetAltingChannelInput * * @deprecated Use net2one instead * @return A new NetAltingChannelInput */ public NetAltingChannelInput createNet2One() { return Net2OneChannel.create(Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetSharedChannelInput * * @deprecated Use net2any instead * @return A new NetSharedChannelInput */ public NetSharedChannelInput createNet2Any() { return Net2AnyChannel.create(Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetChannelOutput connected to the input channel end with the given location * * @deprecated Use one2net instead * @param loc * The location to connect the output end to * @return A new NetChannelOutput connected to the input end at the given location * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput createOne2Net(NetChannelLocation loc) throws JCSPNetworkException { return One2NetChannel.create(loc, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location * * @deprecated Use any2net instead * @param loc * The location to connect the output end to * @return A new NetSharedChannelOutput connected to the input end at the given location * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput createAny2Net(NetChannelLocation loc) throws JCSPNetworkException { return Any2NetChannel.create(loc, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetAltingChannelInput * * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one() { return Net2OneChannel.create(Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetAltingChannelInput with the given immunity level for poison * * @param immunityLevel * The immunity level for poison * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(int immunityLevel) { return Net2OneChannel.create(immunityLevel, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetAltingChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(NetworkMessageFilter.FilterRx filter) { return Net2OneChannel.create(Integer.MAX_VALUE, filter); } /** * Creates a new NetAltingChannelInput with the given poison immunity level which uses the given filter to decode * incoming messages * * @param immunityLevel * The immunity level to poison for the created channel * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return Net2OneChannel.create(immunityLevel, filter); } /** * Creates a new NetSharedChannelInput * * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any() { return Net2AnyChannel.create(Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetSharedChannelInput with the given poison immunity level * * @param immunityLevel * The immunity level to poison for this channel * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(int immunityLevel) { return Net2AnyChannel.create(immunityLevel, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetSharedChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(NetworkMessageFilter.FilterRx filter) { return Net2AnyChannel.create(Integer.MAX_VALUE, filter); } /** * Creates a new NetSharedChannelInput with the given poison immunity level, which uses the given filter to decode * messages * * @param immunityLevel * The immunity level to poison for this channel * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return Net2AnyChannel.create(immunityLevel, filter); } /** * Creates a new NetAltingChannelInput with the given index * * @param index * The index to create the channel with * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index) throws IllegalArgumentException { return Net2OneChannel.create(index, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetAltingChannelInput with the given index and the given poison immunity level * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index, int immunityLevel) throws IllegalArgumentException { return Net2OneChannel.create(index, immunityLevel, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetAltingChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return Net2OneChannel.create(index, Integer.MAX_VALUE, filter); } /** * Creates a new NetAltingChannelInput with the given index and given poison immunity, which uses the given filter * to decode incoming messages * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return Net2OneChannel.create(index, immunityLevel, filter); } /** * Creates a new NetSharedChannelInput with the given index * * @param index * The index to create the channel with * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetSharedChannelInput numberedNet2Any(int index) throws IllegalArgumentException { return Net2AnyChannel.create(index, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetSharedChannelInput with the given index and poison immunity level * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison the channel has * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetSharedChannelInput numberedNet2Any(int index, int immunityLevel) throws IllegalArgumentException { return Net2AnyChannel.create(index, immunityLevel, new ObjectNetworkMessageFilter.FilterRX()); } /** * Creates a new NetSharedChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public NetSharedChannelInput numberedNet2Any(int index, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return Net2AnyChannel.create(index, Integer.MAX_VALUE, filter); } /** * Creates a new NetSharedChannelInput with the given index and poison immunity level, which uses the given filter * to decode incoming messages. * * @param index * The index to create the channel with * @param immunityLevel * The immunity level to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists. */ public NetSharedChannelInput numberedNet2Any(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return Net2AnyChannel.create(index, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation * * @param loc * The location of the input end of the channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NetChannelLocation loc) throws JCSPNetworkException { return One2NetChannel.create(loc, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and having the given * poison immunity level * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel) throws JCSPNetworkException { return One2NetChannel.create(loc, immunityLevel, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and uses the given * filter to encode outgoing messages * * @param loc * The location of the input end of the channel * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return One2NetChannel.create(loc, Integer.MAX_VALUE, filter); } /** * Creates a new NetChannelOutput connected to the given location with the given poison immunity level, and uses the * given filter to encode outgoing messages. * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return One2NetChannel.create(loc, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location * * @param loc * The location of the input end of the channel * @return A new NetSharedChannelInput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NetChannelLocation loc) throws JCSPNetworkException { return Any2NetChannel.create(loc, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location and with the given poison * immunity level * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelInput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel) throws JCSPNetworkException { return Any2NetChannel.create(loc, immunityLevel, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetSharedChannelOutput connected to the input end with the given location, and uses the given * filter to encode outgoing messages * * @param loc * The location of the input end of the channel * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return Any2NetChannel.create(loc, Integer.MAX_VALUE, filter); } /** * Creates a new NetSharedChannelOutput connected to the input end with the given location and with the given * immunity level, which uses the given filter to encode outgoing messages. * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return Any2NetChannel.create(loc, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeID * The NodeID of the node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeID nodeID, int vcn) throws JCSPNetworkException { NetChannelLocation loc = new NetChannelLocation(nodeID, vcn); return One2NetChannel.create(loc, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, and with the given * poison immunity level * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison of the channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel) throws JCSPNetworkException { NetChannelLocation loc = new NetChannelLocation(nodeID, vcn); return One2NetChannel.create(loc, immunityLevel, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, which uses the * given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong with the underlying architecture */ public NetChannelOutput one2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { NetChannelLocation loc = new NetChannelLocation(nodeID, vcn); return One2NetChannel.create(loc, Integer.MAX_VALUE, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, with the given * poison immunity level and uses the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter that encodes the outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong with the underlying architecture */ public NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { NetChannelLocation loc = new NetChannelLocation(nodeID, vcn); return One2NetChannel.create(loc, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeID nodeID, int vcn) throws JCSPNetworkException { NetChannelLocation loc = new NetChannelLocation(nodeID, vcn); return Any2NetChannel.create(loc, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node and the given * poison immunity * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeID nodeID, int vcn, int immunityLevel) throws JCSPNetworkException { NetChannelLocation loc = new NetChannelLocation(nodeID, vcn); return Any2NetChannel.create(loc, immunityLevel, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, which uses * the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter used to encode the outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { NetChannelLocation loc = new NetChannelLocation(nodeID, vcn); return Any2NetChannel.create(loc, Integer.MAX_VALUE, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, with the * given poison immunity level, which uses the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { NetChannelLocation loc = new NetChannelLocation(nodeID, vcn); return Any2NetChannel.create(loc, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn) throws JCSPNetworkException { NodeID remoteNode = LinkFactory.getLink(nodeAddr).remoteID; NetChannelLocation loc = new NetChannelLocation(remoteNode, vcn); return One2NetChannel.create(loc, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node with the given * poison immunity * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison the channel has * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel) throws JCSPNetworkException { NodeID remoteNode = LinkFactory.getLink(nodeAddr).remoteID; NetChannelLocation loc = new NetChannelLocation(remoteNode, vcn); return One2NetChannel.create(loc, immunityLevel, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which uses the given * filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { NodeID remoteNode = LinkFactory.getLink(nodeAddr).remoteID; NetChannelLocation loc = new NetChannelLocation(remoteNode, vcn); return One2NetChannel.create(loc, Integer.MAX_VALUE, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which has the given * poison immunity and uses the given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { NodeID remoteNode = LinkFactory.getLink(nodeAddr).remoteID; NetChannelLocation loc = new NetChannelLocation(remoteNode, vcn); return One2NetChannel.create(loc, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn) throws JCSPNetworkException { NodeID remoteNode = LinkFactory.getLink(nodeAddr).remoteID; NetChannelLocation loc = new NetChannelLocation(remoteNode, vcn); return Any2NetChannel.create(loc, Integer.MAX_VALUE, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which has the * given poison immunity * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel) throws JCSPNetworkException { NodeID remoteNode = LinkFactory.getLink(nodeAddr).remoteID; NetChannelLocation loc = new NetChannelLocation(remoteNode, vcn); return Any2NetChannel.create(loc, immunityLevel, new ObjectNetworkMessageFilter.FilterTX()); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which uses the * given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { NodeID remoteNode = LinkFactory.getLink(nodeAddr).remoteID; NetChannelLocation loc = new NetChannelLocation(remoteNode, vcn); return Any2NetChannel.create(loc, Integer.MAX_VALUE, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node that has the * given poison immunity level and uses the given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { NodeID remoteNode = LinkFactory.getLink(nodeAddr).remoteID; NetChannelLocation loc = new NetChannelLocation(remoteNode, vcn); return Any2NetChannel.create(loc, immunityLevel, filter); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetChannelLocation.java0000644000000000000000000000711711072626250020374 0ustar package org.jcsp.net2; import java.io.Serializable; /** * This class is a data structure representing the location of a NetChannelInput in a network. The NetChannelLocation * consists of the NodeID of the Node on which the NetChannelInput resides, and its Virtual Channel Number, which is the * number uniquely identifying the NetChannelInput on said Node. *

* To acquire the NetChannelLocation of a NetBarrier, use the getLocation method: *

*

* * NetChannelLocation location = (NetChannelLocation)chan.getLocation(); * *

*

* The location returned depends on whether the channel is a NetChannelInput or a NetChannelOutput end. An input end * will return its own location. An output end will return the location of the input end it is connected to. This is * because we consider a networked channel to be a single, virtual construct, with only one location. That location is * where the input end is located. *

* * @see NetChannelInput * @see NetChannelOutput * @see NetLocation * @author Kevin Chalmers */ public final class NetChannelLocation extends NetLocation implements Serializable { /** * The SUID representing this class */ private static final long serialVersionUID = 1L; /** * The NodeID portion of the location */ private final NodeID nodeID; /** * The vcn portion of the location */ private final int vcn; /** * Creates a new NetChannelLocation * * @param aNodeID * The NodeID part of the location * @param aVCN * The vcn part of the location */ public NetChannelLocation(NodeID aNodeID, int aVCN) { this.nodeID = aNodeID; this.vcn = aVCN; } /** * Gets the NodeID part of the location * * @return The NodeID part of the NetChannelLocation */ public NodeID getNodeID() { return this.nodeID; } /** * Gets the NodeAddress part of the location * * @return The NodeAddress part of the NetChannelLocation */ public NodeAddress getNodeAddress() { return this.nodeID.getNodeAddress(); } /** * Gets the vcn part of the location * * @return The VCN part of the NetChannelLocation */ public int getVCN() { return this.vcn; } /** * Converts the NetChannelLocation object into a string representation of the form ncl://[NodeID]/[VCN] * * @return The String form of the NetChannelLocation */ public String toString() { return "ncl://" + this.nodeID.toString() + "/" + this.vcn; } /** * Converts the string form of a NetChannelLocation back into its object form * * @param str * The string representation of a NetChannelLocation * @return A new NetChannelLocation created from the String representation */ public static NetChannelLocation parse(String str) { if (str.equalsIgnoreCase("null")) return null; if (str.startsWith("ncl://")) { String toParse = str.substring(6); int index = toParse.indexOf("/"); NodeID nodeID = NodeID.parse(toParse.substring(0, index)); int vcn = Integer.parseInt(toParse.substring(index + 1)); return new NetChannelLocation(nodeID, vcn); } throw new IllegalArgumentException("String is not a string form of a NetChannelLocation"); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/Any2NetChannel.java0000644000000000000000000001020611072626250017426 0ustar package org.jcsp.net2; import org.jcsp.lang.PoisonException; import org.jcsp.net2.NetworkMessageFilter.FilterTx; /*********************************************************************************************************************** * An outputting network channel (TX) that can be safely shared amongst multiple writers (Any2Net). This is the concrete * implementation of the construct. For information on the user level interface, see NetSharedChannelOutput * * @see org.jcsp.net2.NetSharedChannelOutput * @author Kevin Chalmers (updated from Quickstone Technologies Limited) */ final class Any2NetChannel implements NetSharedChannelOutput { /** * The underlying One2NetChannel used by this channel. This class acts like a wrapper, protecting the underlying * unshared connection. */ private final One2NetChannel chan; /** * Static factory method used to create an Any2NetChannel * * @param loc * The location of the input channel end * @param immunity * The immunity level of the channel * @param filter * The filter used to convert the object being sent into bytes * @return A new Any2NetChannel connected to the input end. * @throws JCSPNetworkException * Thrown if a connection to the Node cannot be made. */ static Any2NetChannel create(NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { One2NetChannel channel = One2NetChannel.create(loc, immunity, filter); return new Any2NetChannel(channel); } /** * Constructor wrapping an existing One2NetChannel in an Any2NetChannel * * @param channel * The One2NetChannel to be wrapped. */ private Any2NetChannel(One2NetChannel channel) { this.chan = channel; } /** * Poisons the underlying channel * * @param strength * The strength of the poison being put on the channel */ public void poison(int strength) { synchronized (this) { this.chan.poison(strength); } } /** * Gets the NetChannelLocation of the input end this channel is connected to. * * @return The location of the input end that this output end is connected to. */ public NetLocation getLocation() { return this.chan.getLocation(); } /** * Writes an object to the underlying channel. * * @param object * The Object to write to the channel * @throws JCSPNetworkException * Thrown if something happens in the underlying architecture * @throws PoisonException * Thrown if the channel has been poisoned. */ public void write(Object object) throws JCSPNetworkException, PoisonException { synchronized (this) { this.chan.write(object); } } /** * Writes asynchronously to the underlying channel. * * @param object * The object to write to the channel * @throws JCSPNetworkException * Thrown if something happens in the underlying architecture * @throws PoisonException * Thrown is the channel has been poisoned */ public void asyncWrite(Object object) throws JCSPNetworkException, PoisonException { synchronized (this) { this.chan.asyncWrite(object); } } /** * Removes the channel from the ChannelManager, and sets the state to DESTROYED */ public void destroy() { synchronized (this) { this.chan.destroy(); } } /** * Sets the underlying message filter * * @param encoder * The new message filter to use */ public void setEncoder(FilterTx encoder) { synchronized (this) { this.chan.setEncoder(encoder); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/BarrierManager.java0000644000000000000000000000752611072626250017551 0ustar package org.jcsp.net2; import java.util.Hashtable; /** * Manages the networked Barriers in the system. This object wraps a Hashtable containing the NetBarrier data objects, * and manages the allocation and removal of NetBarrier front ends within the JCSP networking architecture. For * information on the NetBarrier, see the appropriate documentation. * * @see org.jcsp.net2.NetBarrier * @author Kevin Chalmers */ final class BarrierManager { /** * The index for the next Barrier to be created. We start at 50 as it allows us to have up to 50 default Barriers * with set numbers. */ private static int index = 50; /** * The table containing the Barriers. An Integer (object wrapped int) is used as the key, and the BarrierData as the * value. */ private final Hashtable barriers = new Hashtable(); /** * Singleton instance of the BarrierManager */ private static BarrierManager instance = new BarrierManager(); /** * Private default constructor. Used for the singleton instance. */ private BarrierManager() { // Empty constructor } /** * Allows getting of the singleton instance. * * @return The singleton instance of the BarrierManager */ static BarrierManager getInstance() { return instance; } /** * Allocates a new number to the Barrier, and stores it in the table. * * @param bd * The BarrierData for the Barrier */ synchronized void create(BarrierData bd) { // First allocate the next available number for the Barrier index (VBN). Integer objIndex = new Integer(index); while (this.barriers.get(objIndex) != null) objIndex = new Integer(++index); // Now set the index of the BarrierData to the required index bd.vbn = index; // And add the BarrierData at the given index in the Hashtable this.barriers.put(objIndex, bd); // Increment the index for the next allocation index++; } /** * Stores a barrier with the given index in the table. * * @param idx * The index to use for the barrier * @param bd * The BarrierData representing the barrier * @throws IllegalArgumentException * If a barrier of the given index already exists. */ synchronized void create(int idx, BarrierData bd) throws IllegalArgumentException { Integer objIndex = new Integer(idx); // First, ensure that no barrier of the given index already exists. If it does, throw an exception if (this.barriers.get(objIndex) != null) throw new IllegalArgumentException("Barrier of given number already exists."); // Now allocate the index to the BarrierData object bd.vbn = idx; // And put the new barrier into the list of barriers, and increment the next index if necessary this.barriers.put(objIndex, bd); if (idx == BarrierManager.index) BarrierManager.index++; } /** * Retrieves a barrier from the table * * @param idx * Index in the table to retrieve the barrier from. * @return The BarrierData object for the barrier. */ BarrierData getBarrier(int idx) { Integer objIndex = new Integer(idx); return (BarrierData)this.barriers.get(objIndex); } /** * Removes the given barrier from the table of barriers. * * @param data * The BarrierData object of the barrier to be removed */ void removeBarrier(BarrierData data) { Integer objIndex = new Integer(data.vbn); this.barriers.remove(objIndex); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NodeFactory.java0000644000000000000000000000170011072626250017071 0ustar package org.jcsp.net2; /** * Used to initialise a Node by connecting to the CNS. This approach is now deprecated. To initialise a Node now: *

* * NodeAddress localAddress = ...;
* NodeAddress nodeServerAddr = ...;
* Node.getInstance().init(localAddress);
* CNS.init(nodeServerAddr);
* BNS.init(nodeServerAddr);
*
*

* * @see Node * @author Kevin Chalmers */ public abstract class NodeFactory { /** * The NodeAddress where the CNS / BNS is located */ protected NodeAddress cnsAddress; /** * Initialises a Node * * @param node * The Node to initialise * @return A new NodeAddress for the Node * @throws JCSPNetworkException * Thrown if something goes wrong during the initialisation */ protected abstract NodeAddress initNode(Node node) throws JCSPNetworkException; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ConnectionData.java0000644000000000000000000000037511072626250017554 0ustar package org.jcsp.net2; import org.jcsp.lang.ChannelOutput; final class ConnectionData { int vconnn = -1; byte state = ConnectionDataState.INACTIVE; ChannelOutput toConnection = null; ChannelOutput openServer = null; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetAltingChannelInput.java0000644000000000000000000000170611072626250021060 0ustar package org.jcsp.net2; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.AltingChannelInputWrapper; /** * A NetChannelInput that may be used as a guard. This class describes the abstract interface of such a channel. To * create an instance of this class, use the standard NetChannel factory, or the CNS. For information on the usage of * this object, see AltingChannelInput * * @see AltingChannelInput * @see org.jcsp.lang.ChannelInput * @see NetChannelInput * @see NetChannel * @author Quickstone Technologies */ public abstract class NetAltingChannelInput extends AltingChannelInputWrapper implements NetChannelInput { /** * Creates a new NetAltingChannelInput, with the given channel as the guard * * @param in * The channel that is used within the alternative */ protected NetAltingChannelInput(AltingChannelInput in) { super(in); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetAltingConnectionClient.java0000644000000000000000000003240311072626250021724 0ustar package org.jcsp.net2; import java.io.IOException; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.AltingConnectionClient; import org.jcsp.lang.Any2OneChannel; import org.jcsp.lang.Channel; import org.jcsp.lang.ChannelOutput; import org.jcsp.util.InfiniteBuffer; public final class NetAltingConnectionClient extends AltingConnectionClient implements NetConnectionClient { private final AltingChannelInput in; private final ChannelOutput toLinkTX; private final Link linkConnectedTo; private final NetConnectionLocation serverLocation; private final NetConnectionLocation localLocation; private final ConnectionData localConnection; private final boolean isLocal; private final NetworkMessageFilter.FilterTx outputFilter; private final NetworkMessageFilter.FilterRx inputFilter; private final ConnectionData data; static NetAltingConnectionClient create(NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX) throws JCSPNetworkException { // Create the connection data structure ConnectionData data = new ConnectionData(); // Create channel linking this to the Link level. This channel is used to receive response and // acknowledgement messages Any2OneChannel chan = Channel.any2one(new InfiniteBuffer()); data.toConnection = chan.out(); // Set state of connection data.state = ConnectionDataState.CLIENT_STATE_CLOSED; ConnectionManager.getInstance().create(data); ChannelOutput toLink; if (loc.getNodeID().equals(Node.getInstance().getNodeID())) { toLink = ConnectionManager.getInstance().getConnection(loc.getVConnN()).toConnection; return new NetAltingConnectionClient(chan.in(), toLink, null, data, loc, filterTX, filterRX); } Link link = LinkManager.getInstance().requestLink(loc.getNodeID()); if (link == null) { link = LinkFactory.getLink(loc.getNodeID()); } toLink = link.getTxChannel(); return new NetAltingConnectionClient(chan.in(), toLink, link, data, loc, filterTX, filterRX); } private NetAltingConnectionClient(AltingChannelInput input, ChannelOutput toLink, Link link, ConnectionData connData, NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX) { super(input); this.toLinkTX = toLink; this.in = input; this.data = connData; this.serverLocation = loc; this.localLocation = new NetConnectionLocation(Node.getInstance().getNodeID(), connData.vconnn); this.outputFilter = filterTX; this.inputFilter = filterRX; if (link != null) { this.linkConnectedTo = link; // TODO: registration stuff this.isLocal = false; this.localConnection = null; } else { this.isLocal = true; this.localConnection = ConnectionManager.getInstance().getConnection(this.serverLocation.getVConnN()); this.linkConnectedTo = null; } } public boolean isOpen() throws IllegalStateException, JCSPNetworkException { if (this.data.state == ConnectionDataState.CLIENT_STATE_MADE_REQ) throw new IllegalStateException("Can only call isOpen after a reply has been received from the server"); if (this.data.state == ConnectionDataState.DESTROYED) throw new JCSPNetworkException("Client connection end has been destroyed"); if (this.data.state == ConnectionDataState.BROKEN) throw new JCSPNetworkException("Client connection end has broken"); return this.data.state == ConnectionDataState.CLIENT_STATE_OPEN; } public Object reply() throws IllegalStateException, JCSPNetworkException { if (this.data.state != ConnectionDataState.CLIENT_STATE_MADE_REQ) throw new IllegalStateException("Can only call reply() after a request()"); if (this.data.state == ConnectionDataState.DESTROYED) throw new JCSPNetworkException("Client connection end has been destroyed"); if (this.data.state == ConnectionDataState.BROKEN) throw new JCSPNetworkException("Client connection end has broken"); while (true) { NetworkMessage msg = (NetworkMessage)this.in.read(); try { synchronized (this.data) { switch (msg.type) { case NetworkProtocol.REPLY: { Object toReturn = this.inputFilter.filterRX(msg.data); NetworkMessage ack = new NetworkMessage(); ack.type = NetworkProtocol.REPLY_ACK; ack.attr1 = msg.attr2; ack.attr2 = -1; this.toLinkTX.write(ack); this.data.state = ConnectionDataState.CLIENT_STATE_OPEN; return toReturn; } case NetworkProtocol.REPLY_AND_CLOSE: { Object toReturn = this.inputFilter.filterRX(msg.data); NetworkMessage ack = new NetworkMessage(); ack.attr1 = msg.attr2; ack.attr2 = -1; this.toLinkTX.write(ack); this.data.state = ConnectionDataState.CLIENT_STATE_CLOSED; return toReturn; } case NetworkProtocol.LINK_LOST: { this.data.state = ConnectionDataState.BROKEN; ConnectionManager.getInstance().removeConnection(this.data); throw new JCSPNetworkException("Link to server Node was lost. Reply cannot complete"); } case NetworkProtocol.REJECT_CONNECTION: { this.data.state = ConnectionDataState.BROKEN; ConnectionManager.getInstance().removeConnection(this.data); throw new JCSPNetworkException("Server connection rejected previous request"); } default: { this.data.state = ConnectionDataState.BROKEN; ConnectionManager.getInstance().removeConnection(this.data); Node.err.log(this.getClass(), "Connection " + this.data.vconnn + " received unexpected message"); throw new JCSPNetworkException("NetAltingConnectionClient received unexpected message"); } } } } catch (IOException ioe) { throw new JCSPNetworkException("Incoming message was corrupted"); } } } public void request(Object obj) throws IllegalStateException, JCSPNetworkException { if (this.data.state == ConnectionDataState.CLIENT_STATE_MADE_REQ) throw new IllegalStateException("Cannot call request(Object) twice without calling reply()"); if (this.data.state == ConnectionDataState.DESTROYED) throw new JCSPNetworkException("Client connection end has been destroyed"); if (this.data.state == ConnectionDataState.BROKEN) throw new JCSPNetworkException("Client connection end has broken"); if (this.in.pending()) { NetworkMessage msg = (NetworkMessage)this.in.read(); synchronized (this.data) { if (msg.type == NetworkProtocol.LINK_LOST) { this.data.state = ConnectionDataState.BROKEN; ConnectionManager.getInstance().removeConnection(this.data); throw new JCSPNetworkException("Link to server Node lost. Send cannot complete"); } Node.err.log(this.getClass(), "Connection " + this.data.vconnn + " reports unexpected message"); throw new JCSPNetworkException("NetAltingConnecionClient received an unexpected message"); } } NetworkMessage msg = new NetworkMessage(); if (this.data.state == ConnectionDataState.CLIENT_STATE_CLOSED) { msg.type = NetworkProtocol.OPEN; } else { msg.type = NetworkProtocol.REQUEST; } msg.attr1 = this.serverLocation.getVConnN(); msg.attr2 = this.data.vconnn; try { msg.data = this.outputFilter.filterTX(obj); synchronized (this.data) { this.data.state = ConnectionDataState.CLIENT_STATE_MADE_REQ; } if (!this.isLocal) { this.toLinkTX.write(msg); } else { synchronized (this.localConnection) { switch (this.localConnection.state) { case ConnectionDataState.SERVER_STATE_CLOSED: case ConnectionDataState.SERVER_STATE_OPEN: case ConnectionDataState.SERVER_STATE_RECEIVED: msg.toLink = this.data.toConnection; this.localConnection.openServer.write(msg); break; default: this.data.state = ConnectionDataState.BROKEN; ConnectionManager.getInstance().removeConnection(this.data); throw new JCSPNetworkException("Connection rejected during request"); } } } } catch (IOException ioe) { throw new JCSPNetworkException("Error when trying to convert the message for sending"); } NetworkMessage reply = (NetworkMessage)this.in.read(); if (reply.type == NetworkProtocol.REJECT_CONNECTION) { this.data.state = ConnectionDataState.BROKEN; ConnectionManager.getInstance().removeConnection(this.data); throw new JCSPNetworkException("Connection rejected during request"); } else if (reply.type == NetworkProtocol.LINK_LOST) { this.data.state = ConnectionDataState.BROKEN; ConnectionManager.getInstance().removeConnection(this.data); throw new JCSPNetworkException("Link to server Node was lost. Request cannot complete"); } else if (reply.type == NetworkProtocol.REQUEST_ACK) { return; } else { Node.err.log(this.getClass(), "Connection " + this.data.vconnn + " reports unexpected message."); throw new JCSPNetworkException("NetAltingConnectionClient received an unexpected message"); } } public void destroy() { synchronized (this.data) { this.data.state = ConnectionDataState.DESTROYED; ConnectionManager.getInstance().removeConnection(this.data); // TODO: deregistration from link // Deal with left over messages while (this.in.pending()) { NetworkMessage msg = (NetworkMessage)this.in.read(); switch (msg.type) { case NetworkProtocol.REPLY: case NetworkProtocol.REPLY_AND_CLOSE: { NetworkMessage reply = new NetworkMessage(); reply.type = NetworkProtocol.REJECT_CONNECTION; reply.attr1 = msg.attr2; reply.attr2 = -1; this.toLinkTX.write(reply); break; } case NetworkProtocol.REQUEST_ACK: { NetworkMessage reply = new NetworkMessage(); reply.type = NetworkProtocol.REJECT_CONNECTION; reply.attr1 = msg.attr1; reply.attr2 = -1; this.toLinkTX.write(reply); break; } default: break; } } } } public NetLocation getLocation() { return this.serverLocation; } NetConnectionLocation getLocalLocation() { return this.localLocation; } final ConnectionData getConnectionData() { return this.data; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/Link.java0000644000000000000000000014541211072626250015562 0ustar package org.jcsp.net2; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import org.jcsp.lang.Any2OneChannel; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Channel; import org.jcsp.lang.ChannelInput; import org.jcsp.lang.ChannelOutput; import org.jcsp.lang.Parallel; import org.jcsp.lang.ProcessManager; /** * Abstract class representing a Link. This class defines the two processes (Link TX, Link RX) where the network * protocol is of key importance. Specific technology protocols (e.g. TCP/IP) must extend this class, providing the * necessary streams for operation, and also overriding the methods connect, createResources and destroyResources, which * will have specific implementations dependent on the underlying technology. Everything else should operate as defined * in this class. * * @see org.jcsp.net2.NetworkProtocol * @author Kevin Chalmers */ public abstract class Link implements CSProcess { /** * A flag used to indicate whether the Link is connected or not. This flag is set normally during the connect * operation, but may be done within the constructor. If not set during the constructor, and if connect is not * called to set the flag to true, then when the process is run connect will be called. */ protected boolean connected = false; /** * The incoming stream for the connection. This must be created by the specific protocol implementation. */ protected DataInputStream rxStream; /** * The outgoing stream for the connection. This must be created by the specific protocol implementation. */ protected DataOutputStream txStream; /** * The channel connected to the Link Tx process. This is used by channels, barriers, and the Link Rx to send * messages to the node this Link is connected to. */ private final Any2OneChannel txChannel = Channel.any2one(); /** * The NodeID of the opposite end of the connection. This should be set either during construction, or during the * connect method of a child class. */ protected NodeID remoteID; /** * Link priority in the system. This is a publicly accessible value that can be set by a user. */ public static int LINK_PRIORITY = ProcessManager.PRIORITY_NORM; /** * Link priority for this Link. This is exposed to child classes to allow specific Link priorities for different * Link types. */ protected int priority = Link.LINK_PRIORITY; /** * This Hashtable is used to keep track of the current output channels that are connected to this Link. In the * outcome of a connection failure to the remote Node, the Link uses this table to notify all registered output * ends, allowing them to throw an exception instead of deadlocking. */ private Hashtable connectedOutputs = new Hashtable(); /** * This Hashtable is used to keep track of the current barriers that are connected to this Link. In the outcome of a * connection failure to the remote Node, the Link uses this table to notify all registered barriers, allowing them * to throw an exception instead of deadlocking. */ private Hashtable connectedBarriers = new Hashtable(); /** * Returns the NodeID of the connected Link. * * @return NodeID of the connected Link. */ public final NodeID getRemoteNodeID() { return this.remoteID; } /** * Gets the channel that is connected to the Link Tx process. * * @return The ChannelOutput used to communicate with the Link Tx. */ protected final ChannelOutput getTxChannel() { return this.txChannel.out(); } /** * Connects to the remote Node. This must be overridden by a child class implementation. * * @return True if the connection succeeds, false otherwise. * @throws JCSPNetworkException * Thrown if the connection fails. */ public abstract boolean connect() throws JCSPNetworkException; /** * Creates the resources (if any) required for the Node. These could be set up during construction, but if not, this * method is called immediately after connect within the run method. Child implementations should override this * method. * * @return True if resources were created OK, false otherwise. * @throws JCSPNetworkException * Thrown if a problem occurs creating the resources. */ protected abstract boolean createResources() throws JCSPNetworkException; /** * Destroys any used resources. This is called whenever a Node fails. Particular implementations must overwrite this * method. */ protected abstract void destroyResources(); /** * Registers the Link with the LinkManager * * @return True if Link was registered, false otherwise. */ public final boolean registerLink() { return LinkManager.getInstance().registerLink(this); } /** * Marks the Link as lost within the LinkManager. */ protected final void lostLink() { // Acquire a lock on the Link. We wish to stop any more channel or barrier registrations, // so therefore we stop any more happening until the Link lost operation is completed. synchronized (this) { // First set connected to false, and inform the LinkManager this.connected = false; LinkManager.getInstance().lostLink(this); // Iterate through the registered channels and send them all LINK_LOST messages. for (Iterator iter = this.connectedOutputs.values().iterator(); iter.hasNext();) { // Really we could send just the same LINK_LOST message to all channels. Aliasing should not be a // concern // as the channel will effectively be broken after this ChannelOutput toChannel = ((ChannelData)iter.next()).toChannel; NetworkMessage message = new NetworkMessage(); message.type = NetworkProtocol.LINK_LOST; toChannel.write(message); } // Clear the table of registered channels, and then set it to null. this.connectedOutputs.clear(); this.connectedOutputs = null; // Now do the same for the barriers, sending LINK_LOST to each. for (Iterator iter = this.connectedBarriers.values().iterator(); iter.hasNext();) { ChannelOutput toBar = ((BarrierData)iter.next()).toBarrier; NetworkMessage message = new NetworkMessage(); message.type = NetworkProtocol.LINK_LOST; toBar.write(message); } // Clear the table of registered barriers, and then set it to null. this.connectedBarriers.clear(); this.connectedBarriers = null; } } /** * Register a channel with the Link. * * @param data * The ChannelData object representing the channel */ void registerChannel(ChannelData data) { // Acquire a lock on the Link. This is to ensure that we don't try and register when the Link is going down. synchronized (this) { // Check that the Link is still up. If it isn't, then we inform the channel. // *IMPLEMENTATION NOTE*: Technically, we could either throw an exception or return a error message here. // (for example false). However, this means that the user would have to worry about this outcome in a catch // block. The creation methods for channels return channel objects, so the only other option would be to // return null. This would lead to confusion if the user did not know that null was a possible return value. // It is better to send the LINK_LOST message to the channel, and allow normal error handling during a write // operation. Therefore, if the user wishes to ensure that a link is up, it is no different than a normal // catch on JCSPNetworkException. if (!this.connected) { NetworkMessage message = new NetworkMessage(); message.type = NetworkProtocol.LINK_LOST; data.toChannel.write(message); } // Otherwise the Link can take the channel. Add the channel to the table of registered channels. else { Integer objIndex = new Integer(data.vcn); this.connectedOutputs.put(objIndex, data); } } } /** * Unregisters and removes the channel from the Link. * * @param data * The ChannelData object representing the channel. */ void deRegisterChannel(ChannelData data) { // Acquire a lock on the Link. synchronized (this) { // All we need to do is ensure that the Hashtable of connected channels still exists. It is unlikely that // this occurrence can happen, but destroy may be called on the channel as the Link is going down. if (this.connectedOutputs != null) { // Remove the channel from the registered channels Hashtable Integer objIndex = new Integer(data.vcn); this.connectedOutputs.remove(objIndex); } } } /** * Registers a barrier with the Link * * @param data * The barrier to register with the Link */ void registerBarrier(BarrierData data) { // Acquire lock on the Link synchronized (this) { // Check that the Link is still up. If it isn't, then we inform the Barrier. // *IMPLEMENTATION NOTE*: Technically, we could either throw an exception or return a error message here. // (for example false). However, this means that the user would have to worry about this outcome in a catch // block. The creation methods for barriers return barrier objects, so the only other option would be to // return null. This would lead to confusion if the user did not know that null was a possible return value. // It is better to send the LINK_LOST message to the barrier, and allow normal error handling during an // operation. Therefore, if the user wishes to ensure that a link is up, it is no different than a normal // catch on JCSPNetworkException. if (!this.connected) { NetworkMessage message = new NetworkMessage(); message.type = NetworkProtocol.LINK_LOST; data.toBarrier.write(message); } else { // Otherwise add the barrier to the connected Hashtable of connected barriers Integer objIndex = new Integer(data.vbn); this.connectedBarriers.put(objIndex, data); } } } /** * Unregisters a barrier with the Link * * @param data * The BarrierData representing the Barrier to unregister */ void deRegisterBarrier(BarrierData data) { // Acquire a lock on the Link synchronized (this) { // First we check if the connectedBarriers is not equal to null. If it is, then we can assume that the Link // has gone down. In such a circumstance, we ignore the deregistration. The interacting barrier is already // going down. if (this.connectedBarriers != null) { Integer objIndex = new Integer(data.vbn); this.connectedBarriers.remove(objIndex); } } } /** * The run method for the process. This will connect the Link (if necessary) and then start the Tx and Rx Loops. */ public final void run() { // Check if connected, and if not try and connect. if (!this.connected) { try { if (!connect()) // Failed to connect. Stop Link process return; if (!createResources()) // Failed to create resources. Stop Link process. return; } catch (JCSPNetworkException jne) { // Something went wrong during connection. Stop Link System.out.println(jne.getMessage()); jne.printStackTrace(); Node.err.log(this.getClass(), "Failed to connect Link to " + this.remoteID); return; } } // Create and start Tx and Rx loops. TxLoop txLoop = new TxLoop(this.txChannel.in(), this.txStream); RxLoop rxLoop = new RxLoop(this.txChannel.out(), this.rxStream); ProcessManager txProc = new ProcessManager(txLoop); ProcessManager rxProc = new ProcessManager(rxLoop); txProc.setPriority(this.priority); rxProc.setPriority(this.priority); CSProcess[] processes = { txProc, rxProc }; new Parallel(processes).run(); // At this point the Link has gone down. Should we be accepting messages? This should have really been // handled during the destroy resources stage. But just in case we send LINK_LOST messages appropriately. while (true) { NetworkMessage linkLost = new NetworkMessage(); linkLost.type = NetworkProtocol.LINK_LOST; NetworkMessage msg = (NetworkMessage)this.txChannel.in().read(); switch (msg.type) { // We only respond to certain message types. case NetworkProtocol.SEND: case NetworkProtocol.ASYNC_SEND: // Get the appropriate channel ChannelData chan = ChannelManager.getInstance().getChannel(msg.attr2); chan.toChannel.write(linkLost); break; case NetworkProtocol.SYNC: // Get the appropriate barrier BarrierData bar = BarrierManager.getInstance().getBarrier(msg.attr2); bar.toBarrier.write(linkLost); break; } } } /** * The TxLoop for the Link. This could be implemented as a synchronized method call. * * @author Kevin Chalmers */ final class TxLoop implements CSProcess { /** * The input channel to the TX process. Channels and Barriers send outgoing messages via this channel */ private final ChannelInput input; /** * The output stream connecting to the remote node's input stream. */ private final DataOutputStream outputStream; /** * Constructor to create the TX part of the Link * * @param in * The channel connecting into the Link TX from the various channels and barriers * @param stream * The output stream connected to the remote node */ TxLoop(ChannelInput in, DataOutputStream stream) { this.input = in; this.outputStream = stream; } /** * The run loop of the TX process */ public void run() { try { // Loop forever. while (true) { // Read in next message NetworkMessage msg = (NetworkMessage)this.input.read(); // Write message to the stream. this.outputStream.writeByte(msg.type); this.outputStream.writeInt(msg.attr1); this.outputStream.writeInt(msg.attr2); // Check if message has data element if (msg.type == NetworkProtocol.SEND || msg.type == NetworkProtocol.ARRIVED || msg.type == NetworkProtocol.ASYNC_SEND) { // Write data element this.outputStream.writeInt(msg.data.length); this.outputStream.write(msg.data); } // Flush the stream. this.outputStream.flush(); } } catch (IOException ioe) { // Something went wrong during I/O. Destroy resources. destroyResources(); } } } /** * The RxLoop for the Link. * * @author Kevin Chalmers */ final class RxLoop implements CSProcess { /** * This is the channel connected to the Link's TX process. We retain this in the RX process for messages such as * reject to be sent directly back to the remote node, and to ease the communication mechanism. Any message that * requires an acknowledgement has this channel attached to it for simplicity. */ private final ChannelOutput toTxProcess; /** * The input stream receiving messages from the opposite remote node */ private final DataInputStream inputStream; /** * This is the list of barrier server ends that this Link has received an enroll for. We retain this to allow * server ends to be notified when the Link goes down, letting them know that one of the client ends have gone */ private final ArrayList incomingEnrolledBarriers = new ArrayList(); /** * Constructor for the RX part of the Link * * @param out * The Channel connected to the TX part of the Link * @param stream * The input stream used to receive messages upon */ RxLoop(ChannelOutput out, DataInputStream stream) { this.toTxProcess = out; this.inputStream = stream; } /** * The point here is to try and deal with any message that may come into the Node. This involves a great deal of * choice, and therefore this run method looks quite complicated. However, splitting the switch statements into * parts should allow a good idea of exactly what is going on. */ public void run() { try { // Declare the reference for the possible channel and barrier we are may operate on ChannelData data = null; BarrierData bar = null; // Loop forever (or until something goes wrong) while (true) { // Read in the next message from the stream byte type = this.inputStream.readByte(); int attr1 = this.inputStream.readInt(); int attr2 = this.inputStream.readInt(); // Reconstruct the message object NetworkMessage msg = new NetworkMessage(); msg.type = type; msg.attr1 = attr1; msg.attr2 = attr2; // Now operate on the message switch (msg.type) { // ------------------------------------------------------------------------ // *** SEND & ASYNC_SEND *** // ------------------------------------------------------------------------ // Data sent to the link from another Node. Deal with // the message case NetworkProtocol.SEND: case NetworkProtocol.ASYNC_SEND: // First also read the data portion of the message // Read the size int size = this.inputStream.readInt(); // Declare a buffer of the correct size byte[] bytes = new byte[size]; // Now keeping reading from the stream until the buffer is filled int read = 0; while (read < size) read += this.inputStream.read(bytes, read, size - read); // Set the data part of the message to the buffer msg.data = bytes; // Attach the channel to allow the acknowledge message to be sent later. msg.toLink = this.toTxProcess; // Get the channel we are dealing with. data = ChannelManager.getInstance().getChannel(msg.attr1); // Now check if the channel does exist. If the previous operation returned null, we can // determine that // it does not. if (data != null) { // The channel does exist. Now we must operate on the channel dependent on its state. We // must ensure that this state can't change while we are doing this, so we lock onto the // ChannelData object. // Acquire lock on the channel data synchronized (data) { // Operate on message based on the current state of the channel. switch (data.state) { // Channel is OK for input, so pass on the message case ChannelDataState.OK_INPUT: data.toChannel.write(msg); break; // Channel is currently migrating. Still pass on the message. When the Channel // arrives, the REQUEST still needs to occur before this channel is passed on. case ChannelDataState.MOVING: data.toChannel.write(msg); break; // Channel has moved. Still pass on the message. case ChannelDataState.MOVED: data.toChannel.write(msg); break; // Channel has been poisoned. Spread the poison to the sender. case ChannelDataState.POISONED: // Create a new poison NetworkMessage NetworkMessage poison = new NetworkMessage(); poison.type = NetworkProtocol.POISON; // Destination is the source of the incoming message poison.attr1 = msg.attr2; // Send the poison level poison.attr2 = data.poisonLevel; // Then write the message to the TX process so it can send it to the remote // Link msg.toLink.write(poison); break; // In all other cases we reject the message. The sender is informed and can act // accordingly. default: // Create a new reject NetworkMessage NetworkMessage reject = new NetworkMessage(); reject.type = NetworkProtocol.REJECT_CHANNEL; // Destination is source of incoming message reject.attr1 = msg.attr2; // Attribute 2 unnecessary reject.attr2 = -1; // Write reject to the TX process so it can send it to the remote Link msg.toLink.write(reject); break; } } } else { // Channel does not exist. Reject the message so the sender can act accordingly. NetworkMessage reject = new NetworkMessage(); reject.type = NetworkProtocol.REJECT_CHANNEL; reject.attr1 = msg.attr2; reject.attr2 = -1; msg.toLink.write(reject); } break; // ------------------------------------------------------------------------ // *** ACK *** // ------------------------------------------------------------------------ // Acknowledgement message received. Must inform sending channel. case NetworkProtocol.ACK: // Retrieve the channel data = ChannelManager.getInstance().getChannel(msg.attr1); // Check if the channel exists. The previous operation will set data to null if no channel // of that index has been created. if (data != null) { // The channel exists. We need to acquire a lock on the channel state to ensure it does // not change as we operate on it. // Acquire lock on data state synchronized (data) { // Now behave according to the channel data state switch (data.state) { // Channel is OK_OUTPUT, acknowledge channel. case ChannelDataState.OK_OUTPUT: data.toChannel.write(msg); break; // Channel is not an output, or is destroyed, poisoned, etc. In this case we // can just ignore the message as there is nothing to do. The receiving end is // attempting to acknowledge a channel that never sent it a message. Could be // considered dangerous. default: // Ignore message in all other cases break; } } } else { // Otherwise Channel doesn't exist. Ignore message } break; // ------------------------------------------------------------------------ // *** ENROLL *** // ------------------------------------------------------------------------ // Enrolment on a barrier received. case NetworkProtocol.ENROLL: // Retrieve the barrier bar = BarrierManager.getInstance().getBarrier(msg.attr1); // Now check that the barrier exists. The previous operation would have set bar to null if // no channel // of that index exists if (bar != null) { // Barrier exists. We need to lock the state while we interact to avoid conflicts // Acquire lock on barrier data state synchronized (bar) { // Now behave according to the state of the barrier switch (bar.state) { // Barrier is in OK state, and is a server. Enroll with barrier. case BarrierDataState.OK_SERVER: // Forward the enrolment bar.toBarrier.write(msg); // Add the barrier to the incomingEnrolledBarriers this.incomingEnrolledBarriers.add(bar); break; // Barrier is other state. Reject the enroll and let the enrolling process // handle it. default: // Create the reject message NetworkMessage reject = new NetworkMessage(); reject.type = NetworkProtocol.REJECT_BARRIER; // Destination of reject is source of incoming message reject.attr1 = msg.attr2; // Attribute 2 is not used reject.attr2 = -1; // Send message to the TX process of the Link this.toTxProcess.write(reject); break; } } } else { // Barrier does not exist. Reject message and let enrolling process handle it. NetworkMessage reject = new NetworkMessage(); reject.type = NetworkProtocol.REJECT_BARRIER; reject.attr1 = msg.attr2; reject.attr2 = -1; this.toTxProcess.write(reject); } break; // ------------------------------------------------------------------------ // *** RESIGN *** // ------------------------------------------------------------------------ // Resignation from a barrier received. case NetworkProtocol.RESIGN: // Retrieve the barrier. bar = BarrierManager.getInstance().getBarrier(msg.attr1); // Check if the Barrier exists. The previous operation returns null if no barrier of the // given // index exists. if (bar != null) { // The Barrier exists. We now acquire a lock on the Barrier to avoid it changing while // we // operate on it. // Acquire lock on the barrier data state synchronized (bar) { // Now behave based on the state of the barrier switch (bar.state) { // Barrier is in OK_SERVER state. Attempt resign from barrier. case BarrierDataState.OK_SERVER: // First check that a enrolment occurred previously and remove the enrolled // barrier from the list. This operation returns true if the object was // successfully removed if (!this.incomingEnrolledBarriers.remove(bar)) { // The barrier was not previously enrolled, therefore do not resign from // the barrier. We *COULD* reject the resignation here, but that would // be // pointless. Simply continue. } else { // Forward the resignation to the barrier bar.toBarrier.write(msg); } break; // Barrier is other state. This can be ignored. From the point of view of the // resigner, no different operation has occurred. It can carry on as normal. // Could be considered dangerous. default: break; } } } // Barrier doesn't exist. Ignore. break; // ------------------------------------------------------------------------ // *** SYNC *** // ------------------------------------------------------------------------ // Sync message for a barrier received. case NetworkProtocol.SYNC: // Retrieve the barrier bar = BarrierManager.getInstance().getBarrier(msg.attr1); // Check that the barrier exists. The previous operation returns null if no barrier of the // given // index exists. if (bar != null) { // The barrier exists. We need to operate on it based on its state. Therefore we need to // ensure // that the state doesn't change as we do so, and must acquire a lock on the barrier // Acquire lock on barrier state synchronized (bar) { // Attach the output channel to the txLink so when barrier is ready it can inform // the networked barriers connected to it. msg.toLink = this.toTxProcess; // Now we must behave based on the state of the barrier switch (bar.state) { // Barrier is in OK_SERVER state. Pass SYNC onto the barrier. case BarrierDataState.OK_SERVER: // TODO: Should we check that this Link is enrolled? If we are doing this, // the ArrayList structure will have to be re-thought to something faster. // Forward the SYNC bar.toBarrier.write(msg); break; // Barrier is not in OK_SERVER state. Reject message default: // Create reject message NetworkMessage reject = new NetworkMessage(); reject.type = NetworkProtocol.REJECT_BARRIER; // Destination is source of previous message reject.attr1 = msg.attr2; // Attribute 2 is not required reject.attr2 = -1; // Write reject message to the TX process this.toTxProcess.write(reject); break; } } } else { // Barrier doesn't exist. Reject the message. NetworkMessage reject = new NetworkMessage(); reject.type = NetworkProtocol.REJECT_BARRIER; reject.attr1 = msg.attr2; reject.attr2 = -1; this.toTxProcess.write(reject); } break; // ------------------------------------------------------------------------ // *** RELEASE *** // ------------------------------------------------------------------------ // Barrier has been released after a sync. Notify the barrier. case NetworkProtocol.RELEASE: // Retrieve the barrier. bar = BarrierManager.getInstance().getBarrier(msg.attr1); // Check and see if the barrier exists. The previous operation returns null if no barrier of // the given index exists if (bar != null) { // We now operate on the barrier based on its state. We therefore need to acquire a lock // on the barrier to ensure the state doesn't change as we do so. // Acquire lock on barrier state synchronized (bar) { // Now behave based on the state of the barrier switch (bar.state) { // Barrier is in OK_CLIENT state. Release the waiting processes. case BarrierDataState.OK_CLIENT: // TODO: Should we be checking that this Link is indeed connected to this // Barrier? This would require the Hashtable of registered barriers to be // passed into this process. // Forward on the message bar.toBarrier.write(msg); break; // Barrier is not in OK_CLIENT state. Ignore message. From the point of view of // the releaser no difference is apparent. It may be worth in future informing // the releaser that this Barrier is broken so it can reduce the number of // enrolled. default: break; } } } // Barrier doesn't exist. Ignore. break; // ------------------------------------------------------------------------ // *** REJECT_CHANNEL *** // ------------------------------------------------------------------------ // A channel message has been rejected. Inform the Channel case NetworkProtocol.REJECT_CHANNEL: // Retrieve the channel data = ChannelManager.getInstance().getChannel(msg.attr1); // Now check that the channel exists. The previous operation returns null if no channel // of the given index exists if (data != null) { // We now behave based on the state of the channel. The state cannot change as we do // this, so we must ensure it does not change // Acquire lock on channel state synchronized (data) { // Behave based on state of the channel switch (data.state) { // Channel is in OK_OUTPUT state. Reject the message sent by it. case ChannelDataState.OK_OUTPUT: data.toChannel.write(msg); break; // Channel is in other state. We can ignore the message. The rejector is // rejecting anyway, so there is no need to inform that this channel would also // reject. default: break; } } } // Barrier doesn't exist, ignore message. break; // ------------------------------------------------------------------------ // *** REJECT_BARRIER *** // ------------------------------------------------------------------------ // A barrier message has been rejected. case NetworkProtocol.REJECT_BARRIER: // Retrieve the barrier bar = BarrierManager.getInstance().getBarrier(msg.attr1); // Now check if the barrier exists. The previous operation returns null if no barrier // exists at the given index. if (bar != null) { // Barrier exists. We now operate on it based on its state. We must ensure that the // state doesn't change during this time and must lock the barrier state // Acquire lock on barrier state synchronized (bar) { // Not behave based on the state of the barrier switch (bar.state) { // Barrier is in OK_CLIENT state. Reject the message sent by it. case BarrierDataState.OK_CLIENT: bar.toBarrier.write(msg); break; // Barrier is in other state. We can ignore the message. The rejector is broken // anyway, so there is no need to inform that this barrier is also down. default: break; } } } // Barrier doesn't exist, ignore message. break; // ------------------------------------------------------------------------ // *** MOVED *** // ------------------------------------------------------------------------ // TODO: Bits for mobility case NetworkProtocol.MOVED: break; // ------------------------------------------------------------------------ // *** ARRIVED *** // ------------------------------------------------------------------------ // TODO: Bits for mobility case NetworkProtocol.ARRIVED: break; // ------------------------------------------------------------------------ // *** POISON *** // ------------------------------------------------------------------------ // Poison message received. case NetworkProtocol.POISON: // Retrieve the channel data = ChannelManager.getInstance().getChannel(msg.attr1); // Now check that the channel exists. The previous operation returns // null if no channel of the given index exists if (data != null) { // The channel exists. We need to ensure that the channel does not change // state as we operate on. // Acquire lock on channel data synchronized (data) { // Now behave based on the state of the barrier switch (data.state) { // Channel is in OK state. case ChannelDataState.OK_INPUT: case ChannelDataState.OK_OUTPUT: // We now must check the channels immunity level if (msg.attr2 > data.immunityLevel) { // The poison message is strong enough to poison the channel. // Forward on the message data.toChannel.write(msg); } break; // TODO: Bits for mobility case ChannelDataState.MOVING: break; // TODO: Bits for mobility case ChannelDataState.MOVED: break; // Channel is already poisoned. Check level and forward if necessary. case ChannelDataState.POISONED: if (data.poisonLevel < msg.attr2) data.toChannel.write(msg); break; // Channel is in another state. Ignore message. Poisoner is trying to poison a // channel that is already down. Should be safe to ignore. default: break; } } } // Channel doesn't exist. Ignore message. break; } } } // Something has gone wrong at the the communication layer. Destroy the Link. catch (IOException ioe) { // First destroyResources as appropriate for the implementation destroyResources(); // Now we wish to inform any server ends of a barrier that may have had enrollments via this Link that // the Link is now dead. Iterator iter = this.incomingEnrolledBarriers.iterator(); for (; iter.hasNext();) { BarrierData bar = (BarrierData)iter.next(); NetworkMessage message = new NetworkMessage(); message.type = NetworkProtocol.LINK_LOST; bar.toBarrier.write(message); } this.incomingEnrolledBarriers.clear(); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetLocation.java0000644000000000000000000000145511072626250017102 0ustar /** * */ package org.jcsp.net2; /** * This abstract class defines a data structure that is a location of a networked synchronization mechanism. Currently, * JCSP offers two location structures - NetChannelLocation and NetBarrierLocation. See the relevant documentation for * more information. * * @see NetChannelLocation * @see NetBarrierLocation * @author Kevin Chalmers */ public abstract class NetLocation { /** * Gets the NodeID part of the location structure * * @return the NodeID part of the NetLocation */ public abstract NodeID getNodeID(); /** * Gets the NodeAddress part of the location structure * * @return The NodeAddress part of the NetLocation */ public abstract NodeAddress getNodeAddress(); } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetworkMessage.java0000644000000000000000000000142211072626250017613 0ustar package org.jcsp.net2; import org.jcsp.lang.ChannelOutput; /** * A message received or to be sent via a Link. This is an internal structure to JCSP, and is an object encapsulation of * the messages sent between nodes * * @author Kevin Chalmers */ final class NetworkMessage { /** * The message type, as described in NetworkProtocol. */ byte type = -1; /** * The first attribute of the message. */ int attr1 = -1; /** * The second attribute of the message */ int attr2 = -1; /** * Data sent in the message if relevant. */ byte[] data = null; /** * ChannelOutput to the Link so that acknowledgements can be sent. */ ChannelOutput toLink = null; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/Node.java0000644000000000000000000001062211072626250015544 0ustar package org.jcsp.net2; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Date; import org.jcsp.lang.AltingChannelInput; import org.jcsp.net2.bns.BNS; import org.jcsp.net2.cns.CNS; /** * @author Kevin Chalmers */ public final class Node { /** * */ private NodeID nodeID; /** * */ private boolean initialized = false; /** * */ private NodeKey nk; /** * */ private static Node instance = new Node(); /** * */ public static Logger log = new Logger(); /** * */ public static Logger err = new Logger(); /** * @return The singleton instance of the Node */ public static Node getInstance() { return instance; } /** * @return The NodeID of this Node */ public NodeID getNodeID() { return this.nodeID; } /** * @param aNodeID */ void setNodeID(NodeID aNodeID) { this.nodeID = aNodeID; } /** * */ private Node() { // Empty constructor } /** * @param addr * @return NodeKey for this Node * @throws JCSPNetworkException */ public NodeKey init(NodeAddress addr) throws JCSPNetworkException { return this.init("", addr); } /** * @param name * @param addr * @return NodeKey for this Node * @throws JCSPNetworkException */ public NodeKey init(String name, NodeAddress addr) throws JCSPNetworkException { Node.log.log(this.getClass(), "Node initialisation begun"); if (this.initialized) throw new JCSPNetworkException("Node already initialised"); this.initialized = true; LinkServer.start(addr); this.nodeID = new NodeID(name, addr); this.nk = new NodeKey(); NodeAddress.installProtocol(addr.getProtocol(), addr.getProtocolID()); Node.log.log(this.getClass(), "Node initialisation complete"); return this.nk; } /** * @param factory * @return NodeKey for this Node * @throws JCSPNetworkException */ public NodeKey init(NodeFactory factory) throws JCSPNetworkException { Node.log.log(this.getClass(), "Node initialisation begun"); if (this.initialized) throw new JCSPNetworkException("Node already initialised"); NodeAddress localAddr = factory.initNode(this); this.nodeID = new NodeID("", localAddr); this.initialized = true; this.nk = new NodeKey(); Link toServer = LinkFactory.getLink(factory.cnsAddress); CNS.initialise(toServer.remoteID); BNS.initialise(toServer.remoteID); return this.nk; } /** * @return A channel to receive disconnect events on */ public AltingChannelInput getLinkLostEventChannel() { return LinkManager.getInstance().getLinkLostEventChannel(); } /** * @param stream */ public void setLog(OutputStream stream) { log = new Logger(stream); } /** * @param stream */ public void setErr(OutputStream stream) { err = new Logger(stream); } /** * @author Kevin Chalmers */ public static class Logger { /** * */ private final PrintWriter logger; /** * */ Logger() { this.logger = null; } /** * @param stream */ Logger(OutputStream stream) { this.logger = new PrintWriter(stream); } /** * @param clazz * @param message */ public synchronized void log(Class clazz, String message) { if (this.logger == null) return; Date date = new Date(System.currentTimeMillis()); try { this.logger.println("(" + date.toString() + ")-" + clazz.getName() + ":"); this.logger.println("\t\"" + message + "\""); this.logger.flush(); } catch (Exception e) { // Do nothing } } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/LinkServer.java0000644000000000000000000000262611072626250016750 0ustar package org.jcsp.net2; import org.jcsp.lang.CSProcess; import org.jcsp.lang.ProcessManager; /** * Abstract class defining the LinkServer. * * @author Kevin Chalmers */ public abstract class LinkServer implements CSProcess { /** * @param address * @throws IllegalArgumentException * @throws JCSPNetworkException */ public static final void start(NodeAddress address) throws IllegalArgumentException, JCSPNetworkException { Node.log.log(LinkServer.class, "Attempting to start Link Server on " + address); LinkServer linkServer = address.createLinkServer(); ProcessManager linkServProc = new ProcessManager(linkServer); linkServProc.setPriority(Link.LINK_PRIORITY); linkServProc.start(); Node.log.log(LinkServer.class, "Link Server started on " + address); } /** * @param nodeID * @return The Link connected to the Node with the corresponding NodeID, or null if no such Node exists */ protected final Link requestLink(NodeID nodeID) { return LinkManager.getInstance().requestLink(nodeID); } /** * @param link * @return True if the Link to the Node was successfully registered, false otherwise */ protected final boolean registerLink(Link link) { return LinkManager.getInstance().registerLink(link); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/bns/0000755000000000000000000000000011410045051014563 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net2/bns/BNSNetworkMessageFilter.java0000644000000000000000000001073511072626250022115 0ustar package org.jcsp.net2.bns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.jcsp.net2.NetBarrierLocation; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetworkMessageFilter; /** * This filter is used by the BNS and BNSService to transmit messages between one another in a manner that is platform * independent. This is an internal class to JCSP and is created automatically by the BNS and BNSService. For more * information, see the relevant documentation. * * @see BNS * @see BNSService * @see NetworkMessageFilter * @author Kevin Chalmers */ final class BNSNetworkMessageFilter { /** * The encoding filter used to convert a BNSMessage into bytes * * @author Kevin Chalmers */ static final class FilterTX implements NetworkMessageFilter.FilterTx { /** * The byte stream we will use to retrieve the byte message from */ private final ByteArrayOutputStream baos; /** * the data stream used to write the parts of the BNSMessage to */ private final DataOutputStream dos; /** * Creates a new BNSMessage encoding filter */ FilterTX() { this.baos = new ByteArrayOutputStream(8192); this.dos = new DataOutputStream(this.baos); } /** * Converts a BNSMessage into bytes * * @param obj * A BNSMessage to convert * @return the byte equivalent of the BNSMessage * @throws IOException * Thrown if something goes wrong during the conversion */ public byte[] filterTX(Object obj) throws IOException { // First ensure we have a BNSMessage if (!(obj instanceof BNSMessage)) throw new IOException("Attempted to send a non BNSMessage on a BNSMessage channel"); BNSMessage msg = (BNSMessage)obj; // Now reset the byte stream this.baos.reset(); // Write the parts of the BNSMessage to the stream this.dos.writeByte(msg.type); this.dos.writeBoolean(msg.success); if (msg.serviceLocation != null) this.dos.writeUTF(msg.serviceLocation.toString()); else this.dos.writeUTF("null"); if (msg.location != null) this.dos.writeUTF(msg.location.toString()); else this.dos.writeUTF("null"); this.dos.writeUTF(msg.name); // flush the stream this.dos.flush(); // Get the bytes return this.baos.toByteArray(); } } /** * The filter used to convert an array of bytes back into a BNSMessage * * @author Kevin Chalmers */ static final class FilterRX implements NetworkMessageFilter.FilterRx { /** * The input end of the pipe to read the message back */ private ByteArrayInputStream byteIn; /** * The data input stream used to read in parts of the message */ private DataInputStream dis; /** * Creates a new decoding BNSMessageFilter */ FilterRX() { // Nothing to do. } /** * Decodes a byte array back into a BNSMessage * * @param bytes * The bytes to convert back into a BNSMessage * @return The recreated BNSMessage * @throws IOException * Thrown if something goes wrong during the recreation */ public Object filterRX(byte[] bytes) throws IOException { this.byteIn = new ByteArrayInputStream(bytes); this.dis = new DataInputStream(byteIn); // Recreate the message BNSMessage msg = new BNSMessage(); msg.type = this.dis.readByte(); msg.success = this.dis.readBoolean(); msg.serviceLocation = NetChannelLocation.parse(this.dis.readUTF()); msg.location = NetBarrierLocation.parse(this.dis.readUTF()); msg.name = this.dis.readUTF(); return msg; } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/bns/BNSMessage.java0000644000000000000000000000142111072626250017365 0ustar package org.jcsp.net2.bns; import org.jcsp.net2.NetBarrierLocation; import org.jcsp.net2.NetChannelLocation; /** * A message sent between a BNS and a BNSService. This is an internal structure to JCSP * * @author Kevin Chalmers */ final class BNSMessage { /** * The message type. See BNSMessageProtocol */ byte type = 0; /** * Whether the previous message was successful */ boolean success = false; /** * The location that the BNS must reply to */ NetChannelLocation serviceLocation = null; /** * The location of a resolves or registered barrier */ NetBarrierLocation location = null; /** * The name to register or resolve */ String name = ""; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/bns/BNS.java0000644000000000000000000007252511072626250016075 0ustar package org.jcsp.net2.bns; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import org.jcsp.lang.Alternative; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Guard; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.Link; import org.jcsp.net2.LinkFactory; import org.jcsp.net2.NetAltingChannelInput; import org.jcsp.net2.NetBarrier; import org.jcsp.net2.NetBarrierEnd; import org.jcsp.net2.NetBarrierLocation; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.Node; import org.jcsp.net2.NodeAddress; import org.jcsp.net2.NodeID; /** * This is the main process for the Barrier Name Server. For a more in depth discussion of name servers, see CNS. * * @see org.jcsp.net2.cns.CNS * @see BNSService * @see Node * @author Kevin Chalmers */ public class BNS implements CSProcess { /** * The internal service. This is used by the factory methods. */ private static BNSService service; /** * Flag used to denote if the connection to the BNS has been initialised */ private static boolean initialised = false; /** * Singleton instance of the BNS. Only one may be created on a Node */ private static final BNS instance = new BNS(); /** * Map of registered barriers; name->location */ private final HashMap registeredBarriers = new HashMap(); /** * Map of barriers registered to a Node; NodeID-> */ private final HashMap barrierRegister = new HashMap(); /** * Map of currently waiting resolves; name->reply-location */ private final HashMap waitingResolves = new HashMap(); /** * Map of currently logged clients; NodeID->reply-channel */ private final HashMap loggedClients = new HashMap(); /** * A channel used to receive incoming link lost notifications */ private final AltingChannelInput lostLink = Node.getInstance().getLinkLostEventChannel(); /** * Private empty constructor */ private BNS() { // Empty constructor } /** * Gets the singleton instance of the BNS * * @return The singleton instance of the BNS */ public static BNS getInstance() { return instance; } /** * Initialises the connection to the BNS * * @param bnsNode * The NodeID of the BNS Node * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static void initialise(NodeID bnsNode) throws JCSPNetworkException { // First check that we are not already initialised if (BNS.initialised) throw new JCSPNetworkException("The BNS is already initialised"); // We are initialised. Attempt to do so. // First, we need to create the BNSService BNS.service = new BNSService(bnsNode); // Now set initialised to true BNS.initialised = true; // We are now connected } /** * Initialises the connection to the BNS * * @param bnsNode * The NodeAddress of the BNS Node * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static void initialise(NodeAddress bnsNode) throws JCSPNetworkException { // First check that we are not already initialised if (BNS.initialised) throw new JCSPNetworkException("The BNS is already initialised"); // We are initialised. Attempt to do so. // First, we need to connect to the BNS Node Link link = LinkFactory.getLink(bnsNode); // Now create the BNSService BNS.service = new BNSService(link.getRemoteNodeID()); // Now set initialised to true BNS.initialised = true; // We are now connected } /** * The run method for the BNS process */ public void run() { // Create the channel to receive incoming messages on. The index is 2. NetAltingChannelInput in = NetChannel.numberedNet2One(2, new BNSNetworkMessageFilter.FilterRX()); // We now wish to alternate upon this channel and the link lost channel Alternative alt = new Alternative(new Guard[] { this.lostLink, in }); // Loop forever while (true) { // Select next available Guard. Give priority to link failure switch (alt.priSelect()) { // We have lost the connection to a Node case 0: // Read in the NodeID of the lost Node NodeID lostNode = (NodeID)this.lostLink.read(); // Log loss of connection Node.log.log(this.getClass(), "Lost Link to: " + lostNode.toString()); // Remove the logged client this.loggedClients.remove(lostNode); // Next get the ArrayList of any barriers registered by that Node ArrayList registeredBars = (ArrayList)this.barrierRegister.get(lostNode); // If this ArrayList is null, we have no registrations if (registeredBars != null) { // There are registered barriers // Remove the list from the Hashmap this.barrierRegister.remove(lostNode); // Now remove all the barriers registered by the Node for (Iterator iter = registeredBars.iterator(); iter.hasNext();) { String toRemove = (String)iter.next(); this.registeredBarriers.remove(toRemove); Node.log.log(this.getClass(), toRemove + " deregistered"); } } break; // We have received a new incoming message case 1: { // Read in the message BNSMessage message = (BNSMessage)in.read(); // Now behave based on the type of the message switch (message.type) { // We have received a logon message case BNSMessageProtocol.LOGON_MESSAGE: { // Log the logon attempt Node.log.log(this.getClass(), "Logon received from: " + message.serviceLocation.getNodeID().toString()); // try-catch loop. We don't want the BNS to fail try { // Check if the node is already logged on NetChannelOutput out = (NetChannelOutput)this.loggedClients.get(message.serviceLocation .getNodeID()); // If out is null, no previous logon received if (out != null) { // This Node is already logged on. Send fail message // Log failed attempt Node.err.log(this.getClass(), message.serviceLocation.getNodeID().toString() + " already logged on. Rejecting"); // Create reply channel to the Node NetChannelOutput toNewRegister = NetChannel.one2net(message.serviceLocation, new BNSNetworkMessageFilter.FilterTX()); // Create the reply message BNSMessage reply = new BNSMessage(); reply.type = BNSMessageProtocol.LOGON_REPLY_MESSAGE; reply.success = false; // Asynchronously write to Node. We don't want the BNS to block toNewRegister.asyncWrite(reply); // Destroy the temporary channel toNewRegister.destroy(); } else { // Node hasn't previously registered // Log registration Node.log.log(this.getClass(), message.serviceLocation.getNodeID().toString() + " successfully logged on"); // Create the reply channel NetChannelOutput toNewRegister = NetChannel.one2net(message.serviceLocation, new BNSNetworkMessageFilter.FilterTX()); // Add the Node and reply channel to the logged clients map this.loggedClients.put(message.serviceLocation.getNodeID(), toNewRegister); // Create a reply message BNSMessage reply = new BNSMessage(); reply.type = BNSMessageProtocol.LOGON_REPLY_MESSAGE; reply.success = true; // Write reply asynchronously to the logging on Node toNewRegister.asyncWrite(reply); } } catch (JCSPNetworkException jne) { // Catch any JCSPNetworkException. We don't let the BNS go down } break; } // A Node is attempting to register a Barrier case BNSMessageProtocol.REGISTER_REQUEST: { // Log registration attempt Node.log.log(this.getClass(), "Registeration for " + message.name + " received"); // Catch any JCSPNetworkException try { // Get the reply channel from our logged clients map NetChannelOutput out = (NetChannelOutput)this.loggedClients.get(message.serviceLocation .getNodeID()); // Check if the Node has logged on with us if (out == null) { // The Node is not logged on. Send failure message Node.err.log(this.getClass(), "Registration failed. " + message.serviceLocation.getNodeID() + " not logged on"); // Create the channel to reply to out = NetChannel.one2net(message.serviceLocation, new BNSNetworkMessageFilter.FilterTX()); // Create the reply message BNSMessage reply = new BNSMessage(); reply.type = BNSMessageProtocol.REGISTER_REPLY; reply.success = false; // Write message asynchronously to the Node out.asyncWrite(reply); // Destroy the temporary channel out.destroy(); } // The Node is registered. Now check if the name is else if (this.registeredBarriers.containsKey(message.name)) { // The name is already registered. Inform the register // Log the failed registration Node.err.log(this.getClass(), "Registration failed. " + message.name + " already registered"); // Create reply message BNSMessage reply = new BNSMessage(); reply.type = BNSMessageProtocol.RESOLVE_REPLY; reply.success = false; // Write the reply asynchronously. Do not block the BNS out.asyncWrite(reply); } else { // The name is not registered // Log successful registration Node.log.log(this.getClass(), "Registration of " + message.name + " succeeded."); // First check if any client end is waiting for this name ArrayList pending = (ArrayList)this.waitingResolves.get(message.name); if (pending != null) { // We have waiting resolves. Complete for (Iterator iter = pending.iterator(); iter.hasNext();) { NetChannelOutput toPending = null; // We now catch internally any JCSPNetworkException try { // Get the next waiting message BNSMessage msg = (BNSMessage)iter.next(); // Log resolve completion Node.log.log(this.getClass(), "Queued resolve of " + message.name + " by " + msg.serviceLocation.getNodeID() + " completed"); // Create channel to the resolver toPending = NetChannel.one2net(msg.serviceLocation, new BNSNetworkMessageFilter.FilterTX()); // Create the reply message BNSMessage reply = new BNSMessage(); reply.type = BNSMessageProtocol.RESOLVE_REPLY; reply.location = message.location; reply.success = true; // Write the reply asynchronously to the waiting resolver toPending.asyncWrite(reply); } catch (JCSPNetworkException jne) { // Something went wrong as we tried to send the resolution complete // message // Do nothing } finally { // Check if we need to destroy the temporary channel if (toPending != null) toPending.destroy(); } } // Remove the name from the pending resolves this.waitingResolves.remove(message.name); } // We have completed any pending resolves. Now register the barrier this.registeredBarriers.put(message.name, message.location); // Now add the registered barrier to the barriers registered by this Node ArrayList registered = (ArrayList)this.barrierRegister.get(message.serviceLocation .getNodeID()); // If the ArrayList is null, we have no previous registrations if (registered == null) { // Create a new ArrayList to store the registered names registered = new ArrayList(); // Add it to the barrier register this.barrierRegister.put(message.location.getNodeID(), registered); } // Add the name to the ArrayList registered.add(message.name); // Log the successful registration Node.log.log(this.getClass(), message.name + " registered to " + message.location); // Create the reply message BNSMessage reply = new BNSMessage(); reply.type = BNSMessageProtocol.REGISTER_REPLY; reply.success = true; // Write the reply asynchronously to the Node out.asyncWrite(reply); } } catch (JCSPNetworkException jne) { // Do nothing. Do not let the BNS break } break; } // We have received a resolve request case BNSMessageProtocol.RESOLVE_REQUEST: { // Log resolve request Node.log.log(this.getClass(), "Resolve request for " + message.name + " received"); // Catch any JCSPNetworkException try { // Check if the resolving Node is logged on NetChannelOutput out = (NetChannelOutput)this.loggedClients.get(message.serviceLocation .getNodeID()); // If the channel is null, then the Node has yet to log on with us if (out == null) { // Node is not logged on // Log failed resolution Node.err.log(this.getClass(), "Resolve failed. " + message.serviceLocation.getNodeID() + " not logged on"); // Create connection to the receiver out = NetChannel.one2net(message.serviceLocation, new BNSNetworkMessageFilter.FilterTX()); // Create the reply message BNSMessage reply = new BNSMessage(); reply.type = BNSMessageProtocol.RESOLVE_REPLY; reply.success = false; // Write message asynchronously to the Node out.asyncWrite(reply); // Destroy the temporary channel out.destroy(); } else { // Node is logged on. Now check if the name is already registered NetBarrierLocation loc = (NetBarrierLocation)this.registeredBarriers .get(message.name); // If the location is null, then the name has not yet been registered if (loc == null) { // The name is not registered. We need to queue the resolve until it is // Log the queueing of the resolve Node.log.log(this.getClass(), message.name + " not registered. Queueing resolve by " + message.serviceLocation.getNodeID().toString()); // Check if any other resolvers are waiting for the channel ArrayList pending = (ArrayList)this.waitingResolves.get(message.name); // If the ArrayList is null, no one else is waiting if (pending == null) { // No one else is waiting. Create a new list and add it to the waiting // resolves pending = new ArrayList(); this.waitingResolves.put(message.name, pending); } // Add this resolve message to the list of waiting resolvers pending.add(message); } else { // The location is not null. Send it to the resolver Node.log.log(this.getClass(), "Resolve request completed. " + message.name + " location being sent to " + message.serviceLocation.getNodeID()); // Create channel to the resolver NetChannelOutput toPending = NetChannel.one2net(message.serviceLocation, new BNSNetworkMessageFilter.FilterTX()); // Create the reply message BNSMessage reply = new BNSMessage(); reply.type = BNSMessageProtocol.RESOLVE_REPLY; reply.location = loc; reply.success = true; // Write the reply to the resolver asynchronously toPending.asyncWrite(reply); // Destroy the temporary channel toPending.destroy(); } } } catch (JCSPNetworkException jne) { // Something went wrong during the resolution. Ignore } break; } } break; } } } } /** * Creates a new server end of a NetBarrier with the given name * * @param name * The name to register with the BNS * @param localEnrolled * The number of locally enrolled processes * @param netEnrolled * The number of net enrolled processes to expect * @return A new NetBarrier server end with the number of enrolled processes * @throws IllegalArgumentException * Thrown if the parameters are outside the defined ranges * @throws IllegalStateException * Thrown if the BNS connection has not been initialised */ public static NetBarrier netBarrier(String name, int localEnrolled, int netEnrolled) throws IllegalArgumentException, IllegalStateException { // Check if the BNS connection is initialised if (!BNS.initialised) throw new IllegalStateException("The connection to the BNS has not been initialised"); // Create a new NetBarrier NetBarrier toReturn = NetBarrierEnd.netBarrier(localEnrolled, netEnrolled); // Attempt to register if (BNS.service.register(name, toReturn)) { return toReturn; } // Registration failed. Destroy and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the BNS"); } /** * Creates a new server end of a NetBarrier with a given index and name * * @param name * Name to register with the BNS * @param index * The index to create the NetBarrier with * @param localEnrolled * The number of locally enrolled processes * @param netEnrolled * The number of remote enrollments to wait for * @return A new NetBarrier * @throws IllegalArgumentException * Thrown if the parameters are outside the defined ranges * @throws IllegalStateException * Thrown if the connection to the BNS has not been initialised */ public static NetBarrier numberedNetBarrier(String name, int index, int localEnrolled, int netEnrolled) throws IllegalArgumentException, IllegalStateException { // Check if the BNS connection is initialised if (!BNS.initialised) throw new IllegalStateException("The connection to the BNS has not been initialised"); // Create a new NetBarrier NetBarrier toReturn = NetBarrierEnd.numberedNetBarrier(index, localEnrolled, netEnrolled); // Attempt to register if (BNS.service.register(name, toReturn)) { return toReturn; } // Registration failed. Destroy and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the BNS"); } /** * Creates a new client end of a NetBarrier * * @param name * The name to resolve with the BNS * @param enrolled * The number of locally enrolled processes * @return A new NetBarrier client end with the number of enrolled processes * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws IllegalArgumentException * Thrown if the number of of local enrolled is outside the defined range * @throws IllegalStateException * Thrown if the connection to the BNS has not been initialised */ public static NetBarrier netBarrier(String name, int enrolled) throws IllegalArgumentException, IllegalStateException, JCSPNetworkException { // Check if the BNS connection is initialised if (!BNS.initialised) throw new IllegalStateException("The connection to the BNS has not been initialised"); // Resolve the location of the barrier NetBarrierLocation loc = BNS.service.resolve(name); // Return a new NetBarrier return NetBarrierEnd.netBarrier(loc, enrolled); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/bns/BNSService.java0000644000000000000000000001063411072626250017407 0ustar package org.jcsp.net2.bns; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.NetBarrier; import org.jcsp.net2.NetBarrierLocation; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelInput; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.Node; import org.jcsp.net2.NodeID; /** * This is the service object used to register and resolve barrier names with a Barrier Name Server. This provides a * client front end. * * @author Kevin Chalmers (updated from Quickstone Technologies) */ public final class BNSService { /** * The channel to send messages to the BNS upon */ private final NetChannelOutput toBNS; /** * The incoming channel to receive messages from the BNS */ private final NetChannelInput fromBNS; /** * Creates a new BNSService * * @param bnsNode * The Node that the BNS is on * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public BNSService(NodeID bnsNode) throws JCSPNetworkException { // Create input and output end this.toBNS = NetChannel.one2net(bnsNode, 2, new BNSNetworkMessageFilter.FilterTX()); this.fromBNS = NetChannel.net2one(new BNSNetworkMessageFilter.FilterRX()); // Logon to the BNS BNSMessage message = new BNSMessage(); message.type = BNSMessageProtocol.LOGON_MESSAGE; message.serviceLocation = (NetChannelLocation)this.fromBNS.getLocation(); this.toBNS.write(message); // Wait for logon reply message BNSMessage logonReply = (BNSMessage)this.fromBNS.read(); // Check if we logged on OK if (logonReply.success == false) { Node.err.log(this.getClass(), "Failed to logon to BNS"); throw new JCSPNetworkException("Failed to logon to BNS"); } Node.log.log(this.getClass(), "Logged into BNS"); } /** * Registers a Server end of a NetBarrier with the BNS * * @param name * Name to register with BNS * @param bar * Barrier to register * @return True if the name was registered successfully, false otherwise */ public boolean register(String name, NetBarrier bar) { // Ensure only one registration can happen at a time synchronized (this) { // Create a new registration message BNSMessage message = new BNSMessage(); message.type = BNSMessageProtocol.REGISTER_REQUEST; message.name = name; message.serviceLocation = (NetChannelLocation)this.fromBNS.getLocation(); message.location = (NetBarrierLocation)bar.getLocation(); // Write registration message to the BNS this.toBNS.write(message); // Read in reply BNSMessage reply = (BNSMessage)this.fromBNS.read(); return reply.success; } } /** * Resolves a name on the BNS, retrieving the NetBarrierLocation for the NetBarrier * * @param name * The name to resolve from the BNS * @return The NetBarrierLocation of the NetBarrier declared with name * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetBarrierLocation resolve(String name) throws JCSPNetworkException { // Create a temporary channel to receive the incoming NetBarrierLocation NetChannelInput responseChan = NetChannel.net2one(new BNSNetworkMessageFilter.FilterRX()); // Create the resolution message BNSMessage message = new BNSMessage(); message.type = BNSMessageProtocol.RESOLVE_REQUEST; message.serviceLocation = (NetChannelLocation)responseChan.getLocation(); message.name = name; // Write resolution message to the BNS this.toBNS.write(message); // Read in reply BNSMessage reply = (BNSMessage)responseChan.read(); // Destroy temporary channel responseChan.destroy(); // Return result if (reply.success) return reply.location; throw new JCSPNetworkException("Failed to resolve barrier named: " + name); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/bns/BNSMessageProtocol.java0000644000000000000000000000261411072626250021114 0ustar package org.jcsp.net2.bns; /** * This class defines the message types that can be sent to and from the CNS. This is internal to JCSP * * @author Kevin Chalmers */ final class BNSMessageProtocol { /** * Empty, private constructor. We do not create instances of this class */ private BNSMessageProtocol() { // Empty constructor } /** * A message sent from a BNSService to a BNS to log on */ static final byte LOGON_MESSAGE = 1; /** * Reply from server after a log on */ static final byte LOGON_REPLY_MESSAGE = 2; /** * Register a name with the BNS */ static final byte REGISTER_REQUEST = 3; /** * Resolve a name from the NS */ static final byte RESOLVE_REQUEST = 4; /** * *** Not currently used *** */ static final byte LEASE_REQUEST = 5; /** * *** Not currently used *** */ static final byte DEREGISTER_REQUEST = 6; /** * Reply from a registration request */ static final byte REGISTER_REPLY = 7; /** * Reply from a resolve request */ static final byte RESOLVE_REPLY = 8; /** * *** Not currently used *** */ static final byte LEASE_REPLY = 9; /** * *** Not currently used *** */ static final byte DEREGISTER_REPLY = 10; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetSharedChannelOutput.java0000644000000000000000000000107311072626250021246 0ustar package org.jcsp.net2; import org.jcsp.lang.SharedChannelOutput; /** * Defines a networked ChannelOutput that is safe to be used by multiple concurrent processes. For more information see * NetChannelOutput and SharedChannelOutput. To create an instance, see the relevant factory method. * * @see NetChannelOutput * @see SharedChannelOutput * @see NetChannel * @author Kevin Chalmers (updated from Quickstone Technologies) */ public interface NetSharedChannelOutput extends NetChannelOutput, SharedChannelOutput { // Nothing to add } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetBarrierLocation.java0000644000000000000000000001050411072626250020404 0ustar package org.jcsp.net2; import java.io.Serializable; /** * This class is a data structure representing the location of a NetBarrier in a network. The NetBarrierLocation * consists of the NodeID of the Node on which the NetBarrier resides, and its Virtual Barrier Number, which is the * number uniquely identifying the NetBarrier on said node. *

* To acquire the NetBarrierLocation of a NetBarrier, use the getLocation method: *

*

* * NetBarrierLocation location = (NetBarrierLocation)bar.getLocation(); * *

*

* The location returned depends on whether the NetBarrier is a client or a server end. A server end of a NetBarrier * will return its own location. A client end of a NetBarrier will return the location of the server end it is connected * to. This is because we consider the NetBarrier to be a single, virtual construct, with only one location. That * location is where the server end of the NetBarrier is located. *

* * @see NetBarrier * @see NetLocation * @author Kevin Chalmers */ public final class NetBarrierLocation extends NetLocation implements Serializable { /** * The SUID of this object. Required for Serialization. */ private static final long serialVersionUID = 1L; /** * The NodeID portion of the location structure */ private final NodeID nodeID; /** * The index portion of the location structure */ private final int vbn; /** * Constructor to create a new NetBarrierLocation * * @param aNodeID * The NodeID portion of the NetBarrierLocation * @param aVBN * The index part of the NetBarrierLocation */ public NetBarrierLocation(NodeID aNodeID, int aVBN) { this.nodeID = aNodeID; this.vbn = aVBN; } /** * Gets the NodeID part of the location * * @return The NodeID part of the NetBarrierLocation */ public NodeID getNodeID() { return this.nodeID; } /** * Gets the NodeAddress part of the location * * @return The NodeAddress part of the NetBarrierLocation */ public NodeAddress getNodeAddress() { return this.nodeID.getNodeAddress(); } /** * Gets the index part of the location * * @return The VBN part of the NetBarrierLocation */ public int getVBN() { return this.vbn; } /** * Returns the string representation of the NetBarrierLocation. This takes the form of nbl://[NodeID]/[VBN]. * This string representation has been created to allow other frameworks to interpret the NetBarrierLocation. * * @return String representation of the NetBarrierLocation */ public String toString() { return "nbl://" + this.nodeID.toString() + "/" + this.vbn; } /** * Takes the string representation of a NetBarrierLocation and converts it back into an object for usage by JCSP. * * @param str * The string representation of the NetBarrierLocation * @return A NetBarrierLocation produced from a String representation * @throws IllegalArgumentException * Thrown if a non NetBarrierLocation is attempted to be parsed */ public static NetBarrierLocation parse(String str) throws IllegalArgumentException { if (str.equalsIgnoreCase("null")) return null; // Check that the string starts with nbl:// if (str.startsWith("nbl://")) { // Take the off the starting part of the string String toParse = str.substring(6); // Split the string in two int index = toParse.indexOf("/"); // Parse the NodeID portion NodeID nodeID = NodeID.parse(toParse.substring(0, index)); // Parse the VBN portion int vcn = Integer.parseInt(toParse.substring(index + 1)); // Return a new NetBarrierLocation created from the two parts return new NetBarrierLocation(nodeID, vcn); } // We don't have a NetBarrierLocation throw new IllegalArgumentException("String is not a string form of a NetBarrierLocation"); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetConnectionClient.java0000644000000000000000000000023311072626250020561 0ustar package org.jcsp.net2; import org.jcsp.lang.ConnectionClient; public interface NetConnectionClient extends Networked, ConnectionClient { } jcsp-1.1-rc4.orig/src/org/jcsp/net2/One2NetChannel.java0000644000000000000000000006225311072626250017431 0ustar package org.jcsp.net2; import java.io.IOException; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.Channel; import org.jcsp.lang.ChannelOutput; import org.jcsp.lang.One2OneChannel; import org.jcsp.lang.PoisonException; import org.jcsp.net2.NetworkMessageFilter.FilterTx; import org.jcsp.util.InfiniteBuffer; /** * An outputting end of a networked channel (TX). This is a concrete implementation created internally by JCSP. For * information on how to use networked channels, and how to create them, see the relevant documentation. * * @see NetChannelOutput * @see NetChannel * @author Kevin Chalmers (Updated from Quickstone Technologies) */ final class One2NetChannel implements NetChannelOutput { /** * The channel connecting to the Link that connects to the networked input end of this channel. */ private final ChannelOutput toLinkTx; /** * The actual Link this output channel sends on. We keep this as it allows us to register and unregister with the * Link as we are created and destroyed, allowing the Link to inform the channel when a Link goes down. */ private final Link linkConnectedTo; /** * This is used if we are ever connected locally. We use this to check the state of a locally connected channel * prior to sending a message. */ private final ChannelData localChannel; /** * The channel used to receive acknowledgements from the input end via the Link. */ private final AltingChannelInput theAckChannel; /** * A structure containing the information on the state of the channel. */ private final ChannelData data; /** * The location that this channel is connected to (the input channel ends location) */ private final NetChannelLocation remoteLocation; /** * The local channel end location */ private final NetChannelLocation localLocation; /** * Flag to determine if this is a locally connected channel or not */ private final boolean isLocal; /** * The filter used to encode outgoing messages */ private NetworkMessageFilter.FilterTx messageFilter; /** * Creates a new One2NetChannel by connecting to an already created NetChannelInput * * @param loc * The location of the NetChannelInput * @param immunity * The immunity level of the channel * @param filter * The filter used to encode outgoing messages * @return A new One2NetChannel * @throws JCSPNetworkException * Thrown if the connection to the remote Node fails */ static One2NetChannel create(NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { // Create the channel data structure ChannelData data = new ChannelData(); // Create the channel linking this to the Link level. This channel is the one used to receive acknowledgement // messages One2OneChannel chan = Channel.one2one(new InfiniteBuffer()); data.toChannel = chan.out(); // Set state of channel data.state = ChannelDataState.OK_OUTPUT; // Register channel ChannelManager.getInstance().create(data); // We now need to create the connection to the input end of the channel ChannelOutput toLink; // Check if this is a local link, and if so connect directly to the input channel if (loc.getNodeID().equals(Node.getInstance().getNodeID())) { toLink = ChannelManager.getInstance().getChannel(loc.getVCN()).toChannel; return new One2NetChannel(chan.in(), toLink, null, data, loc, immunity, filter); } // Connect to remote node if necessary Link link = LinkManager.getInstance().requestLink(loc.getNodeID()); // Check if an existing connection exists if (link == null) { // We are not connected. Connect to remote Node. link = LinkFactory.getLink(loc.getNodeID()); } // Get the connection to the Link. toLink = link.getTxChannel(); // Return new channel return new One2NetChannel(chan.in(), toLink, link, data, loc, immunity, filter); } /** * Private constructor for creating a One2NetChannel. This is called by the create method. * * @param ackChannel * The channel used to receive acknowledgements from Links * @param toLink * The channel used to send messages to the input end * @param link * The Link that this channel is connected to * @param chanData * The structure used to store the state of the channel * @param loc * The location of the input end that this channel is connected to * @param immunity * The poison immunity level of the channel * @param filter * Filter used to encode outgoing messages */ private One2NetChannel(AltingChannelInput ackChannel, ChannelOutput toLink, Link link, ChannelData chanData, NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) { // Set all the object properties for the channel this.toLinkTx = toLink; this.theAckChannel = ackChannel; this.data = chanData; this.remoteLocation = loc; this.localLocation = new NetChannelLocation(Node.getInstance().getNodeID(), chanData.vcn); this.data.immunityLevel = immunity; this.messageFilter = filter; // We now must either register with the Link connecting us to the input end, or we connect directly to the // channel if it is local if (link != null) { // We are connected to a remote Node. Register with Link this.linkConnectedTo = link; this.linkConnectedTo.registerChannel(this.data); // Set the localised parameters accordingly this.isLocal = false; this.localChannel = null; } else { // We are connected to an input end on this Node. Set the localised parameters this.isLocal = true; // Get hold of the local channel data structure this.localChannel = ChannelManager.getInstance().getChannel(this.remoteLocation.getVCN()); // Set the Link connected to to null this.linkConnectedTo = null; } } /** * Poisons the underlying channel. * * @param strength * The strength of the poison being placed on the channel */ public void poison(int strength) { // First check the state of the channel if (this.data.state == ChannelDataState.DESTROYED || this.data.state == ChannelDataState.BROKEN) // In this case we do nothing. Destroyed and broken are considered stronger than poisoned return; // Now check if the strength of the poison is greater than a previous poison if (strength > this.data.poisonLevel) { // Change the current poison level this.data.poisonLevel = strength; // Now check if the poison level is strong enough to poison us. if (strength > this.data.immunityLevel) { // The poison is strong enough. We need to change our state to poisoned. // We need to lock on the state to ensure no link is using it as we change it synchronized (this.data) { // Now change our state this.data.state = ChannelDataState.POISONED; } // Now we need to send the poison. Create the poison message NetworkMessage msg = new NetworkMessage(); msg.type = NetworkProtocol.POISON; msg.attr1 = this.remoteLocation.getVCN(); msg.attr2 = strength; // Now we must send the poison. Check if we are locally connected if (this.isLocal) { // Now check the state of the local input end. Acquire lock synchronized (this.localChannel) { // We only need to forward the message if the opposite channel is in OK_INPUT if (this.localChannel.state == ChannelDataState.OK_INPUT) // Write the message this.toLinkTx.write(msg); } } // We are not locally connected. Just forward the poison this.toLinkTx.write(msg); } // Poison is not above our immunity level. Do nothing. } } /** * Gets the NetChannelLocation that this channel is connected to (i.e. the input end location) * * @return The NetChannelLocation that this channel is connected to */ public NetLocation getLocation() { return this.remoteLocation; } /** * Gets the local NetChannelLocation that represents this channel. * * @return The local location of the output end */ NetChannelLocation localLocation() { return this.localLocation; } /** * Writes an object to the input end * * @param object * The object to send to the input end. * @throws JCSPNetworkException * Thrown if something goes wrong in the network architecture * @throws PoisonException * Thrown if the channel has been poisoned */ public void write(Object object) throws JCSPNetworkException, PoisonException { // First we do a state check, and throw an exception if necessary if (this.data.state == ChannelDataState.DESTROYED) throw new JCSPNetworkException("Channel has been destroyed"); if (this.data.state == ChannelDataState.BROKEN) throw new JCSPNetworkException("Channel has broken"); if (this.data.state == ChannelDataState.POISONED) throw new NetworkPoisonException(this.data.poisonLevel); // The channel is in a suitable state to do a write. Continue write operation // First check that no pending messages have been left for us. This can happen if we did an async write and // then were rejected, poisoned, or if the link went down. if (this.theAckChannel.pending()) { NetworkMessage msg = (NetworkMessage)this.theAckChannel.read(); // Lock onto our state object as we may be changing our state synchronized (this.data) { // A previous ASYNC_SEND was rejected. Break channel. if (msg.type == NetworkProtocol.REJECT_CHANNEL) { this.data.state = ChannelDataState.BROKEN; // Remove ourselves from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); throw new JCSPNetworkException("Channel rejected during previous send"); } // The link to the input end has gone down. Break the channel else if (msg.type == NetworkProtocol.LINK_LOST) { this.data.state = ChannelDataState.BROKEN; // Remove ourselves from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); throw new JCSPNetworkException("Link to Node lost. Send cannot complete"); } // A previous ASYNC_SEND resulted in us being poisoned. Poison the channel. There is nothing else that // can be done, as the input end has effectively gone. else if (msg.type == NetworkProtocol.POISON) { this.data.state = ChannelDataState.POISONED; this.data.poisonLevel = msg.attr2; throw new NetworkPoisonException(msg.attr2); } // This shouldn't really happen, but possibly someone ACK'd us when they were not meant to. Throw // exception. else { Node.err.log(this.getClass(), "Channel " + this.data.vcn + " reports unexpected message."); throw new JCSPNetworkException("NetChannelOutput received an unexpected exception"); } } } // Create a new SEND message. NetworkMessage msg = new NetworkMessage(); msg.type = NetworkProtocol.SEND; msg.attr1 = this.remoteLocation.getVCN(); msg.attr2 = this.data.vcn; try { // Pass the message through the filter to convert it into bytes for transfer. Standard method is to convert // an object into a byte array via object serialization, but implementation specific methods can be // developed. // See NetworkMessageFilter and ObjectNetworkMessageFilter. msg.data = this.messageFilter.filterTX(object); // Now we must determine how to send the message. If it is to a remote Node, simply write to the Link. if (!this.isLocal) { this.toLinkTx.write(msg); } // If the input end is actually on this Node, then we attached our ackChannel to the message so the input // channel can send the ACK directly to us else { // Acquire lock on the input ends data structure synchronized (this.localChannel) { // Now check the local channels state and behave accordingly switch (this.localChannel.state) { case ChannelDataState.OK_INPUT: // We have an input end. Send message msg.toLink = this.data.toChannel; this.toLinkTx.write(msg); break; case ChannelDataState.POISONED: // The input end has been poisoned. Set our state and throw exception. // We don't need to acquire a lock. Only we can be operating on the channel this.data.state = ChannelDataState.POISONED; this.data.poisonLevel = this.localChannel.poisonLevel; throw new NetworkPoisonException(this.localChannel.poisonLevel); default: // In all other circumstances, we cause a network exception. Set state to broken // We do not need to acquire a lock. Only we can be operating on the channel this.data.state = ChannelDataState.BROKEN; // Remove ourselves from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); throw new JCSPNetworkException("Channel rejected during send"); } } } } catch (IOException ioe) { throw new JCSPNetworkException("Error when trying to convert the message for sending"); } // Now we wait for a reply on our ackChannel NetworkMessage reply = (NetworkMessage)this.theAckChannel.read(); // The SEND was rejected. Break channel. if (reply.type == NetworkProtocol.REJECT_CHANNEL) { this.data.state = ChannelDataState.BROKEN; // Remove ourselves from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); throw new JCSPNetworkException("Channel rejected during send"); } // The link to the input end has gone down. Break the channel else if (reply.type == NetworkProtocol.LINK_LOST) { this.data.state = ChannelDataState.BROKEN; // Remove ourselves from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); throw new JCSPNetworkException("Link to Node lost. Send cannot complete"); } // The SEND resulted in us being poisoned. Poison the channel. There is nothing else that // can be done, as the input end has effectively gone. else if (reply.type == NetworkProtocol.POISON) { this.data.state = ChannelDataState.POISONED; this.data.poisonLevel = msg.attr2; throw new NetworkPoisonException(msg.attr2); } // We received an ACK. Return. else if (reply.type == NetworkProtocol.ACK) { return; } // This shouldn't happen. Throw exception. else { Node.err.log(this.getClass(), "Channel " + this.data.vcn + " reports unexpected message."); throw new JCSPNetworkException("NetChannelOutput received an unexpected exception"); } } /** * Asynchronously writes an object to the channel * * @param object * The object being written to the channel * @throws JCSPNetworkException * Thrown when something goes wrong in the network architecture * @throws PoisonException * Thrown if the channel is poisoned */ public void asyncWrite(Object object) throws JCSPNetworkException, PoisonException { // First we do a state check, and throw an exception if necessary if (this.data.state == ChannelDataState.DESTROYED) throw new JCSPNetworkException("Channel has been destroyed"); if (this.data.state == ChannelDataState.BROKEN) throw new JCSPNetworkException("Channel has broken"); if (this.data.state == ChannelDataState.POISONED) throw new NetworkPoisonException(this.data.poisonLevel); // The channel is in a suitable state to do a write. Continue write operation // First check that no pending messages have been left for us. This can happen if we did an async write and // then were rejected, poisoned, or if the link went down. if (this.theAckChannel.pending()) { NetworkMessage msg = (NetworkMessage)this.theAckChannel.read(); // Lock onto our state object as we may be changing our state synchronized (this.data) { // A previous ASYNC_SEND was rejected. Break channel. if (msg.type == NetworkProtocol.REJECT_CHANNEL) { this.data.state = ChannelDataState.BROKEN; // Remove ourselves from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); // Now we may need to unregister from the Link if (!this.isLocal) { this.linkConnectedTo.deRegisterChannel(this.data); } throw new JCSPNetworkException("Channel rejected during previous send"); } // The link to the input end has gone down. Break the channel else if (msg.type == NetworkProtocol.LINK_LOST) { this.data.state = ChannelDataState.BROKEN; // Remove ourselves from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); // Now we may need to unregister from the Link if (!this.isLocal) { this.linkConnectedTo.deRegisterChannel(this.data); } throw new JCSPNetworkException("Link to Node lost. Send cannot complete"); } // A previous ASYNC_SEND resulted in us being poisoned. Poison the channel. There is nothing else that // can be done, as the input end has effectively gone. else if (msg.type == NetworkProtocol.POISON) { this.data.state = ChannelDataState.POISONED; this.data.poisonLevel = msg.attr2; throw new NetworkPoisonException(msg.attr2); } // This shouldn't really happen, but possibly someone ACK'd us when they were not meant to. Throw // exception. else { Node.err.log(this.getClass(), "Channel " + this.data.vcn + " reports unexpected message."); throw new JCSPNetworkException("NetChannelOutput received an unexpected exception"); } } } // Create a new SEND message. NetworkMessage msg = new NetworkMessage(); msg.type = NetworkProtocol.ASYNC_SEND; msg.attr1 = this.remoteLocation.getVCN(); msg.attr2 = this.data.vcn; try { // Pass the message through the filter to convert it into bytes for transfer. Standard method is to convert // an object into a byte array via object serialization, but implementation specific methods can be // developed. // See NetworkMessageFilter and ObjectNetworkMessageFilter. msg.data = this.messageFilter.filterTX(object); // Now we must determine how to send the message. If it is to a remote Node, simply write to the Link. if (!this.isLocal) { this.toLinkTx.write(msg); } // If the input end is actually on this Node, then we attached our ackChannel to the message so the input // channel can send the ACK directly to us else { // Acquire lock on the input ends data structure synchronized (this.localChannel) { // Now check the local channels state and behave accordingly switch (this.localChannel.state) { case ChannelDataState.OK_INPUT: // We have an input end. Send message msg.toLink = this.data.toChannel; this.toLinkTx.write(msg); break; case ChannelDataState.POISONED: // The input end has been poisoned. Set our state and throw exception. // We don't need to acquire a lock. Only we can be operating on the channel this.data.state = ChannelDataState.POISONED; this.data.poisonLevel = this.localChannel.poisonLevel; throw new NetworkPoisonException(this.localChannel.poisonLevel); default: // In all other circumstances, we cause a network exception. Set state to broken // We do not need to acquire a lock. Only we can be operating on the channel this.data.state = ChannelDataState.BROKEN; // Remove ourselves from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); throw new JCSPNetworkException("Channel rejected during send"); } } } } catch (IOException ioe) { throw new JCSPNetworkException("Error when trying to convert the message for sending"); } // We are asynchronous, so we simply return. } /** * Gets the channel data state for this channel. * * @return ChannelData for this channel */ final ChannelData getChannelData() { return this.data; } /** * Destroys the channel and removes it from the ChannelManager. */ public void destroy() { // Lock the channel data state synchronized (this.data) { // Set state to DESTROYED this.data.state = ChannelDataState.DESTROYED; // Remove channel from ChannelManager ChannelManager.getInstance().removeChannel(this.data); // Deregister from the Link if required. May be local if (this.linkConnectedTo != null) this.linkConnectedTo.deRegisterChannel(this.data); } } /** * Sets the underlying message filter * * @param encoder * The new message filter to use */ public void setEncoder(FilterTx encoder) { this.messageFilter = encoder; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ConnectionDataState.java0000644000000000000000000000102311072626250020544 0ustar /** * */ package org.jcsp.net2; /** * @author Kevin Chalmers */ final class ConnectionDataState { static final byte INACTIVE = 0; static final byte CLIENT_STATE_CLOSED = 1; static final byte CLIENT_STATE_OPEN = 2; static final byte CLIENT_STATE_MADE_REQ = 3; static final byte SERVER_STATE_CLOSED = 4; static final byte SERVER_STATE_OPEN = 5; static final byte SERVER_STATE_RECEIVED = 6; static final byte DESTROYED = 7; static final byte BROKEN = 8; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetConnectionServer.java0000644000000000000000000000023311072626250020611 0ustar package org.jcsp.net2; import org.jcsp.lang.ConnectionServer; public interface NetConnectionServer extends Networked, ConnectionServer { } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetSharedChannelInput.java0000644000000000000000000000107211072626250021044 0ustar package org.jcsp.net2; import org.jcsp.lang.SharedChannelInput; /** * Defines a networked ChannelInput that is safe to be used by multiple concurrent processes. For more information see * NetChannelInput and SharedChannelInput. To create an instance, see the relevant factory method. * * @see NetChannelInput * @see SharedChannelInput * @see NetChannel * @author Kevin Chalmers (updated from Quickstone Technologies) */ public interface NetSharedChannelInput extends SharedChannelInput, NetChannelInput { // Nothing new to declare } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetworkMessageFilter.java0000644000000000000000000000367311072626250020773 0ustar package org.jcsp.net2; import java.io.IOException; /** * This class defines what is required for the internal networked channel filter. These filters are used to encode and * decode objects into a byte array equivalent. This enables data independence between separate platforms, as well as * data separation from the communication. Two filters are supplied with JCSP; a Object filter and a raw data filter. * The former will encode and decode messages using the standard object serialization techniques. The latter will expect * byte arrays only, and will do no encoding or decoding. The object filter is the default created by the network * factory methods. * * @see ObjectNetworkMessageFilter * @see RawNetworkMessageFilter * @author Kevin Chalmers */ public final class NetworkMessageFilter { /** * The filter used to decode an incoming message * * @author Kevin Chalmers */ public interface FilterRx { /** * Decodes an incoming byte array back into an object * * @param bytes * The bytes to be decoded * @return The recreated Object * @throws IOException * Thrown if something goes wrong during the decoding */ public Object filterRX(byte[] bytes) throws IOException; } /** * The filter used to encode an outgoing message * * @author Kevin Chalmers */ public interface FilterTx { /** * Encodes an object into an array of bytes for sending * * @param obj * The object to convert into bytes * @return The byte array representation of the Object * @throws IOException * Thrown if something goes wrong during the encoding */ public byte[] filterTX(Object obj) throws IOException; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NodeID.java0000644000000000000000000001506011072626250015762 0ustar package org.jcsp.net2; import java.io.Serializable; /** * This class is used to uniquely identify a Node within the entire JCSP network of Nodes in operation. This is to allow * ease to identify individual Nodes when IDs come in, and to quickly find them within tables of other Links to allow * usage of existing connections. This is different to a NodeAddress, which is a symbolic name representing a Node, and * which therefore may be repeated. The hope here is that by using enough pieces of data the Node should have a unique * identification. This is done by gathering the information on the current system time in milliseconds, the current * free memory of the JVM, the hash code of a newly created object, the name of the Node, if there is one, and the * address of the Node itself. Having this much information should provide us with a unique ID. Other implementations of * the protocol can use other means of identifying a Node uniquely, but they must use the same amount of data, e.g. * string(number 64 bits) - string(number 64 bits) - string (number 32 bits) - string - address string, when * communicating with another JCSP Node for the sake of compatibility. * * @author Kevin Chalmers */ public final class NodeID implements Comparable, Serializable { /** * The SUID of this class */ private static final long serialVersionUID = 1L; /** * Current time in milliseconds */ private final long time; /** * Current amount of free memory to the JVM */ private final long mem; /** * Hash code of a object */ private final int hashCode; /** * Name of the Node */ private final String name; /** * Address of the Node */ private final NodeAddress address; /** * Constructor taking the name and the address of the Node * * @param nodeName * Symbolic name of the Node * @param nodeAddress * Symbolic address of the Node */ NodeID(String nodeName, NodeAddress nodeAddress) { this.time = System.currentTimeMillis(); this.mem = Runtime.getRuntime().freeMemory(); this.hashCode = new Object().hashCode(); this.name = nodeName; this.address = nodeAddress; } /** * Constructor taking the full details for a remote Node connection * * @param long1 * The time component of the remote Node * @param long2 * The memory component of the remote Node * @param int1 * The hashCode component of the remote Node * @param nodeName * The name component of the remote Node * @param nodeAddress * The NodeAddress component of the remote Node */ public NodeID(long long1, long long2, int int1, String nodeName, NodeAddress nodeAddress) { this.time = long1; this.mem = long2; this.hashCode = int1; this.name = nodeName; this.address = nodeAddress; } /** * Compares this NodeID with another NodeID. * * @param arg0 * @return -1, 0 or 1 if less than, equal, or greater than the other NodeID */ public int compareTo(final Object arg0) { // Check if other object is a NodeID. If not throw exception if (!(arg0 instanceof NodeID)) throw new IllegalArgumentException("Attempting to compare NodeID to an object that is not a NodeID"); NodeID other = (NodeID)arg0; // Compare to other NodeID values if (other.time < this.time) return 1; else if (other.time > this.time) return -1; else { // Time part is equal if (other.mem < this.mem) return 1; else if (other.mem > this.mem) return -1; else { // Memory part is equal if (other.hashCode < this.hashCode) return 1; else if (other.hashCode > this.hashCode) return -1; else { // Hashcode part is equal if (!(other.name.equals(this.name))) return this.name.compareTo(other.name); return this.address.compareTo(other.address); } } } } /** * Checks if the given object is equal to this NodeID * * @param arg0 * @return True if equal, false otherwise */ public boolean equals(Object arg0) { return this.compareTo(arg0) == 0; } /** * Returns the hashCode for this object * * @return Hashcode for the NodeID */ public int hashCode() { return this.hashCode; } /** * Converts the NodeID into a string for communication with other implementations, or for display purposes. * * @return String representation of the NodeID */ public String toString() { return this.time + "-" + this.mem + "-" + this.hashCode + "-" + this.name + "-" + this.address.toString(); } /** * Gets the NodeAddress part of the NodeID * * @return The NodeAddress part of the NodeID */ public NodeAddress getNodeAddress() { return this.address; } /** * Converts a string representation of a NodeID back to a NodeID object * * @param str * The string version of a NodeID * @return A new NodeID created from the String representation */ public static NodeID parse(String str) { // Split the string into its separate parts String[] pieces = new String[5]; int index = 0; int last = 0; for (int i = 0; i < 5; i++) { index = str.indexOf("-", index + 1); if (index == -1) index = str.length(); pieces[i] = str.substring(last, index); last = index + 1; } // Get the relevant parts long time = Long.parseLong(pieces[0]); long mem = Long.parseLong(pieces[1]); int hashCode = Integer.parseInt(pieces[2]); String name = pieces[3]; // Parse the address NodeAddress addr = NodeAddress.parse(pieces[4]); // Return the NodeID return new NodeID(time, mem, hashCode, name, addr); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetChannelOutput.java0000644000000000000000000000305511072626250020121 0ustar package org.jcsp.net2; import org.jcsp.lang.ChannelOutput; /** * An interface defining a ChannelOutput that is networked. For information on how to an object of this type, see * ChannelOutput. For information on how to create a NetChannelOutput, see the the relevant factory. *

* The only method that this interface defines is asyncSend. This is considered a dangerous method to use, and careful * consideration must be taken. The inclusion of asyncSend is to provide the impression of a simple infinitely buffered * networked channel, without having to create extra buffers beyond what the channel uses. *

* * @see ChannelOutput * @see Networked * @see NetChannel * @author Kevin Chalmers (updated from Quickstone Technologies) */ public interface NetChannelOutput extends ChannelOutput, Networked { /** * Sends a message to the input end of the channel asynchronously (no blocking) * * @param obj * The object to send to the input end * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws NetworkPoisonException * Thrown if the channel is poisoned */ public void asyncWrite(Object obj) throws JCSPNetworkException, NetworkPoisonException; /** * Sets the underlying encoder for the channel * * @param encoder * The encoder to use for the channel. */ public void setEncoder(NetworkMessageFilter.FilterTx encoder); } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetworkProtocol.java0000644000000000000000000000653411072626250020041 0ustar package org.jcsp.net2; /** * This class defines the constants used within the Link interactions. This is the network protocol for JCSP. This is an * internal class to JCSP, used specifically between Links and the Links and the networked constructs. * * @author Kevin Chalmers */ final class NetworkProtocol { /** * Empty constructor. This is a static set of values */ private NetworkProtocol() { // Empty constructor } /** * A SEND message from an output end to an input end */ final static byte SEND = 1; /** * An ACKnowledgment that releases an output end after a write */ final static byte ACK = 2; /** * An ENROLLment from a client end of a NetBarrier to a server end */ final static byte ENROLL = 3; /** * A RESIGNation of a client end of a NetBarrier from a server end */ final static byte RESIGN = 4; /** * A SYNChronization message sent from a client end of a NetBarrier to a server end when the client's local * processes have all synchronised */ final static byte SYNC = 5; /** * RELEASEs a waiting client end of a NetBarrier when the server end has completely been synced with */ final static byte RELEASE = 6; /** * Rejects a message sent from a NetBarrier. */ final static byte REJECT_BARRIER = 7; /** * Rejects a message sent from a NetChannelOutput */ final static byte REJECT_CHANNEL = 8; /** * Signifies that a Link has been lost */ final static byte LINK_LOST = 9; /** * Mobility message. Still to be defined */ final static byte MOVED = 10; /** * Mobility message. Still to be defined */ final static byte ARRIVED = 11; /** * A POISON message sent to poison a channel end */ final static byte POISON = 12; /** * An Asynchronous send operation */ final static byte ASYNC_SEND = 13; /** * The initial message sent from a client connection end to a server end */ final static byte OPEN = 14; /** * The subsequent communications from a client connection before closing */ final static byte REQUEST = 15; /** * The reply from the server end of a connection */ final static byte REPLY = 16; /** * A reply from the server end of a connection which also closes the connection */ final static byte REPLY_AND_CLOSE = 17; /** * An asynchronous open message */ final static byte ASYNC_OPEN = 18; /** * An asynchronous request to a connection server */ final static byte ASYNC_REQUEST = 19; /** * An asynchronous reply from the server */ final static byte ASYNC_REPLY = 20; /** * An asynchronous reply and close */ final static byte ASYNC_REPLY_AND_CLOSE = 21; /** * An acknowledgement of the initial OPEN or REQUEST by a client connection end */ final static byte REQUEST_ACK = 22; /** * An acknowledgement of a connection server REPLY */ final static byte REPLY_ACK = 23; /** * Rejects a message from a networked connection */ final static byte REJECT_CONNECTION = 24; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/Mutex.java0000644000000000000000000000205711072626250015764 0ustar package org.jcsp.net2; import org.jcsp.lang.ProcessInterruptedException; /** * A package-visible class that implements a straightforward mutex, for use by Net2AnyChannel * * @author Neil Brown */ class Mutex { /** * Flag to mark the mutex as claimed */ private boolean claimed = false; /** * Claims the mutex for exclusive access */ void claim() { synchronized (this) { while (this.claimed) { try { wait(); } catch (InterruptedException e) { throw new ProcessInterruptedException("*** Thrown from Mutex.claim()\n" + e.toString()); } } this.claimed = true; } } /** * Releases the mutex for exclusive access */ void release() { synchronized (this) { this.claimed = false; notify(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/LinkFactory.java0000644000000000000000000001767111072626250017117 0ustar package org.jcsp.net2; import org.jcsp.lang.ProcessManager; /** * This class is used to create a new Link from a given NodeID or NodeAddress. *

* It is perfectly reasonable for a user to create a Link to another Node without utilising the normal connection * methods. This class is therefore made public to allow such an occurrence. *

*

* Example, using TCP/IP *

*

* * TCPIPNodeAddress address = new TCPIPNodeAddress("192.168.1.100", 5000);
* Link link = LinkFactory.getLink(address);
*
*

*

* The getLink method will either return an existing Link if one exists, or it shall create a new one if necessary. *

*

* Using this method allows quick creation of channels / barrier on a remote Node without going through the normal name * servers. For example: *

*

* * NetChannelLocation loc = new NetChannelLocation(link.getRemoteNodeID(), 100);
* NetChannelOutput out = NetChannelEnd.one2net(loc);
*
*

*

* This method is generally considered faster than using the CNS, or creating channels just using the address and VCN. * It does require the user to know the address and channel number that is to be connected too. *

* * @see Link * @see NodeAddress * @see NodeID * @author Kevin Chalmers (updated from Quickstone Technologies) */ public final class LinkFactory { /** * Default private constructor. Not used. */ private LinkFactory() { // Empty constructor } /** * Creates a new Link or gets an existing one from the the given NodeID. * * @param nodeID * NodeID of the Node to connect to. * @return A Link connected to the remote Node of given NodeID * @throws JCSPNetworkException * Thrown if there is a problem connecting to the Node * @throws IllegalArgumentException * Thrown if an attempt is made to connect to the local Node */ public static Link getLink(NodeID nodeID) throws JCSPNetworkException, IllegalArgumentException { if (nodeID.equals(Node.getInstance().getNodeID())) throw new IllegalArgumentException("Attempted to connect to the local Node"); // Log start of Link creation Node.log.log(LinkFactory.class, "Trying to get link to " + nodeID.toString()); // First check if Link to NodeID exists. Request the Link from the Link Manager Link toReturn = LinkManager.getInstance().requestLink(nodeID); if (toReturn != null) { // A Link already exists to given NodeID. Log and return existing Link Node.log.log(LinkFactory.class, "Link to " + nodeID.toString() + " already exists. Returning existing Link"); return toReturn; } // An existing Link does not exist within the Link Manager. Log, and then create Link via the address Node.log.log(LinkFactory.class, "Link does not exist to " + nodeID.toString() + ". Creating new Link"); toReturn = nodeID.getNodeAddress().createLink(); // Now attempt to connect the Link. If connect fails, then the opposite node already has a connection to us. // This may occur during connection if the opposite end registered its Link prior to us doing so. In such // a circumstance, the Link should eventually appear in the LinkManager. if (!toReturn.connect()) { // Connect failed. Get NodeID of remote Node (this will have been set during the connect operation) NodeID remoteID = toReturn.getRemoteNodeID(); // Log failed connect Node.log.log(LinkFactory.class, "Failed to connect to " + remoteID.toString()); // Set the Link to return to null toReturn = null; // Loop until the Link is connected. This is a possible weakness. Although it is believed that the // opposite end will eventually connect, we may have a problem if this continually loops. For information, // log every attempt. while (toReturn == null) { try { // Go to sleep for a bit, and give the Link a chance to register Thread.sleep(100); // Log start of attempt Node.log.log(LinkFactory.class, "Attempting to retrieve Link to " + remoteID.toString()); // Retrieve Link from LinkManager toReturn = LinkManager.getInstance().requestLink(remoteID); } catch (InterruptedException ie) { // Ignore. Should never really happen } } // Return the Link retrieved from the LinkManager return toReturn; } // Connection succeeded. Register Link with the LinkManager toReturn.registerLink(); // Now start the Link ProcessManager proc = new ProcessManager(toReturn); proc.setPriority(toReturn.priority); proc.start(); // Return the Link return toReturn; } /** * Creates a new Link, or retrieves an existing one, from a NodeAddress * * @param addr * The NodeAddress of the Node to connect to * @return A new Link connected to the node at the given NodeAddress * @throws JCSPNetworkException * Thrown if anything goes wrong during the connection */ public static Link getLink(NodeAddress addr) throws JCSPNetworkException { // Log start of creation Node.log.log(LinkFactory.class, "Trying to get link to " + addr.toString()); // Create Link from address Link toReturn = addr.createLink(); // Now attempt to connect the Link. If connect fails, then the opposite node already has a connection to us. // This may occur during connection if the opposite end registered its Link prior to us doing so. In such // a circumstance, the Link should eventually appear in the LinkManager. if (!toReturn.connect()) { // Connect failed. Get NodeID of remote Node (this will have been set during the connect operation) NodeID remoteID = toReturn.getRemoteNodeID(); // Log failed connect Node.log.log(LinkFactory.class, "Failed to connect to " + remoteID.toString()); // Set the Link to return to null toReturn = null; // Loop until the Link is connected. This is a possible weakness. Although it is believed that the // opposite end will eventually connect, we may have a problem if this continually loops. For information, // log every attempt. while (toReturn == null) { try { // Go to sleep for a bit, and give the Link a chance to register Thread.sleep(100); // Log start of attempt Node.log.log(LinkFactory.class, "Attempting to retrieve Link to " + remoteID.toString()); // Retrieve Link from LinkManager toReturn = LinkManager.getInstance().requestLink(remoteID); } catch (InterruptedException ie) { // Ignore. Should never really happen } } // Return the Link retrieved from the LinkManager return toReturn; } // Connection succeeded. Register Link with the LinkManager toReturn.registerLink(); // Now start the Link new ProcessManager(toReturn).start(); // Return the Link return toReturn; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ChannelData.java0000644000000000000000000000304111072626250017016 0ustar package org.jcsp.net2; import org.jcsp.lang.ChannelInput; import org.jcsp.lang.ChannelOutput; /** * A class that is used to keep track of the state of a network channel. For a description of networked channels, see * the relevant documentation. * * @see org.jcsp.net2.NetChannelInput * @see org.jcsp.net2.NetChannelOutput * @author Kevin Chalmers */ final class ChannelData { /** * The virtual channel number. A unique number on the Node for identifying a channel. */ int vcn = -1; /** * The current state of the channel. */ byte state = ChannelDataState.INACTIVE; /** * The channel output used to connect to the network channel object. For a networked input end this is used to * communicate input messages from connected output ends. For output channels this is usually used for * acknowledgement, but may also be used for passing link lost and poison messages. */ ChannelOutput toChannel = null; /** * Indicates the level of poison that has been placed on the channel, if relevant. */ int poisonLevel = -1; /** * Indicates the immunity level to poison this channel has */ int immunityLevel = Integer.MAX_VALUE; /** * The other end of the toChannel. This will be set whenever a channel is used in a mobile manner. Any received * messages when the channel is moved are written to the normal channel, and they can then be accessed via this end. */ ChannelInput fromChannel = null; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetworkPoisonException.java0000644000000000000000000000125211072626250021356 0ustar package org.jcsp.net2; import org.jcsp.lang.PoisonException; /** * An exception thrown when a networked channel is poisoned. See the poison exception in the core package for more * information * * @see PoisonException * @author Kevin Chalmers */ public final class NetworkPoisonException extends PoisonException { /** * The SUID of the class */ private static final long serialVersionUID = 1L; /** * Creates a new NetworkPoisonException * * @param strength * The strength of the poison */ protected NetworkPoisonException(int strength) { super(strength); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/Networked.java0000644000000000000000000000117711072626250016626 0ustar package org.jcsp.net2; /** * Defines a standard JCSP synchronization mechanism which is also networked. For concrete examples of this class, see * NetBarrier, and the networked channels * * @see NetBarrier * @see NetChannelInput * @see NetChannelOutput * @author Kevin Chalmers (updated from Quickstone Technologies) */ public interface Networked { /** * Gets the networked location of the Networked construct * * @return The location of the construct */ public NetLocation getLocation(); /** * Destroys the Networked construct */ public void destroy(); } jcsp-1.1-rc4.orig/src/org/jcsp/net2/cns/0000755000000000000000000000000011410045051014564 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/net2/cns/CNSNetworkMessageFilter.java0000644000000000000000000001066511072626250022121 0ustar package org.jcsp.net2.cns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetworkMessageFilter; /** * This filter is used by the CNS and CNSService to transmit messages between one another in a manner that is platform * independent. This is an internal class to JCSP, and is created automatically by the CNS and CNSService. For more * information, see the relevant documentation. * * @see CNS * @see CNSService * @see NetworkMessageFilter * @author Kevin Chalmers */ final class CNSNetworkMessageFilter { /** * The encoding filter used to convert a CNSMessage into bytes * * @author Kevin Chalmers */ static final class FilterTX implements NetworkMessageFilter.FilterTx { /** * The byte stream we will use to retrieve the byte message from */ private final ByteArrayOutputStream baos; /** * The data stream, used to write the parts of the CNSMessage to */ private final DataOutputStream dos; /** * Creates a new CNS encoding filter */ FilterTX() { this.baos = new ByteArrayOutputStream(8192); this.dos = new DataOutputStream(this.baos); } /** * Converts an object (a CNSMessage) into bytes * * @param obj * The CNSMessage to convert * @return The byte equivalent of the CNSMessage * @throws IOException * Thrown if something goes wrong during the conversion */ public byte[] filterTX(Object obj) throws IOException { // First ensure we have a CNSMessage if (!(obj instanceof CNSMessage)) throw new IOException("Attempted to send a non CNSMessage on a CNSMessage channel"); CNSMessage msg = (CNSMessage)obj; // Now reset the byte stream this.baos.reset(); // Write the parts of the CNSMessage to the stream this.dos.writeByte(msg.type); this.dos.writeBoolean(msg.success); if (msg.location1 != null) this.dos.writeUTF(msg.location1.toString()); else this.dos.writeUTF("null"); if (msg.location2 != null) this.dos.writeUTF(msg.location2.toString()); else this.dos.writeUTF("null"); this.dos.writeUTF(msg.name); // Flush the stream this.dos.flush(); // Get the bytes return this.baos.toByteArray(); } } /** * The filter used to convert a CNSMessage from its byte representation back into an object * * @author Kevin Chalmers */ static final class FilterRX implements NetworkMessageFilter.FilterRx { /** * The input end to read the message back from */ private ByteArrayInputStream byteIn; /** * The data input stream used to read in the parts of the message */ private DataInputStream dis; /** * Creates a new decoding CNSMessage filter */ FilterRX() { // Nothing to do } /** * Decodes the byte equivalent of a CNSMessage * * @param bytes * The byte equivalent of a CNSMessage * @return The recreated CNSMessage * @throws IOException * Thrown if something goes wrong during the recreation */ public Object filterRX(byte[] bytes) throws IOException { this.byteIn = new ByteArrayInputStream(bytes); this.dis = new DataInputStream(byteIn); // Recreate the message CNSMessage msg = new CNSMessage(); msg.type = this.dis.readByte(); msg.success = this.dis.readBoolean(); msg.location1 = NetChannelLocation.parse(this.dis.readUTF()); msg.location2 = NetChannelLocation.parse(this.dis.readUTF()); msg.name = this.dis.readUTF(); return msg; } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/cns/CNSService.java0000644000000000000000000001061711072626250017412 0ustar package org.jcsp.net2.cns; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelInput; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.Node; import org.jcsp.net2.NodeID; /** * This is the service object used to register and resolve channel names with a Channel Name Server. This provides a * client front end. * * @author Kevin Chalmers (updated from Quickstone Technologies) */ public final class CNSService { /** * The channel to send messages to the CNS upon */ private final NetChannelOutput toCNS; /** * The incoming channel to receive messages from the CNS from */ private final NetChannelInput fromCNS; /** * Creates a new CNSService * * @param cnsNode * The NodeID of the Node with the CNS on it * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public CNSService(NodeID cnsNode) throws JCSPNetworkException { // Create the input and output channel this.toCNS = NetChannel.one2net(new NetChannelLocation(cnsNode, 1), new CNSNetworkMessageFilter.FilterTX()); this.fromCNS = NetChannel.net2one(new CNSNetworkMessageFilter.FilterRX()); // We now need to logon to the CNS CNSMessage message = new CNSMessage(); message.type = CNSMessageProtocol.LOGON_MESSAGE; message.location1 = (NetChannelLocation)this.fromCNS.getLocation(); this.toCNS.write(message); // Wait for logon reply message CNSMessage logonReply = (CNSMessage)this.fromCNS.read(); // Check if we logged on OK if (logonReply.success == false) { Node.err.log(this.getClass(), "Failed to logon to CNS"); throw new JCSPNetworkException("Failed to Logon to CNS"); } Node.log.log(this.getClass(), "Logged into CNS"); } /** * Registers an input end with the CNS * * @param name * The name to register the channel with * @param in * The NetChannelInput to register with the CNS * @return True if the channel was successfully registered, false otherwise */ public boolean register(String name, NetChannelInput in) { // Ensure that only one registration can happen at a time synchronized (this) { // Create a new registration message CNSMessage message = new CNSMessage(); message.type = CNSMessageProtocol.REGISTER_REQUEST; message.name = name; message.location1 = (NetChannelLocation)this.fromCNS.getLocation(); message.location2 = (NetChannelLocation)in.getLocation(); // Write registration message to the CNS this.toCNS.write(message); // Read in reply CNSMessage reply = (CNSMessage)this.fromCNS.read(); return reply.success; } } /** * Resolves a name on the CNS, retrieving the NetChannelLocation for the channel * * @param name * The name to resolve * @return The NetChannelLocation of the channel declared name * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public NetChannelLocation resolve(String name) throws JCSPNetworkException { // Create a temporary channel to receive the incoming NetChannelLocation NetChannelInput in = NetChannel.net2one(new CNSNetworkMessageFilter.FilterRX()); // Create a resolution message CNSMessage message = new CNSMessage(); message.type = CNSMessageProtocol.RESOLVE_REQUEST; message.location1 = (NetChannelLocation)in.getLocation(); message.name = name; // Write the resolution message to the CNS this.toCNS.write(message); // Read in reply CNSMessage reply = (CNSMessage)in.read(); // Destroy the temporary channel in.destroy(); // Now return the resolved location, or throw an exception if (reply.success == true) return reply.location1; throw new JCSPNetworkException("Failed to resolve channel named: " + name); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/cns/CNSMessage.java0000644000000000000000000000135211072626250017372 0ustar package org.jcsp.net2.cns; import org.jcsp.net2.NetChannelLocation; /** * A message sent between a CNS and a CNSService. This is an internal structure to JCSP. * * @author Kevin Chalmers */ final class CNSMessage { /** * The message type. See CNSMessageProtocol */ byte type = 0; /** * Whether the previous message was successful */ boolean success = false; /** * Location parameter. Usually the location to register */ NetChannelLocation location1 = null; /** * Location parameter. Usually the reply location */ NetChannelLocation location2 = null; /** * Name to register or resolve */ String name = ""; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/cns/CNSMessageProtocol.java0000644000000000000000000000262411072626250021117 0ustar package org.jcsp.net2.cns; /** * This class defines the message types that can be sent to and from the CNS. This is internal to JCSP * * @author Kevin Chalmers */ final class CNSMessageProtocol { /** * Empty, private constructor. We do not create instances of this class. */ private CNSMessageProtocol() { // Empty constructor } /** * A message sent from a CNSService to a CNS allowing logging on */ static final byte LOGON_MESSAGE = 1; /** * The reply from a Logon */ static final byte LOGON_REPLY_MESSAGE = 2; /** * Register a name with the CNS */ static final byte REGISTER_REQUEST = 3; /** * Resolve a location from the CNS */ static final byte RESOLVE_REQUEST = 4; /** * *** Not currently used *** */ static final byte LEASE_REQUEST = 5; /** * *** Not currently used *** */ static final byte DEREGISTER_REQUEST = 6; /** * A reply from a registration request */ static final byte REGISTER_REPLY = 7; /** * A reply from a resolve request */ static final byte RESOLVE_REPLY = 8; /** * *** Not currently used *** */ static final byte LEASE_REPLY = 9; /** * *** Not currently used *** */ static final byte DEREGISTER_REPLY = 10; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/cns/CNS.java0000644000000000000000000020341611072626250016072 0ustar package org.jcsp.net2.cns; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import org.jcsp.lang.Alternative; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Guard; import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.Link; import org.jcsp.net2.LinkFactory; import org.jcsp.net2.NetAltingChannelInput; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelLocation; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.NetSharedChannelInput; import org.jcsp.net2.NetSharedChannelOutput; import org.jcsp.net2.NetworkMessageFilter; import org.jcsp.net2.Node; import org.jcsp.net2.NodeAddress; import org.jcsp.net2.NodeID; /** *

* This class is the Channel Name Server's main server process class. *

*

* This class should only be instantiated at Nodes wishing to run a server process. Although this class does not need to * be used by clients wishing to interact with a server, it does provide some convenient static methods for client code * to use. There are static versions of the methods provided in CNSService and there are also static * factory methods for constructing CNS registered channel objects. *

*

*

Server Installation

*

*

* Channel Name Servers may be run either on a dedicated Node or else on the same Node as one of the user Nodes. The * former approach is recommended for most situations but for smaller scale use, the latter approach may suffice. *

*

* The following example initialises a Node and installs a Channel Name Server. It then proceeds to install a CNS client * service and creates and resolves a channel. The example does not proceed to do anything else but could be used as the * framework for an application wishing to host its own Channel Name Server. *

*

* * import org.jcsp.lang.*;
* import org.jcsp.net2.*;
* import org.jcsp.net2.cns.*;
* import org.jcsp.net2.tcpip.*;
* import java.io.IOException;
* public class CNSInSameJVM implements CSProcess {
* //main method for running example
* public static void main(String[] args) {
* CNSInSameJVM proc = new CNSInSameJVM();
* proc.run();
* }
* public void run() {
* NodeKey key = null;
* NodeID localNodeID = null;
* try {
* //Initialize a Node that does not have a CNS client
* key = Node.getInstance().init(new TCPIPNodeAddress(7890));
* new ProcessManager(CNS.getInstance()).start();
* //Dedicated server code could stop here
* //Initialise the CNS client
* //use the local NodeID to connect to the CNS
* localNodeID = Node.getInstance().getNodeID();
* CNS.init(localNodeID);
* // creating Channel named "in"
* NetChannelInput in = CNS.net2one("in");
* //resolve the channel
* NetChannelOutput out = CNS.one2net("in");
* //could now use these channels for something!!
* //but this is only a test so will terminate
* } catch (NodeInitFailedException e) {
* e.printStackTrace();
* } catch (IOException e) {
* e.printStackTrace();
* }
* Node.log.log(this, "Done."); } }
*
*

*

*

Channel Factory Methods

*

*

* In order to construct a ChannelInput object which can be resolved by other users of a channel name * server, a client simply needs to to do this: *

* * NetChannelInput in = CNS.net2one("Fred"); * *

* Another process using the same channel name server can create a ChannelOutput that will send objects * to this channel by do this: *

* * NetChannelOutput out = CNS.one2net("Fred"); * *

* When these factory methods are called, various resources are used within the JCSP infrastructure. A channel name will * be registered and held in the channel name server. These resources are taken for the duration of the JCSP Node's * runtime. *

*

* This is an example "Hello World" program which contains two inner classes with main methods, each of which can be run * in separate JVMs. *

* *
 * import org.jcsp.lang.*;
 * import org.jcsp.net2.*;
 * import org.jcsp.net2.cns.*;
 * 
 * public class TestCNS
 * {
 *     public static class Rx
 *     {
 *         public static void main(String[] args)
 *         {
 *             try
 *             {
 *                 Node.getInstance().init(new TCPIPNodeAddress(7890));
 *                 NetChannelInput in = CNS.net2one("rx.in");
 *                 System.out.println(in.read());
 *             }
 *             catch (Exception e)
 *             {
 *                 e.printStackTrace();
 *             }
 *         }
 *     }
 * 
 *     public static class Tx
 *     {
 *         public static void main(String[] args)
 *         {
 *             try
 *             {
 *                 Node.getInstance().init(new TCPIPNodeAddress(7890));
 *                 NetChannelOutput out = CNS.one2net("rx.in");
 *                 out.write("Hello World");
 *             }
 *             catch (Exception e)
 *             {
 *                 e.printStackTrace();
 *             }
 *         }
 *     }
 * }
 * 
* *

* This code can be compiled and then the following run at two command prompts: *

*

* java TestCNS$Rx *

*

* java TestCNS$Tx *

*

* The programs will connect to a default channel name server. The Rx program will create a NetChannelInput * and wait for a message on the channel. Once it has received the message, it prints it, then terminates. The Tx * program creates a NetChannelOutput that will send to the Rx program's input channel. It sends a "Hello * World" message. Once this has been accepted by the Rx process, it terminates. *

*

* * @see CNSService * @see Node * @author Quickstone Technologies Limited * @author Kevin Chalmers (updates for new architecture) */ public class CNS implements CSProcess { /** * The internal service. This is used by the factory methods */ private static CNSService service; /** * Flag used to denote whether the CNS has been initialised */ private static boolean initialised = false; /** * Singleton instance of a CNS. Only one may be created on a Node */ private static final CNS instance = new CNS(); /** * The map of registered channels, name->location */ private final HashMap registeredChannels = new HashMap(); /** * The map of channels registered to a Node; NodeID-> */ private final HashMap channelRegister = new HashMap(); /** * The map of currently waiting resolves; name->reply-location */ private final HashMap waitingResolves = new HashMap(); /** * The map of currently logged clients; NodeID->reply-channel */ private final HashMap loggedClients = new HashMap(); /** * A channel used to receive incoming link lost notifications */ private final AltingChannelInput lostLink = Node.getInstance().getLinkLostEventChannel(); /** * Private empty constructor */ private CNS() { // Empty constructor } /** * Gets the singleton instance of the CNS * * @return The singleton instance of the CNS */ public static CNS getInstance() { return instance; } /** * Initialises the factory methods to allow creation of channels with the CNS * * @param cnsNode * The Node that the CNS is located on * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static void initialise(NodeID cnsNode) throws JCSPNetworkException { // First check that we are not already initialised if (CNS.initialised) throw new JCSPNetworkException("The CNS is already initialised"); // We are not initialised. Attempt to do so. // First, we need to create the CNSService CNS.service = new CNSService(cnsNode); // Now set initialised to true CNS.initialised = true; // We are now connected } /** * Initialises the factory methods to allow creation of channels with the CNS * * @param cnsNode * The Node that the CNS is located on * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static void initialise(NodeAddress cnsNode) throws JCSPNetworkException { // First check that we are not already initialised if (CNS.initialised) throw new JCSPNetworkException("The CNS is already initialised"); // We are not initialised. Attempt to do so. // First, we need to get the NodeID Link link = LinkFactory.getLink(cnsNode); // Now create the CNSService CNS.service = new CNSService(link.getRemoteNodeID()); // Now set initialised to true CNS.initialised = true; // We are now connected } /** * The run method for the CNS process */ public void run() { // Create the channel to receive incoming messages on. The index is 1. NetAltingChannelInput in = NetChannel.numberedNet2One(1, new CNSNetworkMessageFilter.FilterRX()); // Now we wish to alternate upon this channel, and the link lost channel Alternative alt = new Alternative(new Guard[] { this.lostLink, in }); // Loop forever while (true) { // Select next available Guard. Give priority to link failure switch (alt.priSelect()) { // We have lost the connection to a Node case 0: // Read in the NodeID of the lost Node NodeID lostNode = (NodeID)this.lostLink.read(); // Log loss of connection Node.log.log(this.getClass(), "Lost Link to: " + lostNode.toString()); // First remove the logged client this.loggedClients.remove(lostNode); // Next get the ArrayList of any channels registered by that Node ArrayList registeredChans = (ArrayList)this.channelRegister.get(lostNode); // If this ArrayList is null, we have no registrations. if (registeredChans != null) { // There are registered channels // Remove the list from the HashMap this.channelRegister.remove(lostNode); // Now remove all the channels registered by that Node for (Iterator iter = registeredChans.iterator(); iter.hasNext();) { String toRemove = (String)iter.next(); this.registeredChannels.remove(toRemove); Node.log.log(this.getClass(), toRemove + " deregistered"); } } break; // We have received a new incoming message case 1: { // Read in the message CNSMessage message = (CNSMessage)in.read(); // Now behave based on the type of the message switch (message.type) { // We have received a LOGON_MESSAGE case CNSMessageProtocol.LOGON_MESSAGE: { // Log the logon attempt Node.log.log(this.getClass(), "Logon received from: " + message.location1.getNodeID().toString()); // try-catch loop. We don't want the CNS to fail try { // Check if the Node is already logged on NetChannelOutput out = (NetChannelOutput)this.loggedClients.get(message.location1 .getNodeID()); // If out is null, no previous log on received if (out != null) { // This Node is already logged on. Send fail message // Log failed attempt Node.err.log(this.getClass(), message.location1.getNodeID().toString() + " already logged on. Rejecting"); // Create reply channel to the Node. NetChannelOutput toNewRegister = NetChannel.one2net(message.location1, new CNSNetworkMessageFilter.FilterTX()); // Create the reply message CNSMessage reply = new CNSMessage(); reply.type = CNSMessageProtocol.LOGON_REPLY_MESSAGE; reply.success = false; // Asynchronously write to Node. We don't want the CNS to block toNewRegister.asyncWrite(reply); // Destroy the temporary channel toNewRegister.destroy(); } else { // Node hasn't previously registered // Log registration Node.log.log(this.getClass(), message.location1.getNodeID().toString() + " successfully logged on"); // Create the reply channel NetChannelOutput toNewRegister = NetChannel.one2net(message.location1, new CNSNetworkMessageFilter.FilterTX()); // Add the Node and the reply channel to the logged clients table this.loggedClients.put(message.location1.getNodeID(), toNewRegister); // Create reply message CNSMessage reply = new CNSMessage(); reply.type = CNSMessageProtocol.LOGON_REPLY_MESSAGE; reply.success = true; // Write reply to the logging on Node asynchronously toNewRegister.asyncWrite(reply); } } catch (JCSPNetworkException jne) { // We do nothing. We have caught this to ensure nothing goes wrong during the I/O } break; } // A Node is attempting to register a channel case CNSMessageProtocol.REGISTER_REQUEST: { // Log registration Node.log.log(this.getClass(), "Registration for " + message.name + " received"); // Catch any JCSPNetworkException try { // Get the reply channel from our logged clients map NetChannelOutput out = (NetChannelOutput)this.loggedClients.get(message.location1 .getNodeID()); // Check if the Node has logged on with us if (out == null) { // The Node is not logged on. Send failure message Node.err.log(this.getClass(), "Registration failed. " + message.location1.getNodeID() + " not logged on"); // Create the channel to reply to out = NetChannel.one2net(message.location1, new CNSNetworkMessageFilter.FilterTX()); // Create the reply message CNSMessage reply = new CNSMessage(); reply.type = CNSMessageProtocol.REGISTER_REPLY; reply.success = false; // Write the reply asynchronously. Do not block the CNS out.asyncWrite(reply); // Destroy the temporary channel out.destroy(); } // The Node is registered, now check if the name is else if (this.registeredChannels.containsKey(message.name)) { // The name is already registered. Inform the register // Log the failed registration Node.err.log(this.getClass(), "Registration failed. " + message.name + " already registered"); // Create reply message CNSMessage reply = new CNSMessage(); reply.type = CNSMessageProtocol.REGISTER_REPLY; reply.success = false; // Write the reply asynchronously. Do not block the CNS out.asyncWrite(reply); } else { // Name is not already registered. // Log successful registration Node.log.log(this.getClass(), "Registration of " + message.name + "succeded"); // Now check if any client end is waiting for this name ArrayList pending = (ArrayList)this.waitingResolves.get(message.name); if (pending != null) { // We have waiting resolves. Complete for (Iterator iter = pending.iterator(); iter.hasNext();) { NetChannelOutput toPending = null; // We now catch internally any JCSPNetworkExceptions try { // Get the next waiting message CNSMessage msg = (CNSMessage)iter.next(); // Log resolve completion Node.log.log(this.getClass(), "Queued resolve of " + message.name + " by " + msg.location1.getNodeID() + " completed"); // Create the channel to the resolver toPending = NetChannel.one2net(msg.location1, new CNSNetworkMessageFilter.FilterTX()); // Create the reply message CNSMessage reply = new CNSMessage(); reply.type = CNSMessageProtocol.RESOLVE_REPLY; reply.location1 = message.location2; reply.success = true; // Write the reply asynchronously to the waiting resolver toPending.asyncWrite(reply); } catch (JCSPNetworkException jne) { // Something went wrong as we tried to send the resolution completion. // Do nothing } finally { // Destroy the temporary channel if necessary if (toPending != null) toPending.destroy(); } } // Remove the name from the pending resolves this.waitingResolves.remove(message.name); } // We have completed any pending resolves on this channel. Now we register the // channel this.registeredChannels.put(message.name, message.location2); // Now we add the registered channel to the channels registered by this Node ArrayList registered = (ArrayList)this.channelRegister.get(message.location1 .getNodeID()); // If the ArrayList is null, we have no previous registrations if (registered == null) { // Create a new ArrayList to store the registered names with registered = new ArrayList(); // Add it to the channel register this.channelRegister.put(message.location1.getNodeID(), registered); } // Add the name to the ArrayList registered.add(message.name); // Log the successful registration Node.log.log(this.getClass(), message.name + " registered to " + message.location2); // Create the reply message CNSMessage reply = new CNSMessage(); reply.type = CNSMessageProtocol.REGISTER_REPLY; reply.success = true; // Write it asynchronously to the registering Node out.asyncWrite(reply); } } catch (JCSPNetworkException jne) { // Something went wrong during the I/O operations. Ignore } } break; // We have received a resolve request case CNSMessageProtocol.RESOLVE_REQUEST: { // Log resolve request Node.log.log(this.getClass(), "Resolve request for " + message.name + " received"); // Catch any JCSP Network Exception try { // Check if the resolving Node is logged on NetChannelOutput out = (NetChannelOutput)this.loggedClients.get(message.location1 .getNodeID()); // If the channel is null, then the Node has yet to log on with us if (out == null) { // Node is not logged on // Log failed resolution Node.err.log(this.getClass(), "Resolve failed. " + message.location1.getNodeID() + " not logged on"); // Create connection to the resolver out = NetChannel.one2net(message.location1, new CNSNetworkMessageFilter.FilterTX()); // Create the reply message CNSMessage reply = new CNSMessage(); reply.type = CNSMessageProtocol.RESOLVE_REPLY; reply.success = false; // Write message asynchronously to the Node out.asyncWrite(reply); // Destroy temporary channel out.destroy(); } else { // Node is logged on. Now we check if the name is already registered NetChannelLocation loc = (NetChannelLocation)this.registeredChannels .get(message.name); // If the location is null, then the name has yet to be registered. if (loc == null) { // The name is not registered. We need to queue the resolve until it does // Log the queueing of the resolve Node.log.log(this.getClass(), message.name + " not registered. Queueing resolve by " + message.location1.getNodeID().toString()); // Check if any other resolvers are waiting for the channel ArrayList pending = (ArrayList)this.waitingResolves.get(message.name); // If the ArrayList is null, no one else is waiting if (pending == null) { // No one else is waiting. Create a new list and add it to the waiting // resolves pending = new ArrayList(); this.waitingResolves.put(message.name, pending); } // Add this resolve message to the list of waiting resolvers pending.add(message); } else { // The location is not null. Send it to the resolver // Log successful resolution Node.log.log(this.getClass(), "Resolve request completed. " + message.name + " location being sent to " + message.location1.getNodeID()); // Create channel to the resolver NetChannelOutput toPending = NetChannel.one2net(message.location1, new CNSNetworkMessageFilter.FilterTX()); // Create the reply message CNSMessage reply = new CNSMessage(); reply.type = CNSMessageProtocol.RESOLVE_REPLY; reply.location1 = loc; reply.success = true; // Write the reply to the resolver asynchronously toPending.asyncWrite(reply); // Destroy the temporary channel toPending.destroy(); } } } catch (JCSPNetworkException jne) { // Something went wrong during the I/O. Ignore. Do not bring down the CNS } break; } } } } } } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @deprecated Use net2one instead * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput createNet2One(String name) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.net2one(); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @deprecated Use net2any instead * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput createNet2Any(String name) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.net2any(); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @deprecated Use one2net instead * @return A new NetChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput createOne2Net(String name) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.one2net(loc); } /** * Creates a new NetSharedChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @deprecated Use one2net instead * @return A new NetChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput createAny2Net(String name) throws JCSPNetworkException, IllegalStateException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.any2net(loc); } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput net2one(String name) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.net2one(); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @param immunityLevel * The immunity to poison the channel has * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput net2one(String name, int immunityLevel) throws IllegalArgumentException, IllegalStateException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.net2one(immunityLevel); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput net2one(String name, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException, IllegalStateException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.net2one(filter); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @param immunityLevel * The immunity level to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput net2one(String name, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException, IllegalStateException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.net2one(immunityLevel, filter); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput net2any(String name) throws IllegalArgumentException, IllegalStateException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.net2any(); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @param immunityLevel * The immunity level to poison that the channel has * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput net2any(String name, int immunityLevel) throws IllegalArgumentException, IllegalStateException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.net2any(immunityLevel); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput net2any(String name, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException, IllegalStateException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.net2any(filter); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput net2any(String name, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException, IllegalStateException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.net2any(immunityLevel, filter); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @param index * The index to create the channel with * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput numberedNet2One(String name, int index) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.numberedNet2One(index); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @param index * The index to create the channel with * @param immunityLevel * The immunity level to poison that the channel has * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput numberedNet2One(String name, int index, int immunityLevel) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.numberedNet2One(index, immunityLevel); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput numberedNet2One(String name, int index, NetworkMessageFilter.FilterRx filter) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.numberedNet2One(index, filter); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetAltingChannelInput registered with the given name * * @param name * The name to register with the CNS * @param index * The index to create the channel with * @param immunityLevel * The immunity level to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetAltingChannelInput numberedNet2One(String name, int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetAltingChannelInput toReturn = NetChannel.numberedNet2One(index, immunityLevel, filter); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @param index * The index to create the channel with * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput numberedNet2Any(String name, int index) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.numberedNet2Any(index); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that this channel has * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput numberedNet2Any(String name, int index, int immunityLevel) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.numberedNet2Any(index, immunityLevel); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput numberedNet2Any(String name, int index, NetworkMessageFilter.FilterRx filter) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.numberedNet2Any(index, filter); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetSharedChannelInput registered with the given name * * @param name * The name to register with the CNS * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput registered with the given name * @throws IllegalStateException * Thrown if the CNS has not been initialised * @throws IllegalArgumentException * Thrown if the channel name is already registered */ public static NetSharedChannelInput numberedNet2Any(String name, int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalStateException, IllegalArgumentException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Create a new channel NetSharedChannelInput toReturn = NetChannel.numberedNet2Any(index, immunityLevel, filter); // Attempt to register if (CNS.service.register(name, toReturn)) return toReturn; // Failed to register channel. Destroy the channel and throw exception toReturn.destroy(); throw new IllegalArgumentException("Failed to register " + name + " with the CNS"); } /** * Creates a new NetChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @return A new NetChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(String name) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.one2net(loc); } /** * Creates a new NetChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @param immunityLevel * The immunity to poison that this channel has * @return A new NetChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(String name, int immunityLevel) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.one2net(loc, immunityLevel); } /** * Creates a new NetChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(String name, NetworkMessageFilter.FilterTx filter) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.one2net(loc, filter); } /** * Creates a new NetChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(String name, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.one2net(loc, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @return A new NetSharedChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(String name) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.any2net(loc); } /** * Creates a new NetSharedChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @param immunityLevel * The immunity to poison that this channel has * @return A new NetSharedChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(String name, int immunityLevel) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.any2net(loc, immunityLevel); } /** * Creates a new NetSharedChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(String name, NetworkMessageFilter.FilterTx filter) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.any2net(loc, filter); } /** * Creates a new NetSharedChannelOutput connected to the input channel registered with the given name * * @param name * The name to resolve * @param immunityLevel * The immunity level to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput connected to the input with the registered name * @throws IllegalStateException * Thrown if the connection to the CNS is not initialised * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(String name, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws IllegalStateException, JCSPNetworkException { // Check if the CNS connection is initialised if (!CNS.initialised) throw new IllegalStateException("The connection to the CNS has not been initialised"); // Resolve the location of the channel NetChannelLocation loc = CNS.service.resolve(name); // Create and return a new channel return NetChannel.any2net(loc, filter); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NodeAddress.java0000644000000000000000000001203211072626250017047 0ustar package org.jcsp.net2; import java.io.Serializable; import java.util.Hashtable; /** * This abstract class defines encapsulates the address of a Node within a JCSP networked system. Specific protocols * must provide concrete implementations of this class to allow Node initialisation and connection. One concrete example * is provided in the org.jcsp.net2.tcpip package. * * @see Node * @author Kevin Chalmers (updated from Quickstone Technologies) */ public abstract class NodeAddress implements Serializable, Comparable { /** * String representing the protocol in used */ protected String protocol; /** * String representation of the address */ protected String address; /** * The table of installed protocols on this Node */ private static Hashtable installedProtocols = new Hashtable(); /** * Gets the string representing the protocol * * @return The String representation of the protocol part of the NodeAddress */ public String getProtocol() { return this.protocol; } /** * Gets a string representing the address * * @return The String representation of the address part of the NodeAddress */ public String getAddress() { return this.address; } /** * Converts the NodeAddress into a String. The form is [protocol]\\[address] * * @return A String representation of this NodeAddress */ public String toString() { return this.protocol + "\\\\" + this.address; } /** * Gets the hash code of this object * * @return Hashcode for this NodeAddress */ public int hashCode() { return this.address.hashCode(); } /** * Checks if this NodeAddress is equal to another * * @param obj * The NodeAddress to compare to * @return True if object is equal to this NodeAddress, false otherwise */ public boolean equals(final Object obj) { if (!(obj instanceof NodeAddress)) return false; NodeAddress other = (NodeAddress)obj; return (this.protocol.equals(other.protocol) && this.address.equals(other.address)); } /** * Compares this NodeAddress to another * * @param arg0 * The NodeAddress to compare to * @return 1 if object is greater than this one, 0 if they are equal, -1 otherwise */ public int compareTo(final Object arg0) { if (!(arg0 instanceof NodeAddress)) return -1; NodeAddress other = (NodeAddress)arg0; if (!this.protocol.equals(other.protocol)) return this.protocol.compareTo(other.protocol); return this.address.compareTo(other.address); } /** * Creates a Link connected to this address * * @return A new Link connected to this address * @throws JCSPNetworkException * If something goes wrong during the creation of the Link */ protected abstract Link createLink() throws JCSPNetworkException; /** * Creates a LinkServer listening on this address * * @return A new LinkServer listening on this address * @throws JCSPNetworkException * If something goes wrong during the creation of the LinkServer */ protected abstract LinkServer createLinkServer() throws JCSPNetworkException; /** * Retrieves the correct protocol handler for the implemented address type. This is used during Node initialisation * * @return the ProtocolID for this address type */ protected abstract ProtocolID getProtocolID(); /** * Parses a string representation of a NodeAddress back to its object form * * @param str * The string to parse * @return A new NodeAddress created from a String form * @throws IllegalArgumentException * Thrown if the string is not for a recognised protocol. */ public static NodeAddress parse(String str) throws IllegalArgumentException { int index = str.indexOf("\\\\"); ProtocolID protocol = (ProtocolID)NodeAddress.installedProtocols.get(str.substring(0, index)); if (protocol != null) { return protocol.parse(str.substring(index+4)); } throw new IllegalArgumentException("Unknown protocol used for parsing NodeAddress"); } /** * Installs a new Protocol on the Node * * @param name * Name of the protocol to install * @param protocol * ProtocolID installed */ public synchronized static void installProtocol(String name, ProtocolID protocol) { if (!NodeAddress.installedProtocols.containsKey(name)) NodeAddress.installedProtocols.put(name, protocol); // If the protocol is already installed, we do nothing. } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/BarrierDataState.java0000644000000000000000000000175411072626250020046 0ustar package org.jcsp.net2; /** * Describes the possible states that a networked Barrier might be in. * * @author Kevin Chalmers */ final class BarrierDataState { /** * Empty private constructor. This is simply a protocol. */ private BarrierDataState() { // Empty constructor } /** * Barrier is inactive. It has not been initialised yet. */ static final byte INACTIVE = 0; /** * Barrier is in OK state, and is a server end. Has been initialised. */ static final byte OK_SERVER = 1; /** * Barrier is in OK state, and is a client end. Has been initialised */ static final byte OK_CLIENT = 2; /** * Barrier is broken. */ static final byte BROKEN = 3; /** * Barrier has been destroyed */ static final byte DESTROYED = 4; /** * Barrier has resigned from the server front end. */ static final byte RESIGNED = 5; } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetAltingConnectionServer.java0000644000000000000000000000673211072626250021762 0ustar package org.jcsp.net2; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.AltingConnectionServer; import org.jcsp.lang.Any2OneChannel; import org.jcsp.lang.Channel; import org.jcsp.util.InfiniteBuffer; public final class NetAltingConnectionServer extends AltingConnectionServer implements NetConnectionServer { private final AltingChannelInput requestIn; private final AltingChannelInput openIn; private final NetConnectionLocation location; private final NetworkMessageFilter.FilterRx inputFilter; private final NetworkMessageFilter.FilterTx outputFilter; private final ConnectionData data; private final NetworkMessage lastRead = null; private final Link linkConnectedTo = null; static NetAltingConnectionServer create(int index, NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX) throws IllegalArgumentException { ConnectionData data = new ConnectionData(); Any2OneChannel requestChan = Channel.any2one(new InfiniteBuffer()); Any2OneChannel openChan = Channel.any2one(new InfiniteBuffer()); data.toConnection = requestChan.out(); data.openServer = openChan.out(); data.state = ConnectionDataState.SERVER_STATE_CLOSED; ConnectionManager.getInstance().create(index, data); return new NetAltingConnectionServer(openChan.in(), requestChan.in(), data, filterRX, filterTX); } static NetAltingConnectionServer create(NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX) { ConnectionData data = new ConnectionData(); Any2OneChannel requestChan = Channel.any2one(new InfiniteBuffer()); Any2OneChannel openChan = Channel.any2one(new InfiniteBuffer()); data.toConnection = requestChan.out(); data.openServer = openChan.out(); data.state = ConnectionDataState.SERVER_STATE_CLOSED; ConnectionManager.getInstance().create(data); return new NetAltingConnectionServer(openChan.in(), requestChan.in(), data, filterRX, filterTX); } private NetAltingConnectionServer(AltingChannelInput openChan, AltingChannelInput requestChan, ConnectionData connData, NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX) throws JCSPNetworkException { super(openChan); this.openIn = openChan; this.requestIn = requestChan; this.data = connData; this.inputFilter = filterRX; this.outputFilter = filterTX; this.location = new NetConnectionLocation(Node.getInstance().getNodeID(), this.data.vconnn); } public void destroy() { // TODO Auto-generated method stub } public NetLocation getLocation() { // TODO Auto-generated method stub return null; } public void reply(Object data, boolean close) throws IllegalStateException { // TODO Auto-generated method stub } public void reply(Object data) throws IllegalStateException { // TODO Auto-generated method stub } public void replyAndClose(Object data) throws IllegalStateException { // TODO Auto-generated method stub } public Object request() throws IllegalStateException { // TODO Auto-generated method stub return null; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/Net2OneChannel.java0000644000000000000000000006600511072626250017430 0ustar package org.jcsp.net2; import java.io.IOException; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.Any2OneChannel; import org.jcsp.lang.Channel; import org.jcsp.net2.NetworkMessageFilter.FilterRx; import org.jcsp.util.InfiniteBuffer; /** * A concrete implementation of a NetAltingChannelInput. This is a hidden class created by the architecture. To create * an instance of this object, use the NetChannel factory, or the CNS. * * @see NetChannelInput * @see NetAltingChannelInput * @see NetChannel * @author Kevin Chalmers (updated from Quickstone Technologies) */ final class Net2OneChannel extends NetAltingChannelInput { /** * The input channel coming into the networked channel input object from Links or locally connected net channel * outputs. */ private final AltingChannelInput in; /** * The ChannelData structure representing this channel. */ private final ChannelData data; /** * The lastRead ChannelMessage. Used during an extended read operation to allow the ACK message to be sent to the * correct Node. */ private NetworkMessage lastRead = null; /** * The filter used to convert the incoming byte array into an object */ private NetworkMessageFilter.FilterRx messageFilter; /** * The location of this channel */ private final NetChannelLocation location; /** * Static factory method used to create a new Net2OneChannel. Used internally within the architecture. * * @param poisonImmunity * The immunity level of the channel * @param filter * The filter on the channel used to convert read bytes into an object * @return A new Net2OneChannel */ static Net2OneChannel create(int poisonImmunity, NetworkMessageFilter.FilterRx filter) { // Create a new ChannelData object ChannelData data = new ChannelData(); // Create a new infinitely buffered any2one channel connecting the Links to the channel object Any2OneChannel chan = Channel.any2one(new InfiniteBuffer()); // Add the output end to the ChannelData object data.toChannel = chan.out(); // Set the immunity level data.immunityLevel = poisonImmunity; // Initialise the ChannelData object with the ChannelManager ChannelManager.getInstance().create(data); // Return a new Net2OneChannel return new Net2OneChannel(chan.in(), data, filter); } /** * Static factory method used to create a new Net2OneChannel with a given index. Used internally within the * architecture * * @param index * The index to create the channel with * @param poisonImmunity * The immunity level of the channel * @param filter * The filter used to take the incoming byte array and convert it into an object * @return A new Net2OneChannel * @throws IllegalArgumentException * Thrown if the index given is already allocated within the ChannelManager */ static Net2OneChannel create(int index, int poisonImmunity, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { // Create a new ChannelData object ChannelData data = new ChannelData(); // Create a new infinitely buffered any2one channel connecting the Links to the channel object Any2OneChannel chan = Channel.any2one(new InfiniteBuffer()); // Add the output end to the ChannelData object data.toChannel = chan.out(); // Set the immunity level data.immunityLevel = poisonImmunity; // Initialise the ChannelData object with the ChannelManager. Use the index given ChannelManager.getInstance().create(index, data); // Return a new Net2OneChannel return new Net2OneChannel(chan.in(), data, filter); } /** * Private constructor for creating a new instance of a Net2OneChannel. This is called by the create method to * create the channel. * * @param input * The input channel connecting to the networked channel. * @param chanData * The ChannelData object representing the networked channel. * @param filter * The filter used to convert the incoming byte array to an object * @throws JCSPNetworkException */ private Net2OneChannel(AltingChannelInput input, ChannelData chanData, NetworkMessageFilter.FilterRx filter) throws JCSPNetworkException { // Set the wrapper's alting channel input so the channel can be used as a guard super(input); // Set the various properties this.in = input; this.data = chanData; this.data.state = ChannelDataState.OK_INPUT; this.location = new NetChannelLocation(Node.getInstance().getNodeID(), this.data.vcn); this.messageFilter = filter; } /** * Ends an extended read operation. * * @throws IllegalStateException * Thrown if the method is called when the channel is not in an extended read state * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws NetworkPoisonException * Thrown if the channel has been poisoned */ public void endRead() throws IllegalStateException, JCSPNetworkException, NetworkPoisonException { // First check the state of the channel. These are sanity checks. Really, if the channel is in an extended // read state then it should not be destroyed or poisoned if (this.data.state == ChannelDataState.DESTROYED) throw new JCSPNetworkException("The channel has been destroyed"); if (this.data.state == ChannelDataState.POISONED) throw new NetworkPoisonException(this.data.poisonLevel); // Now check if a extended read is in progress if (this.lastRead != null) { // We are performing an extended read. Now check if we should be actually sending a reply if (this.lastRead.type != NetworkProtocol.ASYNC_SEND) { // The last message wasn't an asynchronous send, therefore we need to send the ACK // Create ACK message NetworkMessage ack = new NetworkMessage(); ack.type = NetworkProtocol.ACK; // Destination is source of lastRead ack.attr1 = this.lastRead.attr2; // Attribute 2 is not used ack.attr2 = -1; // Write the acknowledgement back to the sender this.lastRead.toLink.write(ack); } // Set the lastRead to null. End of extended read operation this.lastRead = null; } else { // We are not performing an extended read. This is a problem. Thrown an exception throw new IllegalStateException("End read was called on a channel not in an extended read state"); } } /** * Checks if any data is waiting on the channel. * * @return True if data is ready, false otherwise. * @throws JCSPNetworkException * Thrown if the channel has been destroyed * @throws NetworkPoisonException * Thrown if the channel has poisoned */ public boolean pending() throws JCSPNetworkException, NetworkPoisonException { // First check the state of the channel. if (this.data.state == ChannelDataState.DESTROYED) throw new JCSPNetworkException("The channel has been destroyed"); if (this.data.state == ChannelDataState.POISONED) throw new NetworkPoisonException(this.data.poisonLevel); // Return if the channel has any pending messages return this.in.pending(); } /** * Poisons the underlying channel * * @param strength * The strength of the poison */ public void poison(int strength) { // First check the state of the channel if (this.data.state == ChannelDataState.DESTROYED) // In this case we do nothing. Destroyed is considered stronger than poisoned return; // Now check if the strength of the poison is greater than a previous poison if (strength > this.data.poisonLevel) { // Change the current poison level this.data.poisonLevel = strength; // Now check if the poison level is strong enough to poison us. if (strength > this.data.immunityLevel) { // The poison is strong enough. We need to change our state to poisoned. // We need to lock on the state to ensure no link is using it as we change it synchronized (this.data) { // Now change our state this.data.state = ChannelDataState.POISONED; } // Are we extended? If so send poison back there first if (this.lastRead != null) { // We are extended. Send poison as an acknowledgement NetworkMessage poison = new NetworkMessage(); poison.type = NetworkProtocol.POISON; poison.attr1 = this.lastRead.attr2; poison.attr2 = this.data.poisonLevel; this.lastRead.toLink.write(poison); this.lastRead = null; } // Now we must send POISON to any waiting SEND messages while (this.in.pending()) { // We have an incoming message. Read the message. NetworkMessage pending = (NetworkMessage)this.in.read(); switch (pending.type) { // We have three possible outcomes. Either the message is a send of some sort, another poison, // or neither of these (which should not be really possible) // We must reply to sends with a POISON case NetworkProtocol.SEND: case NetworkProtocol.ASYNC_SEND: // Create a new POISON message NetworkMessage poison = new NetworkMessage(); poison.type = NetworkProtocol.POISON; // Destination is the source of the previous message poison.attr1 = pending.attr2; // Attribute 2 is the poison level poison.attr2 = this.data.poisonLevel; // Write poison message to the channel attached to pending message pending.toLink.write(poison); break; case NetworkProtocol.POISON: // We have received another poison message. We now check if it is stronger than the previous // poison. if (pending.attr2 > this.data.poisonLevel) { // We have stronger poison. Increase the poison level this.data.poisonLevel = pending.attr2; } // Poison is not greater than the previous poison. Do nothing. break; default: // In any other case, we do nothing. break; } } } // Poison is not above our immunity level. Do nothing. } // Strength of the poison is not above our previous poison level. Do nothing. } /** * Reads the next message from the channel * * @return The message read from the channel * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws NetworkPoisonException * Thrown if the channel is poisoned * @throws IllegalStateException * Thrown if the channel is in an extended read state */ public Object read() throws JCSPNetworkException, NetworkPoisonException, IllegalStateException { // First check our state if (this.data.state == ChannelDataState.DESTROYED) throw new JCSPNetworkException("Channel has been destroyed"); if (this.data.state == ChannelDataState.POISONED) throw new NetworkPoisonException(this.data.poisonLevel); // Now check if we are in an extended read state if (this.lastRead != null) { // We are in an extended read. Throw exception throw new IllegalStateException("The channel is in an extended read state"); } // We are in an OK state to perform a read. // We need to loop until we return a message, or throw an exception while (true) { // Read in the next message NetworkMessage msg = (NetworkMessage)this.in.read(); // Now we need to decode the message and act accordingly try { switch (msg.type) { // We can either receive a SEND, ASYNC_SEND, or POISON message case NetworkProtocol.SEND: { // We have received a SEND // Convert the message into the object again. This may throw an IOException Object toReturn = this.messageFilter.filterRX(msg.data); // We have a SEND, we need to acknowledge. // Create an ACK message NetworkMessage ack = new NetworkMessage(); ack.type = NetworkProtocol.ACK; // Destination is source of the previous message ack.attr1 = msg.attr2; // Attribute 2 is unused ack.attr2 = -1; // Write ACK to the channel attached to the message msg.toLink.write(ack); // Return read object return toReturn; } case NetworkProtocol.ASYNC_SEND: { // We have received an ASYNC_SEND // Convert the message into the object again. This may throw an IOException Object toReturn = this.messageFilter.filterRX(msg.data); // Return read object return toReturn; } case NetworkProtocol.POISON: // First we change our poison level. Poison level is Attribute 2 of the message this.data.poisonLevel = msg.attr2; // The Link checked our immunity level, so this poison message must be greater than our immunity // We need to lock on the state to ensure no link is using it as we change it synchronized (this.data) { // Now change our state this.data.state = ChannelDataState.POISONED; } // Now we must send POISON to any waiting SEND messages while (this.in.pending()) { // We have an incoming message. Read the message. NetworkMessage pending = (NetworkMessage)this.in.read(); switch (pending.type) { // We have three possible outcomes. Either the message is a send of some sort, another // poison, or neither of these (which should not be really possible) // We must reply to sends with a POISON case NetworkProtocol.SEND: case NetworkProtocol.ASYNC_SEND: // Create a new POISON message NetworkMessage poison = new NetworkMessage(); poison.type = NetworkProtocol.POISON; // Destination is the source of the previous message poison.attr1 = pending.attr2; // Attribute 2 is the poison level poison.attr2 = this.data.poisonLevel; // Write poison message to the channel attached to pending message pending.toLink.write(poison); break; case NetworkProtocol.POISON: // We have received another poison message. We now check if it is stronger than the // previous poison. if (pending.attr2 > this.data.poisonLevel) { // We have stronger poison. Increase the poison level this.data.poisonLevel = pending.attr2; } // Poison is not greater than the previous poison. Do nothing. break; default: // In any other case, we do nothing. break; } } // We now throw the poison exception throw new NetworkPoisonException(this.data.poisonLevel); } } // The filter may have thrown an IOException. Deal with it here and throw a JCSPNetworkException instead catch (IOException ioe) { throw new JCSPNetworkException("Incoming message was corrupted"); } } } /** * Performs an extended read operation on the channel * * @return The message read from the channel * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws IllegalStateException * Thrown if the channel is already in an extended read state * @throws NetworkPoisonException * Thrown if the channel is poisoned. */ public Object startRead() throws JCSPNetworkException, IllegalStateException, NetworkPoisonException { // First check our state if (this.data.state == ChannelDataState.DESTROYED) throw new JCSPNetworkException("Channel has been destroyed"); if (this.data.state == ChannelDataState.POISONED) throw new NetworkPoisonException(this.data.poisonLevel); // Now check if we are in an extended read state if (this.lastRead != null) { // We are in an extended read. Throw exception throw new IllegalStateException("The channel is in an extended read state"); } // We are in an OK state to perform a read. // We need to loop until we return a message, or throw an exception while (true) { // Read in the next message NetworkMessage msg = (NetworkMessage)this.in.read(); // Now we need to decode the message and act accordingly try { switch (msg.type) { // We can either receive a SEND, ASYNC_SEND, or POISON message case NetworkProtocol.SEND: case NetworkProtocol.ASYNC_SEND: { // We have received a SEND or ASYNC_SEND // Convert the message into the object again. This may throw an IOException Object toReturn = this.messageFilter.filterRX(msg.data); // Now set the lastRead to the incoming message so we can acknowledge during the endRead // operation this.lastRead = msg; return toReturn; } case NetworkProtocol.POISON: // First we change our poison level. Poison level is Attribute 2 of the message this.data.poisonLevel = msg.attr2; // The Link checked our immunity level, so this poison message must be greater than our immunity // We need to lock on the state to ensure no link is using it as we change it synchronized (this.data) { // Now change our state this.data.state = ChannelDataState.POISONED; } // Now we must send POISON to any waiting SEND messages while (this.in.pending()) { // We have an incoming message. Read the message. NetworkMessage pending = (NetworkMessage)this.in.read(); switch (pending.type) { // We have three possible outcomes. Either the message is a send of some sort, another // poison, or neither of these (which should not be really possible) // We must reply to sends with a POISON case NetworkProtocol.SEND: case NetworkProtocol.ASYNC_SEND: // Create a new POISON message NetworkMessage poison = new NetworkMessage(); poison.type = NetworkProtocol.POISON; // Destination is the source of the previous message poison.attr1 = pending.attr2; // Attribute 2 is the poison level poison.attr2 = this.data.poisonLevel; // Write poison message to the channel attached to pending message pending.toLink.write(poison); break; case NetworkProtocol.POISON: // We have received another poison message. We now check if it is stronger than the // previous poison. if (pending.attr2 > this.data.poisonLevel) { // We have stronger poison. Increase the poison level this.data.poisonLevel = pending.attr2; } // Poison is not greater than the previous poison. Do nothing. break; default: // In any other case, we do nothing. break; } } // We now throw the poison exception throw new NetworkPoisonException(this.data.poisonLevel); } } // The filter may have thrown an IOException. Deal with it here and throw a JCSPNetworkException instead catch (IOException ioe) { throw new JCSPNetworkException("Incoming message was corrupted"); } } } /** * Returns the NetChannelLocation of the channel * * @return Location of this channel */ public NetLocation getLocation() { return this.location; } /** * Destroys the underlying channel */ public void destroy() { // First acquire a lock on the channel synchronized (this.data) { // Now we can change our state this.data.state = ChannelDataState.DESTROYED; } // Remove the channel from the ChannelManager ChannelManager.getInstance().removeChannel(this.data); // Check if we are in an extended read. If so we need to reject the last message if (this.lastRead != null) { // We are extended. Send a reject to the pending message NetworkMessage reject = new NetworkMessage(); reject.type = NetworkProtocol.REJECT_CHANNEL; reject.attr1 = this.lastRead.attr2; reject.attr2 = -1; this.lastRead.toLink.write(reject); this.lastRead = null; } // Now we must reject any incoming messages, except poison while (this.in.pending()) { // We have a pending message. Deal with it. NetworkMessage msg = (NetworkMessage)this.in.read(); // Check that it is not a poison if (msg.type != NetworkProtocol.POISON) { // The message is not a poison message, and therefore must be a send or some type. Reject the message // Create REJECT_CHANNEL message NetworkMessage reject = new NetworkMessage(); reject.type = NetworkProtocol.REJECT_CHANNEL; // Destination is the source of the incoming message reject.attr1 = msg.attr2; // Attribute 2 is not used reject.attr2 = -1; // Write reject to the channel attached to the incoming message msg.toLink.write(reject); } } } /** * Gets the channel data object for this channel. * * @return The ChannelData for this Channel */ final ChannelData getChannelData() { return this.data; } /** * Sets the underlying message filter * * @param decoder * The message filter to use */ public void setDecoder(FilterRx decoder) { this.messageFilter = decoder; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/RawNetworkMessageFilter.java0000644000000000000000000000353111072626250021436 0ustar package org.jcsp.net2; import java.io.IOException; /** * A NetworkMessageFilter used to send and receive raw byte data. * * @see NetworkMessageFilter * @author Kevin Chalmers */ public final class RawNetworkMessageFilter { /** * The receiving filter * * @author Kevin Chalmers */ public static final class FilterRX implements NetworkMessageFilter.FilterRx { /** * Creates a new RawNetworkMessageFilter.FilterRX */ public FilterRX() { // Nothing to do } /** * Decodes an incoming byte array. Does nothing * * @param bytes * The bytes received in an incoming message * @return The same bytes as is passed in */ public Object filterRX(byte[] bytes) { return bytes; } } /** * The sending Filter * * @author Kevin Chalmers */ public static final class FilterTX implements NetworkMessageFilter.FilterTx { /** * Creates a new output filter */ public FilterTX() { // Nothing to do } /** * Will send a byte array as raw bytes * * @param obj * The object to send. This must be a byte array * @return The same byte array as sent in * @throws IOException * Thrown if the sent object is not a byte array */ public byte[] filterTX(Object obj) throws IOException { if (!(obj instanceof byte[])) throw new IOException("Raw data filter received an object that was not a byte[]"); return (byte[])obj; } } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ChannelManager.java0000644000000000000000000000727511072626250017534 0ustar package org.jcsp.net2; import java.util.Hashtable; /** * A class used to manage the networked channels on the Node. This is an internal object to JCSP networking. For a * description of networked channels, see the relevant documentation. * * @see org.jcsp.net2.NetChannelInput * @see org.jcsp.net2.NetChannelOutput * @author Kevin Chalmers */ final class ChannelManager { /** * The index for the next channel to be created. We start at 50 as it allows us to have up to 50 default channels, * for example for use to connect to a Channel Name Server. */ private static int index = 50; /** * The table containing the channels. An Integer (object wrapped int) is used as the key, and the ChannelData as the * value. */ private final Hashtable channels = new Hashtable(); /** * Singleton instance of the ChannelManager */ private static ChannelManager instance = new ChannelManager(); /** * Private default constructor. Used for the singleton instance. */ private ChannelManager() { // Empty constructor } /** * Allows getting of the singleton instance. * * @return The singleton instance of the ChannelManager */ static ChannelManager getInstance() { return instance; } /** * Allocates a new number to the channel, and stores it in the table. * * @param cd * The ChannelData for the channel */ synchronized void create(ChannelData cd) { // First allocate a new number for the channel Integer objIndex = new Integer(index); while (this.channels.get(objIndex) != null) objIndex = new Integer(++index); // Set the index of the ChannelData cd.vcn = index; // Now put the channel in the channel Hashtable this.channels.put(objIndex, cd); // Finally increment the index for the next channel to be created index++; } /** * Stores a channel in the given index in the table. * * @param idx * The index to use for the channel * @param cd * The ChannelData for the channel * @throws IllegalArgumentException * If a channel of the given index already exists. */ synchronized void create(int idx, ChannelData cd) throws IllegalArgumentException { // First check that a channel of the given index does not exist. If it does, throw an exception Integer objIndex = new Integer(idx); if (this.channels.get(objIndex) != null) throw new IllegalArgumentException("Channel of given number already exists."); // Set the index of the channel data cd.vcn = idx; // Now add the channel to the channels table this.channels.put(objIndex, cd); // Update the index if necessary if (idx == ChannelManager.index) ChannelManager.index++; } /** * Retrieves a channel from the table * * @param idx * Index in the table to retrieve the channel from. * @return The ChannelData object for the channel. */ ChannelData getChannel(int idx) { Integer objIndex = new Integer(idx); return (ChannelData)this.channels.get(objIndex); } /** * Removes a channel from the table. * * @param data * ChannelData for channel to remove */ void removeChannel(ChannelData data) { Integer objIndex = new Integer(data.vcn); this.channels.remove(objIndex); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetChannel.java0000644000000000000000000007231311072626250016703 0ustar /** * */ package org.jcsp.net2; /** * A static factory object used to create networked channels. This class basically wraps around a * StandardNetChannelEndFactory and allows static access to its channel creation methods. * * @see NetChannelEndFactory * @see StandardNetChannelEndFactory * @author Kevin Chalmers */ public final class NetChannel { /** * The factory used to create the networked channels */ private static StandardNetChannelEndFactory factory = new StandardNetChannelEndFactory(); /** * Empty, private default constructor. This is a static access class. */ private NetChannel() { // Empty constructor } /** * Creates a new NetAltingChannelInput * * @deprecated Use net2one instead * @return A new NetAltingChannelInput */ public static NetAltingChannelInput createNet2One() { return factory.net2one(); } /** * Creates a new NetSharedChannelInput * * @deprecated Use net2any instead * @return A new NetSharedChannelInput */ public static NetSharedChannelInput createNet2Any() { return factory.net2any(); } /** * Creates a new NetChannelOutput connected to the input channel end with the given location * * @deprecated Use one2net instead * @param loc * The location to connect the output end to * @return A new NetChannelOutput connected to the input end at the given location * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput createOne2Net(NetChannelLocation loc) throws JCSPNetworkException { return factory.one2net(loc); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location * * @deprecated Use any2net instead * @param loc * The location to connect the output end to * @return A new NetSharedChannelOutput connected to the input end at the given location * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput createAny2Net(NetChannelLocation loc) throws JCSPNetworkException { return factory.any2net(loc); } /** * Creates a new NetAltingChannelInput * * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one() { return factory.net2one(); } /** * Creates a new NetAltingChannelInput with the given immunity level for poison * * @param immunityLevel * The immunity level for poison * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one(int immunityLevel) { return factory.net2one(immunityLevel); } /** * Creates a new NetAltingChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one(NetworkMessageFilter.FilterRx filter) { return factory.net2one(filter); } /** * Creates a new NetAltingChannelInput with the given poison immunity level which uses the given filter to decode * incoming messages * * @param immunityLevel * The immunity level to poison for the created channel * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return factory.net2one(immunityLevel, filter); } /** * Creates a new NetSharedChannelInput * * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any() { return factory.net2any(); } /** * Creates a new NetSharedChannelInput with the given poison immunity level * * @param immunityLevel * The immunity level to poison for this channel * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any(int immunityLevel) { return factory.net2any(immunityLevel); } /** * Creates a new NetSharedChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any(NetworkMessageFilter.FilterRx filter) { return factory.net2any(filter); } /** * Creates a new NetSharedChannelInput with the given poison immunity level, which uses the given filter to decode * messages * * @param immunityLevel * The immunity level to poison for this channel * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return factory.net2any(immunityLevel, filter); } /** * Creates a new NetAltingChannelInput with the given index * * @param index * The index to create the channel with * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index) throws IllegalArgumentException { return factory.numberedNet2One(index); } /** * Creates a new NetAltingChannelInput with the given index and the given poison immunity level * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index, int immunityLevel) throws IllegalArgumentException { return factory.numberedNet2One(index, immunityLevel); } /** * Creates a new NetAltingChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return factory.numberedNet2One(index, filter); } /** * Creates a new NetAltingChannelInput with the given index and given poison immunity, which uses the given filter * to decode incoming messages * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return factory.numberedNet2One(index, immunityLevel, filter); } /** * Creates a new NetSharedChannelInput with the given index * * @param index * The index to create the channel with * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetSharedChannelInput numberedNet2Any(int index) throws IllegalArgumentException { return factory.numberedNet2Any(index); } /** * Creates a new NetSharedChannelInput with the given index and poison immunity level * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison the channel has * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetSharedChannelInput numberedNet2Any(int index, int immunityLevel) throws IllegalArgumentException { return factory.numberedNet2Any(index, immunityLevel); } /** * Creates a new NetSharedChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetSharedChannelInput numberedNet2Any(int index, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return factory.numberedNet2Any(index, filter); } /** * Creates a new NetSharedChannelInput with the given index and poison immunity level, which uses the given filter * to decode incoming messages. * * @param index * The index to create the channel with * @param immunityLevel * The immunity level to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists. */ public static NetSharedChannelInput numberedNet2Any(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return factory.numberedNet2Any(index, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation * * @param loc * The location of the input end of the channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NetChannelLocation loc) throws JCSPNetworkException { return factory.one2net(loc); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and having the given * poison immunity level * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel) throws JCSPNetworkException { return factory.one2net(loc, immunityLevel); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and uses the given * filter to encode outgoing messages * * @param loc * The location of the input end of the channel * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(loc, filter); } /** * Creates a new NetChannelOutput connected to the given location with the given poison immunity level, and uses the * given filter to encode outgoing messages. * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(loc, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location * * @param loc * The location of the input end of the channel * @return A new NetSharedChannelInput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NetChannelLocation loc) throws JCSPNetworkException { return factory.any2net(loc); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location and with the given poison * immunity level * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelInput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel) throws JCSPNetworkException { return factory.any2net(loc, immunityLevel); } /** * Creates a new NetSharedChannelOutput connected to the input end with the given location, and uses the given * filter to encode outgoing messages * * @param loc * The location of the input end of the channel * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(loc, filter); } /** * Creates a new NetSharedChannelOutput connected to the input end with the given location and with the given * immunity level, which uses the given filter to encode outgoing messages. * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(loc, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeID * The NodeID of the node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeID nodeID, int vcn) throws JCSPNetworkException { return factory.one2net(nodeID, vcn); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, and with the given * poison immunity level * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison of the channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel) throws JCSPNetworkException { return factory.one2net(nodeID, vcn, immunityLevel); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, which uses the * given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong with the underlying architecture */ public static NetChannelOutput one2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(nodeID, vcn, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, with the given * poison immunity level and uses the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter that encodes the outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong with the underlying architecture */ public static NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(nodeID, vcn, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn) throws JCSPNetworkException { return factory.any2net(nodeID, vcn); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node and the given * poison immunity * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn, int immunityLevel) throws JCSPNetworkException { return factory.any2net(nodeID, vcn, immunityLevel); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, which uses * the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter used to encode the outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(nodeID, vcn, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, with the * given poison immunity level, which uses the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(nodeID, vcn, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn) throws JCSPNetworkException { return factory.one2net(nodeAddr, vcn); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node with the given * poison immunity * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison the channel has * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel) throws JCSPNetworkException { return factory.one2net(nodeAddr, vcn, immunityLevel); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which uses the given * filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(nodeAddr, vcn, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which has the given * poison immunity and uses the given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(nodeAddr, vcn, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn) throws JCSPNetworkException { return factory.any2net(nodeAddr, vcn); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which has the * given poison immunity * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel) throws JCSPNetworkException { return factory.any2net(nodeAddr, vcn, immunityLevel); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which uses the * given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(nodeAddr, vcn, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node that has the * given poison immunity level and uses the given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(nodeAddr, vcn, immunityLevel, filter); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetChannelEnd.java0000644000000000000000000007245611072626250017342 0ustar package org.jcsp.net2; /** * A static factory object used to create networked channels. This class basically wraps around a * StandardNetChannelEndFactory and allows static access to its channel creation methods. * * @see NetChannelEndFactory * @see StandardNetChannelEndFactory * @deprecated To conform with the core package naming scheme, the class NetChannel has also been provided * @author Kevin Chalmers */ public final class NetChannelEnd { /** * The factory used to create the networked channels */ private static StandardNetChannelEndFactory factory = new StandardNetChannelEndFactory(); /** * Empty, private default constructor. This is a static access class. */ private NetChannelEnd() { // Empty constructor } /** * Creates a new NetAltingChannelInput * * @deprecated Use net2one instead * @return A new NetAltingChannelInput */ public static NetAltingChannelInput createNet2One() { return factory.net2one(); } /** * Creates a new NetSharedChannelInput * * @deprecated Use net2any instead * @return A new NetSharedChannelInput */ public static NetSharedChannelInput createNet2Any() { return factory.net2any(); } /** * Creates a new NetChannelOutput connected to the input channel end with the given location * * @deprecated Use one2net instead * @param loc * The location to connect the output end to * @return A new NetChannelOutput connected to the input end at the given location * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput createOne2Net(NetChannelLocation loc) throws JCSPNetworkException { return factory.one2net(loc); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location * * @deprecated Use any2net instead * @param loc * The location to connect the output end to * @return A new NetSharedChannelOutput connected to the input end at the given location * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput createAny2Net(NetChannelLocation loc) throws JCSPNetworkException { return factory.any2net(loc); } /** * Creates a new NetAltingChannelInput * * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one() { return factory.net2one(); } /** * Creates a new NetAltingChannelInput with the given immunity level for poison * * @param immunityLevel * The immunity level for poison * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one(int immunityLevel) { return factory.net2one(immunityLevel); } /** * Creates a new NetAltingChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one(NetworkMessageFilter.FilterRx filter) { return factory.net2one(filter); } /** * Creates a new NetAltingChannelInput with the given poison immunity level which uses the given filter to decode * incoming messages * * @param immunityLevel * The immunity level to poison for the created channel * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return factory.net2one(immunityLevel, filter); } /** * Creates a new NetSharedChannelInput * * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any() { return factory.net2any(); } /** * Creates a new NetSharedChannelInput with the given poison immunity level * * @param immunityLevel * The immunity level to poison for this channel * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any(int immunityLevel) { return factory.net2any(immunityLevel); } /** * Creates a new NetSharedChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any(NetworkMessageFilter.FilterRx filter) { return factory.net2any(filter); } /** * Creates a new NetSharedChannelInput with the given poison immunity level, which uses the given filter to decode * messages * * @param immunityLevel * The immunity level to poison for this channel * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return factory.net2any(immunityLevel, filter); } /** * Creates a new NetAltingChannelInput with the given index * * @param index * The index to create the channel with * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index) throws IllegalArgumentException { return factory.numberedNet2One(index); } /** * Creates a new NetAltingChannelInput with the given index and the given poison immunity level * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index, int immunityLevel) throws IllegalArgumentException { return factory.numberedNet2One(index, immunityLevel); } /** * Creates a new NetAltingChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return factory.numberedNet2One(index, filter); } /** * Creates a new NetAltingChannelInput with the given index and given poison immunity, which uses the given filter * to decode incoming messages * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return factory.numberedNet2One(index, immunityLevel, filter); } /** * Creates a new NetSharedChannelInput with the given index * * @param index * The index to create the channel with * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetSharedChannelInput numberedNet2Any(int index) throws IllegalArgumentException { return factory.numberedNet2Any(index); } /** * Creates a new NetSharedChannelInput with the given index and poison immunity level * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison the channel has * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetSharedChannelInput numberedNet2Any(int index, int immunityLevel) throws IllegalArgumentException { return factory.numberedNet2Any(index, immunityLevel); } /** * Creates a new NetSharedChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists */ public static NetSharedChannelInput numberedNet2Any(int index, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return factory.numberedNet2Any(index, filter); } /** * Creates a new NetSharedChannelInput with the given index and poison immunity level, which uses the given filter * to decode incoming messages. * * @param index * The index to create the channel with * @param immunityLevel * The immunity level to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @throws IllegalArgumentException * Thrown if a channel with the given index already exists. */ public static NetSharedChannelInput numberedNet2Any(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException { return factory.numberedNet2Any(index, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation * * @param loc * The location of the input end of the channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NetChannelLocation loc) throws JCSPNetworkException { return factory.one2net(loc); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and having the given * poison immunity level * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel) throws JCSPNetworkException { return factory.one2net(loc, immunityLevel); } /** * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and uses the given * filter to encode outgoing messages * * @param loc * The location of the input end of the channel * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(loc, filter); } /** * Creates a new NetChannelOutput connected to the given location with the given poison immunity level, and uses the * given filter to encode outgoing messages. * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(loc, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location * * @param loc * The location of the input end of the channel * @return A new NetSharedChannelInput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NetChannelLocation loc) throws JCSPNetworkException { return factory.any2net(loc); } /** * Creates a new NetSharedChannelOutput connected to the input end at the given location and with the given poison * immunity level * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelInput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel) throws JCSPNetworkException { return factory.any2net(loc, immunityLevel); } /** * Creates a new NetSharedChannelOutput connected to the input end with the given location, and uses the given * filter to encode outgoing messages * * @param loc * The location of the input end of the channel * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(loc, filter); } /** * Creates a new NetSharedChannelOutput connected to the input end with the given location and with the given * immunity level, which uses the given filter to encode outgoing messages. * * @param loc * The location of the input end of the channel * @param immunityLevel * The immunity to poison that this channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(loc, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeID * The NodeID of the node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeID nodeID, int vcn) throws JCSPNetworkException { return factory.one2net(nodeID, vcn); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, and with the given * poison immunity level * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison of the channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel) throws JCSPNetworkException { return factory.one2net(nodeID, vcn, immunityLevel); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, which uses the * given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong with the underlying architecture */ public static NetChannelOutput one2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(nodeID, vcn, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, with the given * poison immunity level and uses the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node that the input channel resides on * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter that encodes the outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong with the underlying architecture */ public static NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(nodeID, vcn, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn) throws JCSPNetworkException { return factory.any2net(nodeID, vcn); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node and the given * poison immunity * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn, int immunityLevel) throws JCSPNetworkException { return factory.any2net(nodeID, vcn, immunityLevel); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, which uses * the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter used to encode the outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(nodeID, vcn, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, with the * given poison immunity level, which uses the given filter to encode outgoing messages * * @param nodeID * The NodeID of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(nodeID, vcn, immunityLevel, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn) throws JCSPNetworkException { return factory.one2net(nodeAddr, vcn); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node with the given * poison immunity * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison the channel has * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel) throws JCSPNetworkException { return factory.one2net(nodeAddr, vcn, immunityLevel); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which uses the given * filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(nodeAddr, vcn, filter); } /** * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which has the given * poison immunity and uses the given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.one2net(nodeAddr, vcn, immunityLevel, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn) throws JCSPNetworkException { return factory.any2net(nodeAddr, vcn); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which has the * given poison immunity * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel) throws JCSPNetworkException { return factory.any2net(nodeAddr, vcn, immunityLevel); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which uses the * given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param filter * The immunity to poison that the channel has * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(nodeAddr, vcn, filter); } /** * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node that has the * given poison immunity level and uses the given filter to encode outgoing messages * * @param nodeAddr * The NodeAddress of the Node to connect to * @param vcn * The Virtual Channel Number of the input channel * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to encode outgoing messages * @return A new NetSharedChannelOutput * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException { return factory.any2net(nodeAddr, vcn, immunityLevel, filter); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/JCSPNetworkException.java0000644000000000000000000000151111072626250020644 0ustar package org.jcsp.net2; /** * This is the general exception thrown when something bad happens in the underlying architecture. Currently this is * generalised for the sake of simplicity. However, a number of different errors may occur internally, and therefore * this exception may be specialised into particular exception types in the future. * * @author Kevin Chalmers */ public final class JCSPNetworkException extends RuntimeException { /** * Default serial ID. Given for the sake of completeness. */ private static final long serialVersionUID = 1L; /** * Constructor for a new JCSPNetworkException * * @param message * The message for the exception */ public JCSPNetworkException(String message) { super(message); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NodeKey.java0000644000000000000000000000050011072626250016207 0ustar package org.jcsp.net2; /** * A unique object for allowing access to privileged operations on the Node. Returned when a Node is initialised. * * @author Kevin Chalmers */ public final class NodeKey { /** * Creates a NodeKey */ NodeKey() { // Empty constructor } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetChannelInput.java0000644000000000000000000000130111072626250017710 0ustar package org.jcsp.net2; import org.jcsp.lang.ChannelInput; /** * This interface defines a ChannelInput that is also networked. For information on ChannelInput see the relevant class. * For information on how to create a NetChannelInput, see the relevant factory class * * @see ChannelInput * @see Networked * @see NetChannel * @author Kevin Chalmers (updated from Quickstone Technologies) */ public interface NetChannelInput extends ChannelInput, Networked { /** * Sets the underlying decoder for the channel * * @param decoder * The new decoder to use. */ public void setDecoder(NetworkMessageFilter.FilterRx decoder); } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetBarrier.java0000644000000000000000000011557211072626250016726 0ustar package org.jcsp.net2; import java.util.LinkedList; import org.jcsp.lang.AltingChannelInput; import org.jcsp.lang.Any2OneChannel; import org.jcsp.lang.Barrier; import org.jcsp.lang.Channel; import org.jcsp.lang.ChannelOutput; import org.jcsp.lang.ProcessInterruptedException; import org.jcsp.util.InfiniteBuffer; /** * This class is a networked implementation of the standard JCSP Barrier. *

* The NetBarrier is a networked version of the JCSP Barrier, a synchronization primitive similar to the standard event * in CSP. The networked implementation follows the standard interface for a local Barrier, with the addition of the * interface defining a networked construct. Internally, the two constructs behave differently due to the distributed * nature of the NetBarrier. *

*

Client and Server Ends

*

* Unlike a normal Barrier, a NetBarrier has two types, based on whether the Barrier is the hosting end or an attached, * synchronizing end. These are differentiated between as server and client ends. The server end, like the input end of * a networked channel, will be declared first. The location of this server end can then be used to connect a number of * client ends to. The server end can declare an initial number of expected client ends, which it waits for enrolls from * before beginning any sync operations. This value can be set to 0 if need be. Each end of a barrier must also declare * the number of local syncing processes, creating a two tier construct: *

*

* Process ---> NetBarrier (client) ---> NetBarrier (server) *

*

Creating NetBarriers

*

* To create a NetBarrier, a similar method is used as a networked channel. A Barrier Name Server is provided for * declaring named barriers, or the NetBarrierEnd factory can be used. First, creation of a sever end: *

*

* * int locallyEnrolled = 5;
* int remoteEnrolled = 1;
* NetBarrier bar = NetBarrierEnd.netBarrier(locallyEnrolled, remoteEnrolled);
*
*

*

* A client end requires the location of this barrier to allow creation: *

*

* * NetBarrierLocation loc;
* int locallyEnrolled = 5;
* NetBarrier bar = NetBarrierEnd.netBarrier(loc, locallyEnrolled);
*
*

*

* These barriers can then be used as normal. *

*

IMPLMENTATION NOTE

*

* To save on resources, a NetBarrier does not have an internal process controlling it (although other implementations * may decide to do this). Because of this, the declaring (server) end of the barrier must always have at least one * process enrolled with it to ensure that the SYNC operation occurs. If there is a danger that the enrolled processes * on the server node will become 0, it is safer to define a process that is only responsible for SYNCing with the * barrier. This minor overhead in certain circumstances is seen as a better approach than all NetBarriers being a * process within JCSP, where processes are expensive in resources. *

*

* * public void run() {
* while (true) {
* bar.sync(); }}
*
*

* * @see Barrier * @author Kevin Chalmers (networked part) * @author P.H. Welch (Barrier) */ public final class NetBarrier extends Barrier implements Networked { /** * The SUID for this object. Shouldn't really need it. Barrier should not be serializable. */ private static final long serialVersionUID = 1L; /** * The data structure representing this NetBarrier object */ private final BarrierData data; /** * The location that this NetBarrier is connected to */ private final NetBarrierLocation remoteLocation; /** * The local location of this NetBarrier */ private final NetBarrierLocation localLocation; /** * The number of locally connected processes */ private int localEnrolled; /** * The number of local processes still to SYNC */ private int localCountDown; /** * The number of remote connected processes */ private int netEnrolled; /** * The number of networked processes still to SYNC */ private int netCountDown; /** * Flag used to determine if the NetBarrier is connected to a server end on the same Node */ private boolean locallyConnected = false; /** * A queue of waiting network ends waiting for a SYNC message */ private final LinkedList waitingEnds = new LinkedList(); /** * The number of initial network enrolls that this barrier must wait for. */ private int initialNetEnrollCountdown; /** * The connection to the Link that the client end communicates with */ private ChannelOutput toLinkTX; /** * Used by a locally connected barrier to allow it to check the state prior to sending the SYNC. */ private BarrierData localBar = null; /** * The input channel into this NetBarrier from the Links */ private final AltingChannelInput in; /** * The exclusive access lock for syncing, etc. */ private final Object lock = new Object(); /** * A flag used to signify that a waking process should perform a network sync when released */ private boolean performNetSync = false; /** * The constructor for a NetBarrier * * @param barData * The data structure defining the Barrier * @param numToEnroll * The number of local processes to enroll * @param netNumToEnroll * The number of network processes that will enroll * @param serverLocation * The location of the server end of the NetBarrier * @param inToBar * The channel into the NetBarrier from the Link * @param toLink * The channel connecting the client end of a NetBarrierer to its Link * @throws IllegalArgumentException * Thrown if the number of local enrolled processes is less than 1, or remote enrolled is less than 0 */ private NetBarrier(BarrierData barData, int numToEnroll, int netNumToEnroll, NetBarrierLocation serverLocation, AltingChannelInput inToBar, ChannelOutput toLink) throws IllegalArgumentException { // First do some sanity checks if (numToEnroll < 1) throw new IllegalArgumentException("*** Attempt to set an enrollment of less than 1 on a NetBarrier *** \n"); if (netNumToEnroll < 0) throw new IllegalArgumentException("*** Attempt to create a NetBarrier with negative remote enrolls *** \n"); // Now set the standard parameters this.localEnrolled = numToEnroll; this.localCountDown = numToEnroll; this.data = barData; this.localLocation = new NetBarrierLocation(Node.getInstance().getNodeID(), this.data.vbn); this.in = inToBar; // Now check if we are a server or client end. if (this.data.state == BarrierDataState.OK_SERVER) { // We are a server end. There is no remote location, and we must set the networked enrolls this.remoteLocation = null; this.initialNetEnrollCountdown = netNumToEnroll; this.netEnrolled = netNumToEnroll; this.netCountDown = netNumToEnroll; } else { // We are a client end. Set the remote location this.remoteLocation = serverLocation; // Now, are we a locally connected barrier, or remote connected barrier if (serverLocation.getNodeID().equals(Node.getInstance().getNodeID())) { this.localBar = BarrierManager.getInstance().getBarrier(serverLocation.getVBN()); // We are remotely connected. Get the channel connected to the server end this.toLinkTX = this.localBar.toBarrier; // Now we need to check if we can still enroll with it synchronized (this.localBar) { if (this.localBar.state != BarrierDataState.OK_SERVER) throw new JCSPNetworkException( "Attempted to enroll with a NetBarrier that is not a server end."); // Set the locally connected flag to true. this.locallyConnected = true; // Send an enroll message NetworkMessage msg = new NetworkMessage(); msg.type = NetworkProtocol.ENROLL; // Destination is the VBN of the location, although this isn't used as we are locally connected msg.attr1 = serverLocation.getVBN(); // Attrubute 2 is not used msg.attr2 = -1; // Write the enroll to the server end this.toLinkTX.write(msg); // We do not need to register with a Link, as we do not go down to that layer. } } else { // Otherwise we are remotely connected. Set the link connection channel to the given one. this.toLinkTX = toLink; } } } /** * Static factory method used to create a server end of a NetBarrier * * @param localEnroll * The number of locally enrolled processes * @param remoteEnroll * The number of remote processes to wait for enrolls from * @return A new NetBarrier * @throws IllegalArgumentException * Thrown if the number of enrolled processes is outside the defined ranges */ static NetBarrier create(int localEnroll, int remoteEnroll) throws IllegalArgumentException { // First, the sanity checks if (localEnroll < 1) throw new IllegalArgumentException( "Tried to create a NetBarrier with fewer than one locally enrolled process"); if (remoteEnroll < 0) throw new IllegalArgumentException("Tried to create a NetBarrier with negative remote enrollments"); // Now create the BarrierData structure BarrierData data = new BarrierData(); // Set state to OK_SERVER data.state = BarrierDataState.OK_SERVER; // Create the connecting channel Any2OneChannel chan = Channel.any2one(new InfiniteBuffer()); // Add the output end to the structure data.toBarrier = chan.out(); // Initialise the structure with the BarrierManager BarrierManager.getInstance().create(data); // Return a new NetBarrier return new NetBarrier(data, localEnroll, remoteEnroll, null, chan.in(), null); } /** * Static factory method for creating a new NetBarrier with a given index * * @param localEnroll * The number of locally enrolled processes * @param remoteEnroll * The number of remote processes to wait for enrolls from * @param barrierIndex * The index to create the barrier with * @return A new NetBarrier * @throws IllegalArgumentException * Thrown if the any of the arguments are outside the desired ranges. */ static NetBarrier create(int localEnroll, int remoteEnroll, int barrierIndex) throws IllegalArgumentException { // First, the sanity checks. if (localEnroll < 1) throw new IllegalArgumentException( "Tried to create a NetBarrier with fewer than one locally enrolled process"); if (remoteEnroll < 0) throw new IllegalArgumentException("Tried to create a NetBarrier with negative remote enrollments"); // Now create the BarrierData structure BarrierData data = new BarrierData(); // Set state to OK_SERVER data.state = BarrierDataState.OK_SERVER; // Create the connecting channel Any2OneChannel chan = Channel.any2one(new InfiniteBuffer()); // Add the output end to the structure data.toBarrier = chan.out(); // Initialise the structure with the BarrierManager, using the given index BarrierManager.getInstance().create(barrierIndex, data); // Return a new NetBarrier return new NetBarrier(data, localEnroll, remoteEnroll, null, chan.in(), null); } /** * Static factory method for creating a client end of a NetBarrier * * @param loc * The location of the server end of the connection * @param localEnroll * The number of locally enrolled processes * @return A new NetBarrier client end * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws IllegalArgumentException * Thrown if local enrolled is less than 1 */ static NetBarrier create(NetBarrierLocation loc, int localEnroll) throws JCSPNetworkException, IllegalArgumentException { // First, the sanity check. if (localEnroll < 1) throw new IllegalArgumentException( "Tried to create a NetBarrier with fewer than one locally enrolled process"); // Next, create the BarrierData structure BarrierData data = new BarrierData(); // Set the state to OK_CLIENT data.state = BarrierDataState.OK_CLIENT; // Create the connecting channel between this object and the Links Any2OneChannel chan = Channel.any2one(new InfiniteBuffer()); // Attach the output end to the structure data.toBarrier = chan.out(); // Initialise the barrier with the BarrierManager BarrierManager.getInstance().create(data); // Now check if this is a locally connected barrier if (loc.getNodeID().equals(Node.getInstance().getNodeID())) { // We are locally connected, so create a new NetBarrier. The constructor will connect to the Barrier server // end for us. return new NetBarrier(data, localEnroll, 0, loc, chan.in(), null); } // We are not locally connected. Continue. // This is the channel we will pass to the NetBarrier ChannelOutput toLink; // First, check if the LinkManager has a connection for us. Link link = LinkManager.getInstance().requestLink(loc.getNodeID()); // The previous operation returns null if no connection exists. if (link == null) { // No connection to the Link exists. Use the factory to get one. link = LinkFactory.getLink(loc.getNodeID()); // The LinkFactory will have created and started the Link for us, if it could connect. We can continue } // Retrieve the channel connecting to the TX process toLink = link.getTxChannel(); // We now need to enroll with the server end. Send the enroll message NetworkMessage msg = new NetworkMessage(); msg.type = NetworkProtocol.ENROLL; // Destination is the VBN of the location msg.attr1 = loc.getVBN(); // Attribute 2 is not used msg.attr2 = -1; // Write the message to the Link toLink.write(msg); // Register with the Link link.registerBarrier(data); // Return a new NetBarrier return new NetBarrier(data, localEnroll, 0, loc, chan.in(), toLink); } /** * Resets the number of locally enrolled processes. A dangerous operation. * * @param numToEnroll * The number of processes to reset the enrolled to. */ public void reset(int numToEnroll) { if (numToEnroll < 1) { throw new IllegalArgumentException("*** Attempt to set an enrollment of less than 1 on a NetBarrier ***\n"); } synchronized (this.lock) { this.localEnrolled = numToEnroll; this.localCountDown = numToEnroll; } } /** * Performs a SYNC operation with the Barrier throws JCSPNetworkException Thrown if something goes wrong in the * underlying architecture * * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public void sync() throws JCSPNetworkException { // First check our state if (this.data.state == BarrierDataState.BROKEN) throw new JCSPNetworkException("The Barrier has broken"); if (this.data.state == BarrierDataState.DESTROYED) throw new JCSPNetworkException("The Barrier has been destroyed"); if (this.data.state == BarrierDataState.RESIGNED) throw new JCSPNetworkException("The Barrier has been completely resigned from"); // Now we must ensure we are the only process interacting with the Barrier synchronized (this.lock) { // First we check for any incoming messages while (this.in.pending()) { // We have a waiting message. Read it in. NetworkMessage msg = (NetworkMessage)this.in.read(); // Now behave based on the type of message switch (msg.type) { // Client end enrollment case NetworkProtocol.ENROLL: // We should be a server (the Link checked) // Check the number of waiting enrolls, and decrement if required if (this.initialNetEnrollCountdown > 0) this.initialNetEnrollCountdown--; else { // Otherwise we increment the netCountdown and netEnrolled this.netCountDown++; this.netEnrolled++; } break; // We have lost connection, either to a client end or to the server end case NetworkProtocol.LINK_LOST: // Now we must determine how to behave based on whether we are a server or a client end. if (this.data.state == BarrierDataState.OK_CLIENT) { // Link to server end has gone down. Break Barrier as we are no longer doing a network SYNC. // Set state to broken synchronized (this.data) { this.data.state = BarrierDataState.BROKEN; } // Release any waiting processes this.lock.notifyAll(); // Throw exception throw new JCSPNetworkException("Link to server end lost"); } // We are a server end. Resign one front end, and then throw exception. The Barrier could still // be used. this.netCountDown--; this.netEnrolled--; throw new JCSPNetworkException("A connection to a Client end was lost"); // A client end is resigning case NetworkProtocol.RESIGN: // Resign an end from the server this.netCountDown--; this.netEnrolled--; // We may have a problem with too many resigners. Check and throw exception if necessary if (this.netEnrolled < 0) { // Set enrolled and countdown to 0 this.netEnrolled = 0; this.netCountDown = 0; // Throw exception. The syncing process can deal with if needed. throw new JCSPNetworkException("Too many net resigns have occurred"); } break; case NetworkProtocol.SYNC: // Decrement countdown this.netCountDown--; // Check we haven't received too many SYNC messages if (this.netCountDown < 0) { // Set countdown to 0 and throw an exception this.netCountDown = 0; throw new JCSPNetworkException("Too many net syncs have occurred"); } // Otherwise we can add the message to the waiting ends. this.waitingEnds.add(msg); break; } } // We have dealt with all incoming messages. Now deal with our own SYNC // First, are we the the final process to SYNC locally? if (this.localCountDown > 1) { // We are not the final process to SYNC locally. Decrement countdown. this.localCountDown--; // Wait on the lock try { this.lock.wait(); // Now we check if we have had a problem if (this.data.state != BarrierDataState.OK_CLIENT && this.data.state != BarrierDataState.OK_SERVER) { throw new JCSPNetworkException("The NetBarrier failed"); } // Now check if we should be performing a netSYNC or not. If not we return. This occurs if a // local process resigned from us, making the net sync occur. if (!this.performNetSync) // We are not performing the net sync. Continue return; } catch (InterruptedException ie) { // Should never happen, however throw new ProcessInterruptedException("*** Thrown from NetBarrier.sync() ***\n" + ie.toString()); } } // We are the final local process to sync, or we have been woken up. Now we perform the network SYNC // Are we a client? if (this.data.state == BarrierDataState.OK_CLIENT) { // We are a client end. We need to SYNC with the server end. // Send SYNC message to the server end NetworkMessage msg = new NetworkMessage(); msg.type = NetworkProtocol.SYNC; // Destination taken from the remote location msg.attr1 = this.remoteLocation.getVBN(); // Source is our own VBN msg.attr2 = this.data.vbn; // Now are we locally connected or not? if (this.locallyConnected) { // We are locally connected. To ensure we get the SYNC back, attach our own input channel to the // message msg.toLink = this.data.toBarrier; // Now check the state of the local barrier. We need to lock onto it. synchronized (this.localBar) { if (this.localBar.state != BarrierDataState.OK_SERVER) throw new JCSPNetworkException("The server end of the NetBarrier is down."); this.toLinkTX.write(msg); } } else { // We are not locally connected. Send message to Link this.toLinkTX.write(msg); } // Wait for incoming message NetworkMessage message = (NetworkMessage)this.in.read(); // Now behave according to incoming message switch (message.type) { case NetworkProtocol.RELEASE: // Everything OK, release processes this.lock.notifyAll(); this.localCountDown = this.localEnrolled; break; case NetworkProtocol.REJECT_BARRIER: case NetworkProtocol.LINK_LOST: // Our sync was rejected, or the Link to the server is down. Set state to broken, and throw // exception synchronized (this.data) { this.data.state = BarrierDataState.BROKEN; } this.lock.notifyAll(); if (message.type == NetworkProtocol.REJECT_BARRIER) throw new JCSPNetworkException("SYNC to server end of NetBarrier was rejected"); throw new JCSPNetworkException("Link to server end of NetBarrier was lost"); } } else { // We are a server end. Wait until all all client ends are ready while (this.netCountDown > 0) { // Read in the next message NetworkMessage message = (NetworkMessage)this.in.read(); // Deal with message switch (message.type) { case NetworkProtocol.ENROLL: // We've had another network end enrolling // Check the number of waiting enrolls, and decrement if required if (this.initialNetEnrollCountdown > 0) this.initialNetEnrollCountdown--; else { this.netCountDown++; this.netEnrolled++; } break; case NetworkProtocol.RESIGN: // Resign a client end from the barrier this.netEnrolled--; this.netCountDown--; // We don't need to do a check here, the while loop covers this. netCountdown can never be // less than 0. break; case NetworkProtocol.LINK_LOST: // A connection to a client end has gone down. We decrement the enrolled and countdown and // throw an exception this.netCountDown--; this.netEnrolled--; throw new JCSPNetworkException("Link to a client end of a NetBarrier was lost"); case NetworkProtocol.SYNC: // A client end has synced with us. Decrement netCountdown and add the message to the queue this.netCountDown--; this.waitingEnds.add(message); break; } } // All local processes and client ends have synced. Release all. this.localCountDown = this.localEnrolled; this.netCountDown = this.netEnrolled; this.lock.notifyAll(); // Iterate through the list of waiting ends and send them all a RELEASE message for (; !this.waitingEnds.isEmpty();) { NetworkMessage waitingMessage = (NetworkMessage)this.waitingEnds.getFirst(); NetworkMessage reply = new NetworkMessage(); reply.type = NetworkProtocol.RELEASE; reply.attr1 = waitingMessage.attr2; waitingMessage.toLink.write(reply); } } // Set flag for performing net sync to false. All other released processes will now continue as normal. this.performNetSync = false; } } /** * Enrolls locally with the Barrier * * @throws JCSPNetworkException * Thrown if the barrier is not a state where it can be enrolled with */ public void enroll() throws JCSPNetworkException { // First check our state if (this.data.state == BarrierDataState.BROKEN) throw new JCSPNetworkException("The Barrier has broken"); if (this.data.state == BarrierDataState.DESTROYED) throw new JCSPNetworkException("The Barrier has been destroyed"); // Get exclusive access to the Barrier synchronized (this.lock) { // Do we need to reenroll on the server? if (this.data.state == BarrierDataState.RESIGNED) { // We were previously resigned from the server end. First we need to change our state. Acquire // a lock on our state. synchronized (this.data) { this.data.state = BarrierDataState.OK_CLIENT; } // Now re-enroll on the server NetworkMessage enroll = new NetworkMessage(); enroll.type = NetworkProtocol.ENROLL; enroll.attr1 = this.remoteLocation.getVBN(); this.toLinkTX.write(enroll); } // Increment countdown and enrolled this.localCountDown++; this.localEnrolled++; } } /** * Resigns an local process from the barrier * * @throws JCSPNetworkException * Thrown if something bad happens within the underlying architecture */ public void resign() throws JCSPNetworkException { // First check our state if (this.data.state == BarrierDataState.BROKEN) throw new JCSPNetworkException("The Barrier has broken"); if (this.data.state == BarrierDataState.DESTROYED) throw new JCSPNetworkException("The Barrier has been destroyed"); if (this.data.state == BarrierDataState.RESIGNED) return; // Now acquire a lock on the barrier to assure exclusive access synchronized (this.lock) { // Now we must check if enrolled will become 0 or not if (this.localEnrolled == 1) { // Are we a server or client end? if (this.data.state == BarrierDataState.OK_CLIENT) { // We are a server end, and we are the last enrolled one. We need to change our state. // Lock our state object synchronized (this.data) { // Change state to resigned this.data.state = BarrierDataState.RESIGNED; } // We need to resign from the server end. Send resignment message NetworkMessage resign = new NetworkMessage(); resign.type = NetworkProtocol.RESIGN; resign.attr1 = this.remoteLocation.getVBN(); this.toLinkTX.write(resign); // Now decrement the enrolled and countdown this.localEnrolled--; this.localCountDown--; } else { // We must be a server end. We can't really have a server end with no local enrollments, as this // would break the Barrier. Release all the waiting client ends with a REJECT and throw an exception // Set state to broken synchronized (this.data) { this.data.state = BarrierDataState.BROKEN; } // We now have to check for pending messages while (this.in.pending()) { // There is an incoming message. Handle it NetworkMessage message = (NetworkMessage)this.in.read(); // The only message type we are interested in is SYNC calls. Enrollments and resignments will // not effect the barrier going down. if (message.type == NetworkProtocol.SYNC) { // Add the message to the queue of SYNCers this.waitingEnds.add(message); } } // Now we must inform all SYNCing ends that we are broken. Iterate through list of waiting ends // and send the REJECT_BARRIER message for (; !this.waitingEnds.isEmpty();) { NetworkMessage waitingMessage = (NetworkMessage)this.waitingEnds.getFirst(); NetworkMessage reply = new NetworkMessage(); reply.type = NetworkProtocol.REJECT_BARRIER; reply.attr1 = waitingMessage.attr2; waitingMessage.toLink.write(reply); } // Decrement local enrolled and countdown this.localEnrolled--; this.localCountDown--; // Throw exception throw new JCSPNetworkException( "A server end of a NetBarrier has been completely resigned from locally. No management of the NetBarrier can now occur"); } } else { // We are not the final enrolled process. // First decrement enrolled this.localEnrolled--; // Next we check if countdown will become 0. If it does, the other processes need to be SYNCed if (this.localCountDown == 1) { // The networked SYNC needs to occur. Set the flag accordingly and wake a waiting process to perform // it. this.performNetSync = true; // *** IMPLEMENTATION NOTE: we are now going to wake one of the waiting processes to perform the // networked part of the SYNC. We do this to avoid the resigning process from doing it, possibly // leading to deadlock. Unfortunately this does mean we may have a problem when another process is // attempting to enroll as we wake up a process. If synchronized is a fair queue in Java, then we // will not have a problem. // Wake a process this.lock.notify(); } else { // We are not ready to SYNC, decrement the countdown this.localCountDown--; } } } } /** * Destroys the Barrier * * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture */ public void destroy() throws JCSPNetworkException { // First check our state and change it accordingly if (this.data.state == BarrierDataState.BROKEN) return; if (this.data.state == BarrierDataState.DESTROYED) return; if (this.data.state == BarrierDataState.RESIGNED) this.data.state = BarrierDataState.DESTROYED; // Now acquire lock on the barrier synchronized (this.lock) { // Are we a client or server end? if (this.data.state == BarrierDataState.OK_CLIENT) { // Change our state to destroyed // We now lock on the barrier state to update it synchronized (this.data) { this.data.state = BarrierDataState.DESTROYED; } // There isn't anything left to do but release the locally waiting processes this.lock.notifyAll(); } else { // We are a server end. We need to reject the all waiting ends // Change our state to destroyed // We now lock on the barrier state to update it synchronized (this.data) { this.data.state = BarrierDataState.DESTROYED; } // We now have to check for pending messages while (this.in.pending()) { // There is an incoming message. Handle it NetworkMessage message = (NetworkMessage)this.in.read(); // The only message type we are interested in is SYNC calls. Enrollments and resignments will not // effect the barrier going down. Whenever the enrolling end SYNCs, it will be rejected here or by // the Link if (message.type == NetworkProtocol.SYNC) { // Add the message to the queue of SYNCers this.waitingEnds.add(message); } } // Now iterate through all the waiting SYNCs and send them a REJECT_BARRIER message for (; !this.waitingEnds.isEmpty();) { NetworkMessage waitingMessage = (NetworkMessage)this.waitingEnds.getFirst(); NetworkMessage reply = new NetworkMessage(); reply.type = NetworkProtocol.REJECT_BARRIER; reply.attr1 = waitingMessage.attr2; waitingMessage.toLink.write(reply); } } } } /** * Returns the location of this barrier * * @return The location of this channel */ public NetLocation getLocation() { if (this.data.state == BarrierDataState.OK_SERVER) return this.localLocation; return this.remoteLocation; } /** * Gets the local location of the barrier * * @return The local location of the barrier */ NetBarrierLocation getLocalLocation() { return this.localLocation; } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetBarrierEnd.java0000644000000000000000000001061011072626250017340 0ustar package org.jcsp.net2; /** * This class is the factory class for creating NetBarrier objects. For information, see NetBarrier. * * @see NetBarrier * @author Kevin Chalmers */ public final class NetBarrierEnd { /** * */ private NetBarrierEnd() { // Empty constructor } /** * Creates a new server end of a NetBarrier * * @param localEnrolled * The number of locally enrolled processes * @param netEnrolled * The number of net enrolled processes to expect * @return A new NetBarrier server end with the number of enrolled processes * @throws IllegalArgumentException * Thrown if the parameters are outside the defined ranges */ public static NetBarrier netBarrier(int localEnrolled, int netEnrolled) throws IllegalArgumentException { return NetBarrier.create(localEnrolled, netEnrolled); } /** * Creates a new server end of a NetBarrier with a given index * * @param index * The index to create the NetBarrier with * @param localEnrolled * The number of locally enrolled processes * @param netEnrolled * The number of remote enrollments to wait for * @return A new NetBarrier * @throws IllegalArgumentException * Thrown if the parameters are outside the defined ranges */ public static NetBarrier numberedNetBarrier(int index, int localEnrolled, int netEnrolled) throws IllegalArgumentException { return NetBarrier.create(localEnrolled, netEnrolled, index); } /** * Creates a new client end of a NetBarrier * * @param loc * The location of the server end of the NetBarrier * @param enrolled * The number of locally enrolled processes * @return A new NetBarrier client end with the number of enrolled processes * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws IllegalArgumentException * Thrown if the number of of local enrolled is outside the defined range */ public static NetBarrier netBarrier(NetBarrierLocation loc, int enrolled) throws JCSPNetworkException, IllegalArgumentException { return NetBarrier.create(loc, enrolled); } /** * Creates a new client end of a NetBarrier connected to the barrier with the given index on the given Node * * @param nodeID * The NodeID of the Node to connect to * @param vbn * The index of the barrier on the remote Node * @param enrolled * The number of locally enrolled processes * @return A new client end of a NetBarrier * @throws JCSPNetworkException * Thrown is something goes wrong in the underlying architecture * @throws IllegalArgumentException * Thrown if the number of enrolled is outside the defined range */ public static NetBarrier netBarrier(NodeID nodeID, int vbn, int enrolled) throws JCSPNetworkException, IllegalArgumentException { return NetBarrier.create(new NetBarrierLocation(nodeID, vbn), enrolled); } /** * Creates a new client end of a NetBarrier connected to the barrier with the given index on the given Node * * @param addr * NodeAddres of the Node that the barrier is located * @param vbn * Index of the barrier to connect to * @param enrolled * The number of locally enrolled processes * @return A new client end of a NetBarrier * @throws JCSPNetworkException * Thrown if something goes wrong in the underlying architecture * @throws IllegalArgumentException * Thrown if the number of enrolled processes is outside the defined range. */ public static NetBarrier netBarrier(NodeAddress addr, int vbn, int enrolled) throws JCSPNetworkException, IllegalArgumentException { // Get the Link with the given address Link link = LinkFactory.getLink(addr); // Create a new NetBarrier return NetBarrier.create(new NetBarrierLocation(link.remoteID, vbn), enrolled); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/ConnectionManager.java0000644000000000000000000000305211072626250020250 0ustar package org.jcsp.net2; import java.util.Hashtable; final class ConnectionManager { private static int index = 50; private final Hashtable connections = new Hashtable(); private static ConnectionManager instance = new ConnectionManager(); private ConnectionManager() { } static ConnectionManager getInstance() { return instance; } synchronized void create(ConnectionData data) { Integer objIndex = new Integer(index); while (this.connections.get(objIndex) != null) { objIndex = new Integer(++index); } data.vconnn = index; this.connections.put(objIndex, data); index++; } synchronized void create(int idx, ConnectionData data) throws IllegalArgumentException { Integer objIndex = new Integer(idx); if (this.connections.get(objIndex) != null) { throw new IllegalArgumentException("Connection of given number already exists"); } data.vconnn = idx; this.connections.put(objIndex, data); if (idx == ConnectionManager.index) { index++; } } ConnectionData getConnection(int idx) { Integer objIndex = new Integer(idx); return (ConnectionData)this.connections.get(objIndex); } void removeConnection(ConnectionData data) { Integer objIndex = new Integer(data.vconnn); this.connections.remove(objIndex); } } jcsp-1.1-rc4.orig/src/org/jcsp/net2/NetConnectionLocation.java0000644000000000000000000000525611072626250021125 0ustar /** * */ package org.jcsp.net2; import java.io.Serializable; /** * @author Kevin */ public final class NetConnectionLocation extends NetLocation implements Serializable { /** * The SUID representing this class */ private static final long serialVersionUID = 1L; /** * The NodeID portion of the location */ private final NodeID nodeID; /** * The vconnn portion of the location */ private final int vconnn; /** * Creates a new NetConnectionLocation * * @param aNodeID * The NodeID part of the location * @param aVConnN * The vconnn part of the location */ public NetConnectionLocation(NodeID aNodeID, int aVConnN) { this.nodeID = aNodeID; this.vconnn = aVConnN; } /** * Gets the NodeID part of the location * * @return The NodeID part of the NetConnectionLocation */ public NodeID getNodeID() { return this.nodeID; } /** * Gets the NodeAddress part of the location * * @return The NodeAddress part of the NetConnectionLocation */ public NodeAddress getNodeAddress() { return this.nodeID.getNodeAddress(); } /** * Gets the vconnn part of the location * * @return The VConnN part of the NetConnectionLocation */ public int getVConnN() { return this.vconnn; } /** * Converts the NetConnectionLocation object into a string representation of the form nconnl://[NodeID]/[VConnN] * * @return The String form of the NetConnectionLocation */ public String toString() { return "nconnl://" + this.nodeID.toString() + "/" + this.vconnn; } /** * Converts the string form of a NetConnectionLocation back into its object form * * @param str * The string representation of a NetConnectionLocation * @return A new NetConnectionLocation created from the String representation */ public static NetConnectionLocation parse(String str) { if (str.equalsIgnoreCase("null")) return null; if (str.startsWith("nconnl://")) { String toParse = str.substring(6); String[] addressBits = toParse.split("/"); NodeID nodeID = NodeID.parse(addressBits[0]); int vcn = Integer.parseInt(addressBits[1]); return new NetConnectionLocation(nodeID, vcn); } throw new IllegalArgumentException("String is not a string form of a NetConnectionLocation"); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/0000755000000000000000000000000011410045054015107 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Deparaplex.java0000644000000000000000000001407311105701167020051 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This demultiplexes data from its input channel to its output channel array. * *

Process Diagram

*

*

Description

* Deparaplex is a process to convert the single stream of * Object[] packets sent from a {@link Paraplex} process on the other * end of its in channel back to separate streams (its out * channels). It assumes that {@link Paraplex} operates on the same * size array of channels as its out array. It conforms to * contract required by {@link Paraplex} for a process receiving its packets. *

* In each cycle, it inputs one packet and outputs its contents in parallel * to each of its output channels. * The parallel output means that the process will wait until each item is accepted * by every channel -- in whatever order is demanded by its environment. * The ordering of the channels in the out array, therefore, makes * no difference to the functionality of this process. * *

Channel Protocols

* * * * * * * * * * * * * * * * *
Input Channels
inObject[] * A packet carrying the paraplexed data. *
Output Channels
out[]Object * Most channels in this package carry integers. *
* *

Example

*
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class DeparaplexExample {
 * 
 *   public static void main (String[] args) {
 * 
 *     final One2OneChannel[] a = Channel.one2oneArray (3);
 *     final One2OneChannel b = Channel.one2one ();
 *     final One2OneChannel[] c = Channel.one2oneArray (3);
 *     final One2OneChannel d = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a[0].out ()),
 *         new Squares (a[1].out ()),
 *         new Fibonacci (a[2].out ()),
 *         new Paraplex (Channel.getInputArray (a), b.out ()),
 *         new Deparaplex (b.in (), Channel.getOutputArray (c)),
 *         new Paraplex (Channel.getInputArray (c), d.out ()),
 *         new CSProcess () {
 *           public void run () {
 *             System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n");
 *             while (true) {
 *               Object[] data = (Object[]) d.in ().read ();
 *               for (int i = 0; i < data.length; i++) {
 *                 System.out.print ("\t\t" + data[i]);
 *               }
 *               System.out.println ();
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.Paraplex * @see org.jcsp.plugNplay.Multiplex * @see org.jcsp.plugNplay.Demultiplex * * @author P.H. Welch */ public final class Deparaplex implements CSProcess { /** The input Channel */ private final ChannelInput in; /** The output Channels */ private final ChannelOutput[] out; /** * Construct a new Deparaplex process with the input Channel in and the output * Channels out. The ordering of the Channels in the out array make * no difference to the functionality of this process. * * @param in the input channel * @param out the output Channels */ public Deparaplex(final ChannelInput in, final ChannelOutput[] out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessWrite[] outputProcess = new ProcessWrite[out.length]; for (int i = 0; i < out.length; i++) outputProcess[i] = new ProcessWrite(out[i]); Parallel parOutput = new Parallel(outputProcess); while (true) { Object[] data = (Object[]) in.read(); for (int i = 0; i < data.length; i++) outputProcess[i].value = data[i]; parOutput.run(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Plex.java0000644000000000000000000001243611105701167016675 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Fair multiplexes its input Object stream array into one output stream. *

Process Diagram

*

*

Description

* Plex is a process whose output stream is a fair multiplexing * of its input streams. It makes no assumptions about the traffic patterns occuring * on the input streams and ensures that no input stream will be starved by busy siblings. * It guarantees that if an input stream has data pending, no other stream will be * serviced twice before that data is serviced. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in[]java.lang.Object * The input streams. *
Output Channels
outjava.lang.Object * The multiplexed output stream. *
*

Example

* The following example shows how to use Plex in a small program. *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class PlexExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel[] a = Channel.one2oneArray (3);
 *     final One2OneChannel[] b = Channel.one2oneArray (3);
 *     final One2OneChannel c = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a[0].out ()),
 *         new Fibonacci (a[1].out ()),
 *         new Squares (a[2].out ()),
 *         new Sign ("Numbers ", a[0].in (), b[0].out ()),
 *         new Sign ("            Fibonacci ", a[1].in (), b[1].out ()),
 *         new Sign ("                          Squares ", a[2].in (), b[2].out ()),
 *         new Plex (Channel.getInputArray (b), c.out ()),
 *         new Printer (c.in (), "", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
*

*

Implemntation Note

* For information, here is the run method for this process: * *
 *   public void run () {
 *     Alternative alt = new Alternative (in);       // in is the input channel array
 *     while (true) {
 *       out.write (in[alt.fairSelect ()].read ());  // out is the output channel
 *     }
 *   }
 * 
* * @see org.jcsp.plugNplay.Plex2 * @see org.jcsp.plugNplay.Multiplex * * @author P.H. Welch */ public final class Plex implements CSProcess { /** The first input Channel */ private final AltingChannelInput[] in; /** The output Channel */ private final ChannelOutput out; /** * Construct a new Plex process with input channels * in and output channel out. * The ordering of the input channels makes no difference * to the behaviour of this process. * * @param in the input channels * @param out the output channel */ public Plex(AltingChannelInput[] in, ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { Alternative alt = new Alternative(in); while (true) out.write(in[alt.fairSelect()].read()); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Fibonacci.java0000644000000000000000000001104111105701167017631 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This generates the Fibonacci sequence on its output channel. * *

CSProcess Diagram

*

External View

* *
 *         ___________  
 *        |           | out
 *        | Fibonacci |------>
 *        |___________|
 * 
*

Internal View

* *
 *         ________________________________
 *        |                                |
 *        |  ____________       ________   |
 *        | |            |     |        |  | out
 *        | | {@link Prefix Prefix (0)} |-->--| {@link Delta2 Delta2} |------>-- 
 *        | |____________|     |________|  |
 *        |        |               |       |
 *        |        ^               V       |
 *        |  ______|_____       ___|___    |
 *        | |            |     |       |   |
 *        | | {@link Prefix Prefix (1)} |--<--| {@link Pairs Pairs} |   |
 *        | |____________|     |_______|   |
 *        |                                |
 *        |                      Fibonacci |
 *        |________________________________|
 * 
*

Description

* FibonacciInt generates the sequence of Fibonacci * Numbers on its output channel. *

Channel Protocols

* * * * * * * * * *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
* * @author P.H. Welch and P.D. Austin */ public class Fibonacci implements CSProcess { /** The output Channel */ private ChannelOutput out; /** * Construct a new Fibonacci process with the output Channel out. * * @param out the output channel */ public Fibonacci(ChannelOutput out) { this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannel a = Channel.one2one(); final One2OneChannel b = Channel.one2one(); final One2OneChannel c = Channel.one2one(); final One2OneChannel d = Channel.one2one(); new Parallel(new CSProcess[] { new Prefix(new Integer(1), c.in(), d.out()), new Prefix(new Integer(0), d.in(), a.out()), new Delta2(a.in(), b.out(), out), new Pairs(b.in(), c.out()) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Sign.java0000644000000000000000000001134711105701167016665 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Converts each input Object to a String, prefixing it * with a user-defined sign. *

Process Diagram

*

*

Description

* Sign converts each input Object to a String, * prefixing it with a user-defined sign. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The Channel accepts any class of data. *
Output Channels
outjava.lang.String * The output will always be of type String. *
*

Example

* The following example shows how to use Sign in a small program. *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class SignExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel[] a = Channel.one2oneArray (3);
 *     final One2OneChannel[] b = Channel.one2oneArray (3);
 *     final One2OneChannel c = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a[0].out ()),
 *         new Fibonacci (a[1].out ()),
 *         new Squares (a[2].out ()),
 *         new Sign ("Numbers ", a[0].in (), b[0].out ()),
 *         new Sign ("            Fibonacci ", a[1].in (), b[1].out ()),
 *         new Sign ("                          Squares ", a[2].in (), b[2].out ()),
 *         new Plex (Channel.getInputArray (b), c.out ()),
 *         new Printer (c.in (), "", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
*

* * @see org.jcsp.plugNplay.ints.SignInt * * @author P.H. Welch and P.D. Austin */ public final class Sign implements CSProcess { /** The user-defined sign to attach to each item */ private final String sign; /** The input Channel */ private final ChannelInput in; /** The output Channel */ private final ChannelOutput out; /** * Construct a new Sign process with the input Channel in and the * output Channel out. * * @param sign the user-defined signature to attach to each item. * @param in the input Channel. * @param out the output Channel. */ public Sign(final String sign, final ChannelInput in, final ChannelOutput out) { this.sign = sign; this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) out.write(sign + in.read()); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Regular.java0000644000000000000000000000747711105701167017377 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This process generates a constant stream of Integers at a regular rate. *

Process Diagram

*
 *    _____________
 *   |             | out
 *   | Regular (n) |-->--
 *   |_____________|
 * 
*

Description

* This process generates a constant stream of Integers at a regular rate * – at least, it does its best! * If the consumption of data is less than the set rate, that rate cannot be sustained. * If the consumption failure is only temporary, the set rate will be restored * when consumption resumes. *

* The interval (in msecs) defining the output flow rate is given by a constructor argument. *

Channel Protocols

* * * * * * * * * *
Output Channels
outjava.lang.Integer * A constant value is sent down this channel at a regular rate. *
* * @see org.jcsp.plugNplay.FixedDelay * @see org.jcsp.plugNplay.Regulate * * @author P.H. Welch */ public class Regular implements CSProcess { final private ChannelOutput out; final private Integer n; final private long interval; /** * Construct the process. * * @param out the output channel * @param n the value to be generated * @param interval the interval between outputs (in milliseconds) */ public Regular (final ChannelOutput out, final int n, final long interval) { this.out = out; this.n = new Integer (n); this.interval = interval; } /** * The main body of this process. */ public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read (); // read the (absolute) time once only while (true) { out.write (n); timeout += interval; // set the next (absolute) timeout tim.after (timeout); // wait until that (absolute) timeout } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/FramedButton.java0000644000000000000000000002104011105701167020346 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.plugNplay; import org.jcsp.lang.*; import org.jcsp.awt.*; //{{{ javadoc /** * A free-standing button process in its own frame, with configure and * event channels. *

Process Diagram

*
 *                            __________________
 *                           |                  |
 *                           |                  |
 *                           |                  |
 *                           |                  |
 *                 {@link #FramedButton configure} |                  |  {@link #FramedButton event}
 *                ----->-----|   FramedButton   |----->-----
 *        (java.lang.String) |                  | (java.lang.String)
 *       (java.lang.Boolean) |                  |
 *  ({@link org.jcsp.awt.ActiveButton.Configure ActiveButton.Configure}) |                  |
 *                           |                  |
 *                           |__________________|  
 * 
*

Description

* This process provides a free-standing button in its own frame. It is just * an {@link org.jcsp.awt.ActiveButton} wrapped in an {@link org.jcsp.awt.ActiveClosingFrame}, * but saves us the trouble of constructing it. *

* Wire it to application processes with a configure * channel (for setting its label, enabling/disabling and all other * configuration options) and an event channel (on which the * current label is sent when the button is clicked). *

*

* Initially, the button label is an empty java.lang.String. * To set the button label, send a java.lang.String down * the configure channel. *

*

* Initially, the button is enabled. * To disable the button, send java.lang.Boolean.FALSE * down the configure channel. * To enable, send java.lang.Boolean.TRUE. *

*

* For other configuration options, send objects implementing * the {@link org.jcsp.awt.ActiveButton.Configure} interface. *

*

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myButtonEvent =
 *     Channel.one2one (new OverWriteOldestBuffer (n));
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Example

* This runs a framed button in parallel with a simple application process * (in-lined in the {@link org.jcsp.lang.Parallel Parallel} below). * The application process configures the button with the first of an array * of String labels, reporting and changing it each time the button * is pressed. *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class FramedButtonExample {
 * 
 *   public static void main (String argv[]) {
 *   
 *     // initial pixel sizes for the button frame
 *     
 *     final int pixDown = 100;
 *     final int pixAcross = 250;
 *   
 *     // labels for the button
 * 
 *     final String[] label = {"JCSP", "Rocket Science", "occam-pi", "Goodbye World"};
 * 
 *     // the event channel is wired up to the button & reports all button presses ...
 * 
 *     final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10));
 * 
 *     // the configure channel is wired up to the button  ...
 * 
 *     final One2OneChannel configure = Channel.one2one ();
 * 
 *     // make the framed button (connecting up its wires) ...
 * 
 *     final FramedButton button =
 *       new FramedButton (
 *         "FramedButton Demo", pixDown, pixAcross, configure.in (), event.out ()
 *       );
 * 
 *     // testrig ...
 * 
 *     new Parallel (
 *     
 *       new CSProcess[] {
 *       
 *         button,
 *         
 *         new CSProcess () {
 *         
 *           public void run () {
 *     
 *             int i = 0;
 *             
 *             while (true) {
 *               configure.out ().write (label[i]);
 *               i = (i + 1) % label.length;
 *               final String s = (String) event.in ().read ();
 *               System.out.println ("Button `" + s + "' pressed ...");
 *             }
 *             
 *           }
 *           
 *         }
 *         
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveButton * @see org.jcsp.plugNplay.FramedButtonArray * @see org.jcsp.plugNplay.FramedButtonGrid * @see org.jcsp.plugNplay.FramedScrollbar * * @author P.H. Welch * */ //}}} public final class FramedButton implements CSProcess { /** The frame for the button */ private final ActiveClosingFrame activeClosingFrame; /** The button */ private final ActiveButton button; /** * Construct a framed button process. *

* * @param title the title for the frame (must not be null) * @param pixDown the pixel hieght of the frame (must be at least 100) * @param pixAcross the pixel width of the frame (must be at least 100) * @param configure the configure channel for the button (must not be null) * @param event the event channel from the button (must not be null) * */ public FramedButton (String title, int pixDown, int pixAcross, ChannelInput configure, ChannelOutput event) { // check everything ... if (title == null) { throw new IllegalArgumentException ( "From FramedButton (title == null)" ); } if ((pixDown < 100) || (pixAcross < 100)) { throw new IllegalArgumentException ( "From FramedButton (pixDown < 100) || (pixAcross < 100)" ); } if ((configure == null) || (event == null)) { throw new IllegalArgumentException ( "From FramedButtonGrid (configure == null) || (event == null)" ); } // OK - now build ... activeClosingFrame = new ActiveClosingFrame (title); final ActiveFrame activeFrame = activeClosingFrame.getActiveFrame (); button = new ActiveButton (configure, event); activeFrame.setSize (pixAcross, pixDown); activeFrame.add (button); activeFrame.setVisible (true); } /** * The main body of this process. */ public void run () { new Parallel ( new CSProcess[] { activeClosingFrame, button } ).run (); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/DynamicDelta.java0000644000000000000000000001603511105701167020322 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import java.util.*; import org.jcsp.lang.*; /** * This process broadcasts objects arriving on its input channel in parallel * to its output channel array -- those output channels can be changed dynamically. * *

Process Diagram

*

*

Description

* A DynamicDelta process is a broadcasting node whose array of broadcasting * channels can be changed dynamically. Any process can become one of the recipients * of the broadcast by sending the DynamicDelta a channel on which it will be * listening. A process may leave the broadcast be re-sending that same channel. *

* In each cycle, DynamicDelta waits for either its in or configure * channel to become ready, giving priority to configure. *

* Anything arriving from in is broadcast in parallel down each element * of its array of out channels. *

* The configure channel delivers ChannelOutput channels -- anything * else is discarded. If the delivered ChannelOutput channel is not * one of the channels already in the output array, it is added -- otherwise it is removed. *

*

*

Channel Protocols

* * * * * * * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
inorg.jcsp.lang.ChannelOutput * The configure Channel accepts Objects of type {@link org.jcsp.lang.ChannelOutput} only. *
Output Channels
out[]java.lang.Object * The output Channels will carry a broadcast of whatever * is sent down the in Channel. *
* * @author P.H. Welch and P.D. Austin */ public final class DynamicDelta implements CSProcess { private AltingChannelInput in; private AltingChannelInput config; private Hashtable hash; private Parallel par; /** * Construct a new DynamicDelta process with the input channel in and * the configuration channel configure. * * @param in the input Channel * @param config the configuration Channel */ public DynamicDelta(AltingChannelInput in, AltingChannelInput config) { this(in, config, null); } /** * Construct a new DynamicDelta process with the input channel in, * the configuration channel configure and the initial output * channels out. The ordering of the channels in the out array make * no difference to the functionality of this process. * * @param in the input channel * @param config the configuration channel * @param out the output channels */ public DynamicDelta(AltingChannelInput in, AltingChannelInput config, ChannelOutput[] out) { this.in = in; par = new Parallel(); if (out != null) { hash = new Hashtable(out.length); for (int i = 0; i < out.length; i++) addOutputChannel(out[i]); } else hash = new Hashtable(); this.config = config; } /** * The main body of this process. */ public void run() { AltingChannelInput[] chans = {config, in}; Alternative alt = new Alternative(chans); while (true) { switch (alt.priSelect()) { case 0: Object object = config.read(); if (object instanceof ChannelOutput) { if (hash.containsKey(object)) removeOutputChannel((ChannelOutput) object); else addOutputChannel((ChannelOutput) object); } break; case 1: Object message = in.read(); Enumeration hashChans = hash.elements(); while (hashChans.hasMoreElements()) ((ProcessWrite) hashChans.nextElement()).value = message; par.run(); break; } } } /** * Adds a Channel to the list of output Channels. This method is * private as the only way clients can add Channels is via the * configure Channel. */ private void addOutputChannel(ChannelOutput c) { ProcessWrite p = new ProcessWrite(c); par.addProcess(p); hash.put(c, p); } /** * Removes a Channel from the list of output Channels. This method is * private as the only way clients can remove Channels is via the * configure Channel. */ private void removeOutputChannel(ChannelOutput c) { ProcessWrite p = (ProcessWrite) hash.get(c); par.removeProcess(p); hash.remove(c); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/0000755000000000000000000000000011410045054016754 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Squares2.gif0000644000000000000000000000764410520670125021167 0ustar GIF89aT¥÷  $$$(((000444888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÂÂÂÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,T¥ÿUH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£JJÕ¡‡ X³jÝʵ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊK·.Û K4°Ë·¯ß¿€ L¸°áÃn Hôƒª#Kž\B¤X)kÞ̹3ÏÌGA{Mº´é¢‹¦>ͺµë×W• »¶íÛ’iÕ»·ïßFyÿ¼¸ñã4‰÷T޼¹óç"™ï”½ºõë©çÔŽ½»÷îÜo†ÿÿN¾¼ññ5Ñ›_Ïþµú™ïÛËŸÏ9~Lûôóë—ŠÿeÿýZ˜(àFö_K &èàƒðœ„VhálÕà…vÒ†*èáˆ$V$"J'–¨âŠ ¥h’‹,Æ#Œ$Ñ(ã#Ú]†8öècD:¢ÆãDyPiä’E"ù‘“LFi”Q)啨Y¹‘–Xvé—éå˜À‰y‘™d¦iš&*©æ›²I‘œpÖ9ái瞔陛|ºžŸ*è¡OÚt'`ÀÀ£F*餔Vj饘fªé¦‘6cJ¥Aœ–jꩨ¦)'0µªÆÿ*묨Z`‚CŠ2$|àë¯À+ì°Äkì±È&«,°<ðÀRÎz°ì´ÔVkíµÀF ÀR4À¶à†+®µêB¹¢ è@" à[ ´Š” œ{Û#$•B·öÖ€‹®»œÀ*dÁo””c¿1ðAR%ð›eØÁ+ÜØc¾9 ±Ä¾Q¬+ÁÓŒ±o /Ìqo#ñÄ—l1C'÷–òÆ ?ì2Ƚ‰¬îÌ ÕŒÛÍG1ܱÎG½rÌ?xñÁ(k\ôʸµœ4ϸùÜ"É:1'ômDe4ËH¥tÏLo ´B_ÛvQcW]vQggvBéªM3Ô6Kÿ-6Õ·Ym6Ö·i7×Û™Ì÷Ð~à ¸m‚ÓM¸m†#”÷áOg¬rÎÃ\±Ó{kŽóÑ/ýù„™G½9é;{.3èA/vãDÅøÜDÕ]øÝ–#ޓײ»MûP¶CŽûPºSÎû‘¾‹§¸èSs޺鯣ºê£“]:Ú§«ö<öѳ~µëM[;ôK?>õå{Ÿzß«k?=÷Õ[¤ ~öroow÷ Ø% pàJ€‡>Ç©opäÓ[ @Á¨@ àoúc\üú7¿ÿÕ! p€ P``PƒøC`þÞ'BþÝλàA `,`/TÁÿU C–0|éÙ'Á„´P p@!†³á K˜ÃÄ€€ ð`   &^ñzû ŸüÖG¿ö%¤° ‚G | ‡$È£C˜E‡ÊÓ¡PŽÇ$Îq‰ul¢†)<-’‹‰ôâ")¹ t €@DPÊš¼­vÛ)E¹”Èånr%Á€0 @„`6©óÖ–¶m„‚{ âC„9“Sîĸ+ÞFˆIûaÄ™(qåNRÀƒ$¯$ ð `Aƒ8À4Ñelš¼L„‘Ù¦ ƒ¨@ª€(0EÌ ÖR òì— (ÿJîQ$ÆÜɧL¼ÐôôarO†Âs€$ˆèIpOÎS"‘æN€€jäš$)"(Ï‹¾S¢ïl¨JÄY4= Ë³#B|©‘3@/ âˆÀn³´éÁî‡@ ¨€‚ÀÀ³9€o'è`Ë š‘n°=HÄ *©]"³)ÅVñŒ#ѨN.ÐÁŽ ¤#)"2Ø3ªñ‡au{Ê–Mè Lÿ„EŽðpŒ°g…XE!à“<Ä .ÁH4uˆQ„¢HðŒ~$ :™kà0ªbĪxZeˆ €…·L­ ¨ØÕ×ÿjà“´e­ka›ÑãíÄ£@Gá*’lþ›Ä¥2ˆW¾Ö¢*E‰_‚¦w°Š4M3ÂC3fS€‹Ý©GzT­.ö…t+ÛÃ5n“‡"@pçKßúÚ÷¾øÍ¯~;˜€n~Īl.þÐÆ1êõƒâå#ï:àg6$د„'La €+A`qùÎ¥2ׂxUÁý<<“d³Â(NqŠ /™d»/;ÀÜŽw±‘½©ˆP٦ʳ¼ Eæ*” 7à@* šÁ!ÄøK#CQÐÚ[ÙŠM•² ¥|AV‚D­9Ilp!X†ÔŠ>´`bEÐÜnŠ@ÿžlôìI¦+4•`¾RÌnA`|ø1ƒÞMc o<À[­TL£ý|F „$ Í :ˆä[™ö"NóÛXY@à±Gµë ¡¸€ F™Ó-üô'Cfœˆ6Œ #nHŠ81:úÃOˆ­©Ø¯”ÐYhnóŒ+NjÄ: ¤(ûøGÜR%²I)A D–F6>óXJ?U' ¨ô@.m‘U6ÛÙ¸ dÿ¨íwZ@C|6´g©luϻݬö­Nëšy$²,ˆ ò8p<[ÞÎÎã?WÓ–’$“&v¡ŒýšHßÄèµ@ÈD±žI«m’‚4NÖ¬ÿù5š$ çb¶6÷ ÇQâè.\äú ÊO£ò‡'‡â®‰yOf^š‘÷dç¦é9/gZbØ'D'Ñy‚ôÒ(vlkzÅ¿ ”¨fê;©:i®n¾¬7•”\1‡õ^j=è\ÿ‰×=vˆ}4dwk(GÒÑ„.Þ Ð[óô̽3uÏÉÝ=“÷I¾Üéq—ù’_“xœ,¾3ÇÐã·nÉÚTþ&—çLæ7¹y¸w6Ÿ·Iè73zÁ—žð‘úä]“úš¬^3­ : Ù÷-þ½‹×ýàYSxž3µ§Éí)“ûá ÿ4Åóì[“ü™,2Í÷Éî+iHÏçü'×—LÿöözâÇêÓgMõeþÈŒÿ3Ï7Môqrüͬ?&í‡ÌûKV~èŸßðéw÷ùW ÷W>!ý'ÿg|høHû×5ñWówõ§è8˜8 ˆ (}i÷Jk×;K÷bo{§Gyßç(!ø;HhHØ35è<#ˆƒ%HXt1xtÿæAhÛsE¨G(uIHuKØM˜789X;8=È?YøsCÈ…Q¨ƒSøuUvW˜rH] (Oy/H{mhwoÈsqXgsx[è]H_(a¸cøe¨€{Ç{Žÿäwx’¤y á ð qE1ð Iq`/¶ñæ|Î×û0¸‘î¢Ї¥áõ¢zEНü¢g©ØÐ*ŒÂ8ŒÄøix"ÀoĸŒÌØŒõÕ-G7ÎXÖ(Œ P…—£‚ˆÒƒò‡0±Þ8ŽÂ·‚äxŽÍ!Žã„ŽìêèpíÈñŽ(öX&àèùxü8ô(‡ý°ñ~(É lûx YvŽ×¹ ™Y‘@²ƒd‘Y‰‘ù‘fØv 9’æXŽ$y’%Ù‹(¹’”è,ù’ð—’09“Œè’4y“5ÿ©w8¹“ø”P3$’< “T´Mþ"i”A‰“’ålÀaH ”I‰’$F´O"FATTmôMîEA¥alvF4Fgtsð•Qy’iDbP(ðiZ™f(àÀB*$–(°@tS(0«¶Kh™–$iði.t^M`j6Ædf¤W¼†T ‰õ8˜„¹‘­ÅJ?„A“iO6•@x_f44@(p˜&˜6™™ ™X¥öi=ôC —As[}‰uµhíÕ™êu?´Ôšëˆ™°i‘ ×h õCq¦ê5ž6[zi*äFêµYBôC`™iœÇ‰’̉$$2žâ¹P5r”)A‘æÙžð¹%ê‰"óŸiùžö™ŸsRŸ& ŸÐ^F±/0.š  º  Ú ú ¡:¡Z¡º»ˆ#´Ò¡ú¡ ¢":¢$Z¢&z¢(š¢*š¢Šú¢0£2:£4Z£6z£8š£:º£ ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Plus1.gif0000644000000000000000000000415710520670125020462 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú RTàÁc‰I†³§:ÔX¸(ç[a¹ò„E{„À¿¬ ‡¯?›5´G ÐtwQw4µ@X-/sˆîÉÞ™•„bËW6G¥–´¼ûÿ«à÷UÌXwzwo4õ´0_çp)`€ÉV56ãå˜g®ùæœwî9HvÈÖý;ã&ü5Ö T€®O_wÂå ÐV]âMoCÚ´öºvecë´A‡µ¿‡{F<´ Óz0A‚L«ÁU±sÁg¶#NzµÙoô@÷ì-oføš?&úŒª¿%û‰º%ü†Ê%ýƒÚï$þ€ê#ÿ}ò_ˆ¨'jˆ€w2à…H'>ˆqr ƒ è& ˆ‚k² €0h& ú‡ƒcòà~@¸%⇄Òñ€à’µR}OW(DÎë’²pa&@2UñTå¸äb"Hùÿ –ûìðTÙ1¼&‡²¬- ‡EDUÁ’ˆ¸†6ËáNÃâ$18ϙډ¸EtQ7_X`ÄèÂ2šñˆ¤Jãl4&.´Ve<ãmX6Ť .K¡XD=jÈ„õ1ä…)E>ˆ‘ïqä{(Ð$H²G’ì©ZdÉô`2=…“Ð&­åÆO‚§—Ûd'ÁcʉDès°Œ¥,c)€¹QŠ·,*;$€ˆ`•ÝieuBÙK¸³:”ΊIcJ'™È©€+ôÂ[ASyÕ¤Õ5Ë—ÍXmÓ{·ü&xœ‰qŽ.œpÌ%ó˜Î\’³8æ¼]7_Oé¼S7õDÎ=o“TÏâìó4ýÔÍ?IÐÛ ·dÀÓÔ¹ ÀH¨D'JÑŠZô¢>ÂÀÀÄP…TF ©HGJÒ’šô¤(bÀ;ÊÒ–ºô¥0©LgJÓšÚt-;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Numbers2.gif0000644000000000000000000001237010520670125021147 0ustar GIF89aD<÷  $$$(((000444888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,D<ÿUH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£J*0„…«X³jÝʵ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊKWîš ÔÝË·¯ß¿€ L¸°aº$È ¡€ªãÇ#KFHÀDÌ«“3kÞÌy(—-tMº´i•ŸCŸ^ͺµëˆ©ab~M»¶íÓ±_ξͻ·ï©¹]îþM¼¸q¡Á[?μ¹ó˜ÉY.N½ºuÑWN¿Î½»÷‡ÙUnÿÿN¾<ùð)Ç›_ÏÞ9z”êÛËŸÏûýÉøôóëÇ Z¶èýÈŸjh`fö™„ß 6ˆT‚%-èà„ú!IV¨á†4]8R††("jýéö߈(¦Ø’‡"¨â‹0^ÄbH.Æhã ÍR8öèã@:~ÄãDÚ¤GC©dŠGv”ä’PrØ$GOFiå„SnTå•\˜¥F[v)æ~_fæ˜hÊW&Fg¦éfyk^Ôæ›tr§EsÖ©çswV”瞀×'EjhoƒNTèA%TÀÀ£F*餔Vj饘fªé¦œvŠi'Lxž–jꩨ¦ª*¥XFR¢-ÿZ\­¸æªë®¼öêë¯À+ì°Ä ¬8˜Âëì³ÐF+í´¼Vp@¨#Á‘¬M€Aƒ |Ð`Š1(A¯–(܉!ik\4È­qó äîCõªp/qðÊËnùîÛPÀêØ/ƒùþF0" ìÛÁ&ìÛÂþ¥Û ÄJÜÅ&ZÌ Æÿ+ Çëz| È#‹ Éʩܑý¡¼²Ëû±,ÍÁÌ›ÌjÌ›ÍÚᬑηñ\³Ðô-Òm›Ñúù|›Òé1-cÁBŸÔ¶Q ŸÕ9]›ÖIƒÍž×÷™M‘Ø´‘=×µ¡­ Ú±ýšÛòÁM›ÜÒÿ-‘Ý®áÝžÞ¯ñ¡ß°a àg#þá:žâ2¾á®AÞ¢äÞšåæaÞšæ4rž#åû^žè¬‘.Pi:Cž³¦:y¬¯æ: \ »ÉÞþøìÖÙL‚ D PÊ«à@`º`¯Pí« ï]î§±l‚\°À*Œ/\€¨Çj}BØŸ¦}wÜ›Æò¼€æ«€¾½û]¶Ú—Ÿùq§~¥¹_þT@þ‘Ï ï´ô>„ÄÏ4¼IÃ2]Èß €‚ ôŽw@g°x!¬‚αþ `€Øy€†!ô 'h&ä‚¥É`ñÿ|È× ‰ˆ"i„X ŽÆˆHB"H&Rlj¢“¤h/*žé\µ0ò!$Ø€@6 FÀÎ&V|Æ d`ŒÉõÂF2æD‹l˜M@Ò0v qøð·¨q„  H“8ú%0ÈRHC¶± æÛ% ò=C’`'€4ÅE} ²$T "É@ˆ@ $¸¥ H0>˜à–"8e-‚üyÐ újbÉÞ„Èä@6ÉÀ¢`„ù¥«Ì7B]ŠøCÁ,Ïx“Täp!D̹‘XÎr$AGx<¬‘0€< @ÿÆ‘T8“fö†öŒ¦@¨K7îO”#|$<íÉOCês ßÛ#NØ9Ø3ëlå 9Bl –¼‹P¾.°¤Ÿ,TÐe´ êÌì™Ð04€ÕÄßLÉÍüßã!6Q)ÒW6d<HÖÔ™0|¶ªæ-M¸ä‰Ð¥ñz>ßÕÔw"eLÕ¶ºõ­p«\çJ׺Úõ®xÍ+OÐJ‹4´Òó*/É·T²u‚Ýä ôÊØÆæµÒTG3ÒPNîÏ¡ Á£ùªH ²¬*Ø|i5f@­01(oÕtþt‚!üÞLÙÒòÿå&§muÉT^¤mU(C&‹‘ÊjU ãËçL7{[€@‘d\éù )›ÊDµ·9ÀG]øÓH €!Ì'aÉGõ™ѳ#E—©â~€§Â¥ªo[Fu5›ék£ÝhVt™àŸe6)@a.`¦•Ìé|€;Õ…öµ"uLŸ0U; d¿$H…m•l }aìí92hFÖ!ÄÍÉE ÂOf*X>x153CÜ œ_U¥Ê‡ â'Ø_@qÅ„|²Ï,È‚dX»œºìgÆ“I1+ç[9#÷ìÁËqLj<+ ÉKV2v˜l'Ê’‘²¢´Üe0‡ŒÿÊUƒ³~̬0,ÿŒÍ-“s½5;O Ï7Ósù¼5?w ÐAô|è<1CÇ ÑKS´|e7{jf¥ïli`Ò©#tÙ:ý22QÒíÙôŸIÍ‘O£š=ª>4«sfê(¾ºÉ¢~›£÷ê¯ÝºÌ¹ÎÛ® ×ë´ýº<±~ô¬‡Vë-›<Éæõ²3âj.·pÚº~¶³­µ`nØ™+öÜ´íhÛWó¥›]no7Ýac÷ ¹½8w_Ü£wßÈÝs‡Þ©v’?fïÐá»uú>¿¹ãï||mò®Þ¯Óp„?¼nïáÄ­SqÝÜã—SÂS]ðÕ}¼{#ÿßI°J±¼A˜@ƒ*@Îu«Û# 8À¨ÅóžûüçÆâRÐ  @OºÒ—Îó@6äxê+°ªª«J°ºÖOõÞ2(غØ;•€±›=Sì+‰ÀmS‚ê5&€k³öÚ´ýí®)±Ìë“q6¼'wÇûjL`;m/xӔ؞{·â_ÃøÆ†ð<=üm&ïšÊ[ž3çiäiÃùÖxþó™Á|T5O÷¾‹¼7§G½dbÀ ð–ä]uØ»]ö¤€oJÏšØ2ÂGïýôwžÿø‘I>ßoÞùßC3Òßüò§Ì›ç_ß1Ùß=ÿõMoýï#øÛ_³ïͯ™ð·~üÅ/?û!ã~Ò§ß}럿dêŸøûo«ù;á}ú÷üçÄ·8€MQ€­q€§‘€ ¸ ÈhI1«Q¥qx8 CvøE‚¦Á¤Q‚&8(X*8,Ø‚Añ‚¤ƒ1ƒ4ø688È:¸ƒ=уñƒ›„B¸DÈF¨H˜„9±„›Ñ„™ñ„PxR¨T8Vx…5‘…â!•^˜è(ex‚g8‚l§†kè‚m¸e$‡qXƒsX2Ýg‡wȃy˜g{؇F†“±…’Ñ…‚Ø„(†ˆÿ˜ˆ+±ˆ‘шñˆ˜’”ø–x‰'‘‰±‰ŽÑ‰žX è¢H¤XŠ#qŠT‘ŠS±Š¬®bˆcd8‹Jø‡ˆºÈµ(°(²ø‹ŒQ1ŒQQŒÆ¸ÈÊÌØŒñŒOO1ÔxÖèØèÚ¸ÑMñMŽâ8äÈæÈ蘎±ŽKÑŽKñŽðøò¨ô¨öx ‘I±IÑþ¸ù ·ˆb¨Y qG!HÑyiyY‘q‘E‘‘F±‘9I Y"9’*P’ž‘òå‹*‰¼˜h0“˜8“‘ÿV“6ù‰8g:¹“¦Ø“¾ö“@ÙŠBilDY”´x”ã–”Jù,‰.9\ ™)9’Q'IWÉ‘Y [9]Y‘_ùa)céei!S¹h&iYkÙgqésÉu wy'‡˜‚é@tJ‘—;±—?Ñ—±,0˜™ †‰ˆ©ŠéŒI1× /g†Ê‡†ȇAÑq(w˜L¹oNYš%‡;U©Ž©©p« ¦i?¯)—™™ x¤I›­9<¨šnhw½ùµ™@·±9¹hÇÉAÉ ¹‰»é|ÅéÏùDщ˩r³iœ¿¹=ÛÿéÓyÕ€×ÙÙ™EãùÝY:ÍYëÉoÉåiçÉéÉó¹õiï¹#í›9ý©ÿ©÷Yùi•û¹Jc  ÂI‡o¨eª zj߉áI?újkªž!z@#Š Ú!m)Y+Ê*šf1j-: Š35 J¢ª‡uˆ¡)ªA7Ú‘%ºmEš? AÊ¢KHê¤G:DÁ9}ùxªOúQj‘S:oMŠ_êaŠ£c*q'ÊŸWÚDIJ9*;z= gJiª¤C ˆezy:{*§kªqm ¡ozEqJ’…ÿêwñI*ƒÊ¨}Ú‹꜉*G‹*s /š“zwú‘¡º’úz‡ê¥™:&Pa1åŸ›Šª•J“—Ú €-Ñp“Ic¥Yª}¢i]0 «*ÐpáDaLaKÙôME­¸äußDFÙZ­ÂdK´e¡ƒ˜ª½·ª1‘ö„¬ØÒp¢õ<ÂÔ@4•?7DC,¯à³¬ÞuJ44B±“¯5Z†¤<êCC[J uzB¡]皬‡?öÄRîJT,pM)å< A&à¹Ô;KZ3åAæ\*®DÁ,U«9ÉP pv4;mÿ5 ЪqJöA›?ìZ6V^å<ù ŠIbtYd].N4µ’‚pcï7°µL·tßÅSéÔpŠ”MÿsY!ä?ÊC)dgKÉÄ@¹5Få­Å;j”QNÛ[»·¸âuZª²Jb³RåB 'VÞÅOßs`[^þ”?Œ‹MÉel Mø•k´u[¨e©hr°ÏñL ¶¬: páã*`G§»Féã*Ö**ð_ÐF§kaü…»v*Ժê$ ëðb¥ §úÁÛo¥{Ç+®Ì÷&ÅûÍë²>™&ÑëÓû·DŠ&×ÛÙ+¬Xÿ{%ÝËß+~ák%ã»å{µ€Ë%é«ëk¿[$ï›ñÛóK$õ‹÷k€ŸŠýû9ËK/³Š¼ÿ{l;üdì¼Üg½ |f L½C Á×#ÉËp\go’Á·ÁÖÁ¬I¼3 \inâÁwœ–Â#\ œ=,¼j.œ¿?²¿GÃ"ؾâ;òVÃç%8l:œ‚/LED>¬l@ÌÃè»ÄÒÖÄÛ;&C\I|ƒG˜Å½glqiü²küB"lÃ>Bs3Ws]âÆÔ!à·ÿ€xƒLÇ* Ç£ÑàX”\É–|ɘìV àÈ:åÈü”?BÈ Œw¢<ʇRʦ(¨œÊ{²Ê¬\'®üÊ}IJ,ޱ\ËŸëÉ[ŒËPr˼ÜÈ~üË—èËÂl%Ä\̽¬ËÈìǼÌEÒÌÎÊÊÍnBK ô¬‘VˆÜjÓLÍhò]hÅ´á®aFËÞ\$†ôKûÃK§”,…¹þÄF]UMOË“<Ë0>0a´ÓÍçÜ%j«¶ ô³¶µÑ¢AcµØ„<ýÌRlE§Õ±û<9Á<Ð0‚>&dBßtYDõO—5¶·äAiE"pZµå?à£Q½Ñ­"ËÝTR!}K#MS%íÐÀ´?÷”>×ô@&°¹dµÐ<Ó­±L´?”×ôU:}Kc«“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzJHðèr:n'ªHüèã©¡ÒÿU¨4Ùx™J’Ù™îJf—dnpê  ©±"|°²Ø­ÚRˆ‘ƒ{²­ºjåœFî飨ècT¶ÚA® kwβdD;m»ù)t°å¡Tn›%€°çµ7B À­CŠyÁK½*q/¼ò¾qGA~Ð#b Ôñ™t¸À•7–)‚ø"`nI:j“Ç,óÌ4×lóÍ8ã 9(¦±?J ®TyæÀb~B å¡Âv µÐj²K—2#ÀlBÔúØêÁtPt•ƒ:€d©QJ°±Wí@Q:6¥*k­žMÿÁ¡–Z´Ç×þ}òß\0°}k)©ÜZ÷Å(=€ÞóºÕ±s”ŸÔÀÖvuNҤɉþ•Ý¥Çúiƒ¦·:몿ÞbëZ¡Îyì²ÓHûR¶O·ûä¹ÏŽ{ðÑ O¼›ÆQïåý.;óAoŸó+ïdòÖW$ýÞÙ#¿#õ«oz÷Þß&¾…àËtþeé§Ö~¢ë/?gØ“ýû âßæü\ëÿ%ÿùñ_“x~F€`²ßò¸~È€þqà„ H Þé{ TUý2h± rP~ÜÔie¾ È‚áDPx .È…°Sáý<(CÃа†„áHX¨òP7:Œo¹WÂ!ŽƒFìY…—DÞЈ>\"yX(4q!¨ZkB­ xñ‹` £ÇHÆ2šñŒhL£×ÈÆ3V ë’ `€:ÚñŽxÌ£÷ÈÇ>úñ€ ¤ éÇhàŠˆL¤"ÉÈF:ò‘ N@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/DynamicDelta1.gif0000644000000000000000000000537210520670125022075 0ustar GIF89a<÷ $$$(((000888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿQH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O#*PJ´¨Ñ£H“*]Ê´©Ó§P£2Åpâ§Õ’ Lʵ«×¯`Ã"}àªÙ 6œ]ëA¶p1·®Áìê…8w¯^¼7IT XÁ€ €¢ða¿ ûBŽ Ø¦„+Pp@€˜¼P2鵕S>PÐ@Š >xÐÙÀƒ…QˆðŒ‚5 ¢O'4-üj꓊+<0 Ø€ÀÍ _ÀíøèÍ¿ƒ7H|»ÏãXxÿh BîÞ˜/gÎ~³uï»Ãß žä{åÏcWO=ûxì÷͇‚|âTI¶½&^aˆ©w™kgLà|hÓ#QhØ`$¶Yl [„Ρˆ]_†ÒÄaMç DÂ@.zcŒ2ÍHS<–™vîÈ#L>Îdb-9š†FéR’7… å@Q^¹•61ÐÀ“Gf©¥jy]…|&]cÊX¦UÀ¡™&˜E²Ù¦L °Àž|öé矀*è „* §œ XYç39 F*餔Vj饘fºÁ¡ð&†v2ú—5} §§<Š)êH¤þØé§P†ÿº*K­ÎĬ1ª:+HµîÊ’®¾vÔk°)K¬FÃk’±Ê^”l³#1 -EÏ+Âh ˜ð‘´ÓJTm°¹â`qÛ-D­ÞØlaÚ‚ nGæžë©0pd‰& „/c ,f˜…‰ß`ˆèÜy ÄvYy+æ‹P¼ò2Dj t X¤pP¢VÜ&”hBÁ£1 À$(ÖXŠû)àn…&(pÛAG¬Ð·ða7PyϹ\nš—"Ð,§7Xh—ø°¬6s„³w:¶XÏïMžÐ¼rÏ«èbcÉtÓÈâºjgæy¶\@fPõÁ)–b;×ÙBˆxÿ óÒdô´wlF®›M'‚®ÁöÚ‰ LÇÌZ£Ð€Ìfùt(Lþ7à kvè->Ør¡ÌÝØ¤W4¸²øADÁ»²ÞúD¯ïnPhÚ®n;“ B¾?t¡Â¿ûÄa_å§ÔWoýõØg¯=õ {òõ¾@ËúÀη.þøÀ£y¾@链>ø@¾/öøÍŸ¼LǺþø#ˆÿÀÂï{LH 8@²y |H›½J,È8Aƒ\À<ˆÞELPm„„¸€»‚·.ƒé`A e`†#ý p c˜Ù;+Õ ÿa8De^ó„®õ›ß€éZO Hð$@Lˆ¹p³QQ]ØQLWˆ’ âψA"zP‡Ÿ/ÙÐP±‘€ Ó„ÅlÆàÀ{c˜€\ÓÁŠ3»Íĉ9<4„LbÆñ¡ñ9)ê¦çÝøñtÎÉP€:•i“å±NhÆC›-¶èSËMCÂ)òì$ß#%™Æô<@koëƒ •Ìc¢©QvÈe ]N‘«”ÍfþXÆ!1"³Db¿nã~ýÌ9SÓZ/ƒJÑ\€9(€ ™ÉID2†Šè¡eaH`‚W2Ò™8‚à3AWCÝQÚ \“ÿËË8&¾˜uB$³?îP1Ì\NÁ0ƒ9F™#ç;B±æð‚'ù y|È5´LH/ ‚¶0¤Úª€>*˜ Ì…æYä9×’惸À&a O ~Ô!³<ˆäȹ6ÅÒZŒ[\6³SšaP$øÜŽJ,ëG ÎS‰HÕ`YU<[£ç<ÒU_}u4ÂŒÏVaXÖ]5¬NëÍzÁ^4­\k8ÖÄU®d¥kEç¨%¯€ lbb*ö~‹Õ ][‚C=6¨Íj+K>@¨Îzö³ åS8…ïEV²:A¦VËÚÖº6R£=0«,ÍÿNk²=ài b[h UÝ-''+WàŠ¶Çâën‘K¬ .W¯ìmÓ˜,Û &3BRˆã ‡º¾²-Pä]=€™ !¨„+âBD—›™ã8I› Í,¬ ¨Àåȵ³S½/‚nõ7·ÂaF? ˆN…úƒÙ5`ŸÏ+s´ðîJç $‚ñsC‘Çš Ш ' ` 8N‘u6<Þ°òÌ:øz‰ËK ÏJÓ›êÔ¯ô0ŽÁ/.ñŒcÅÞá‚Ä1Û›ˆ|S¢¹x0-È dãUIw=¡pqª,ª+ã&H4R˜!ÃeFyY N‚Hš‰ÌÞ3Ÿ«ßÌSuoL*€»TØ€n~„'%8UÎ0é@ðngç"çÙ!ítM\dCmïÑŽ4¤  ¨õ¶Ð/I4@°Y¸‡nˆ 7ÝéB_Ú,à´§×dhL»Ä«îóêfùyLµVÖ­µ”ëcíúJ½&Ö¯¥ì` ûHÅöÕ±y”ì]-;FÍžÕ³5íUM»@ÕÕµ”mFm{>ݾSüÊ^h ÈÁ@^Ëîv»ûÝðŽ·k5@€ª »!­¾÷Íï~ûûß uÀ˜ïMð‚üàO¸ÂÎð†;\@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Numbers1.gif0000644000000000000000000000361710520670125021152 0ustar GIF89að÷ $$$000888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,ðÿEH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³fD rêÜɳ§ÏŸ@ƒ J´¨Ñ£B'Ø$IàÒ§P£JJÕç‚!–‚Ì`@«W’ ”~å˜s¬YeÏfL«¶­E¶n)ÂK×áܺïâÝkP/_…~ÿò ,¸/„ˆN¬ø0cÁ‹G~lv2bË”½b†ì83ÞÍA{¦)zoéÑ1O×UÚ%븯[¯ŒÝ–¶l”¶Ïæ¾]r÷Xß¼E×Ü9øïâ­‡G‹µòåd›~]#õš×«_Ì>“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzº•š`úP©œ…:S, ЙÁÿÚ)]€*«zf´A—AnÐkAZYÀ<êk±d‚$²Ìv'ªK  D Šù£±ÜÒÁ?ЪXࣽš»­>fð£Êʤ£@€µØN둘PFp&¬u@XŠi¥ € ¥+,b^ðA]JKöÚ‹ï{úvd0•Ûü-Ank0¬0äÂeB*îÂñƤ@Æ4×lóÍ8ç¬óÎ;ÀCÙV©0åb¹çÈ%\¥¹E"àÀ˜¿¶Ìk(iq\ÔŒ@´ -D‹0¨H"M°'«<èð¹vˬ:à€À¤u¼o­ÞLÿŠé‹D@q]FPiß"”JAÔ·à"€@¸@‹3ŽÝ*= 2×@cþiçt5À9ÇŸ7è¹n§—ž_êÇ©¡ª®kÈúWóÊV{E·;7;q±Ë{ïNþ¼‰»k•ûtÅ/u¼xÉÛ´<{Í_>|ð;F_úóùNðÚogýÕÝc„ýÞá‹ÿ½¼çk:¾]é'º>éå{Ï}üåµ¢ým¾:ý¸ãŸÿMÒßB˜ªêñ¯ó; û¨Àý݆€¡ ˜X?R°kÜO?ÁÕ]0{üàC(BÚnƒêàATønª„ð{  ÄBÿÌpA74 M˜œ>ȇ¯Û!}t,(ıEG$O ²Ä;‘°ˆ†!¢›Ø(z7`€ò5É&ÖÊ€ÇHÆ2šñŒhL£×ÈÆ6ºñp\c3Ùp`È£÷ÈÇ>úñ€ ¤ IÈBò‚L€¶ÈÈF:ò‘Œ¤$'IÉ—;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Merge1.gif0000644000000000000000000000450110520670125020567 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìú40áàa ì„À˜ì·ïþûðÇ/ÿü»O›Q×nãTÜÔ.óÑÈÑŠ÷ çÆr·NBÀ¾¨H#mËIö6RœË,‹/ €šÕ4Ð É®eÿƒY‚˜“ 4Éš Fòv¼¾õ“ 2œ ¼§ÄË q °w7»Šÿ žYezyÀ8š Œ-}WAâ¯T¨*)òŠŠ§²b®°H*-ÚŠ‹¡ò¢Nð'Á ÊKŒ9‰ NÀè)4¶Š›r£ªàh)9žŠŽ“²#©ð¸(=†Šˆò£§(AnŠ~2dLȸF3ÂK‘0QãMy&H.Š’Q²äZü³Äð¯!«Ü†xô¶qí0T,vA‘]Ïe”Yô )e€âêº ÀN¨M­jWËÚÖºöµnÂÀ EZ…&TL¸Í­nwËÛÞúö·Xb+kKÜâ÷¸ÈM®r—ËÜæ:.;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/xor1.gif0000644000000000000000000000414510520670125020344 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú,Ò0›0Á’áì©Î!Uðš ®}\X®£åoy~¢éc¹¾¡íGùþ ñ;9? õßxŸù‡¸¿žýÓÐÿîÀ N|Ðã”@-ÐM ,Ð×AMÐLôÏÇ”ÁýlpKÄÏ¥ãÁ a}Fˆt$eáªwdvá‘ÊX+ÈÅD`´ïŒ†5,Xvÿ¨æ¶¬™`a¢@XXœ!"@®¡ ð`¥Ä%Ú0TC ÎsÚæÃVÑŠB Nv†ÃÅRiOWLÔMö.µ•.‰JLãmX6Ť .K P8Ã/ÊQC*”Ï/È÷ òA…dÏ!ßC&%2=‹dî° G‚'’é9œ„(i­/¢Ê“)å(iÉî`’"òœ*WÉÊU  F iÆŠšÙ‹åAéE?n”Ç,6ÁNÝŒStÚäfCÊy›sÖΚ¯r§tØyy"‡ž¤±gqðYJ}êæ%œ¦Î…XàFJ¨BÊІ:ô¡õ¦‚*¤0ʨF7ÊÑŽzô£ EºhÑ’šô¤(M©JWÊÒ–ºô¥k ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Merge21.gif0000644000000000000000000000434010520670125020652 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(͡ڌ Óâk´[ÂÀ:áì©ÎyÀo|‘ka_®§žMkZ9‰[G"ð™øÍN{?±Ü*æã˜å&dOI2Ô,àxka¥f8&JЇ[òá£ÿ€ˆ%!2ŠˆQ2b¢è$%Љ7râ  ")ŠŠ²bŸ°x!-ꉋòâÀÈ 1Ò‰Œ2cœÐ( 5º‰þqãšà¸9š‰Žø±cw<ೃà!x¬«ƒ®‚¤,\ë#H å3Héˆí Áèbh0™áª`Ù¹]ïPv¼…È’Šsª2‰¸†6Ëá(E%ÊSe28Ïñ%+¹ÊPb28ÙŽ,K…B]59¯Ø»—š?*²—·úeqX6Ť .K ŒY!dÒJ™7Zä{°"m²‡›òfzÀY 4Iœà!§|×€¡³;ê|ì$ÔNkÕR ñdO š×ÅÎwV'Ÿ‰PõJЂT5º'>[ Ê}vH?¥PðÌ¢j›(r*Ú `ô˜ EUH RµT¡ÅF‹“Òú¬T7-œ5cSÎôU5•áMU•Ó†´§àyém€š½Ÿ2t¤´¼'Qå·ÓS-U:B=ÍS‘UÒLµ8è@H`5¤.Ä0’XÇJÖ²šõ¬hM«000yU!€‘\çJ׺Úõ®xÍ+Š0Ë·úõ¯€ ¬`KØÂö°ˆ]K@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Pairs1.gif0000644000000000000000000000375610520670125020621 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xîEdÙ¦µË׊½"´A—»ö4Ážj€/AŸÎ[ÖT›iÀÿÚX-MûÒ™¨–ïv"pIçÄðò”.H °ð_p0¾ëZÔ0¦RÛïï«æª™°N„x\™8‹ŒpÉíû¨šˆ0Àf ê¾]lMCFïNôœóÇ%jõÖ\wíõ×`‡-6΀uLûB%ÉŽÙ2¬Ñî©­O Œm÷ÝxãM€‰!ÿ`µÇ@Stò@Ÿ† ‚”o ôÁâð©ñÔ:°õÿ5Î:+¬ï Q è±J“°èŠ jÔeiÐ3åU¹@OÔn¥Q0Ád ¯¼Ye?ÕìQ°.Y(Æð=PyhÊ;ÇüƒÑ/7½‚Õ#wýÙ·=Ý ÷}€áÿ6¾åóvþ~éç¶>~íÛö~}ñÏ6¿|õÃvÿ{ù·¶?{ýSÍÿÒÀÓ Ð<$ÍÇ“ÀÐ,< ôÌ»ÁÍLP;Ä̯“ÁÊl:”Ì£ÂÇŒÐ9%dÌ —“ÂĬ9-4Ì ‹ÃÂÌP85Ì “ÿì7=ôËÓsĽ Ñ6EÄËg“Ä»,6MX½(Ź<±5U„ËU“Å·lñ4] 䦸0ªå‹¤1£Yн³¹ˆžQcYà¸9*fŒdLˆ©BGÌì1xxÌc›ÜÈ¢>Væ¨$„™"CJ‘=qäc ù8E.Ò’’dLNEÆMZò!! À6@ÊRšò”¨L¥*WÉÊVºò•°Œ¥,[yÌì“ áÀË^úò—À ¦0‡IÌbó˜ÈL¦2‹Éàò™ÐŒ¦4§IÍjZóšØÌft;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Pairs2.gif0000644000000000000000000001212510520670125020610 0ustar GIF89aj<÷  $$$(((,,,000444888<<<@@@HHHPPPUUUYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÊÊÊÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,j<ÿ[H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£JJµªU†,8`ØÊµ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊK·®Ý»x편*0‚ y L¸°áÈ+^Ì/ |5TàK¹²åËM  ¸:æÏ C‹¦é@gÏ£S«^ÍZcéÓ­cËžM[àk«këÞÍ›òíª¹{ NéoªÁ‹+_Îüæñ©É›KŸNÝäs©Ñ«kßνâõ¨Ù»‹ÿOžàw¨áË«_?ýüÓôìãËïíÞ)üùøó³®ßô¾þÿ^ÆSþhàR ¸T6è q¦á†ÚƒV!lf¨!P *Åà† †ÈR‡I}(â‰(ŠD"R&¦èâ‹­xT‹0Öh£C2Eã<öh^„ÀMèãD"”cQ;©$ŠG•ä’PnØäPOFi%…S Uå•\˜eP[v)¦~_æ˜hÆWæOg¦é&ykúÔæ›tngOsÖ©§twò”瞀×çNj(oƒêT行ΖhN‹"‚Tj饘fªé¦œvêé§ †*ꨞnÀ…&P@ꪬ¶êê«°jÿzA %=ŠS¤y €"ôêë¯À+ì°Äkì±È&«ì²ÆN Áƒ(°³ÔVkíµØf+lœ:’­7áZ{5ˆ€ ^ƒl@¸6‰KfÂKœ¼Åmõ.È ½ Ú;¾Äéû-¿ÐùûÀ ,Áì"ÂØ)ìÃ^R ÄÂI’Ã2AŒ± óÆqoƒT2L"o°ÆÿÌ[Ê­üRËõ¬ŸÌ»Ñì‘Í.áü²ƒ<ëæsG@·$tÃ:çWtmGs”4KKgL´ÅÿE½ÑÔ+UMrÓø=M›Ö®M Ö ×±‰=Ù±’×k›-ŸÛ²Á£Ý¢ÿ½‘ÚÊÍÞ±é}‘à'Ñ8ßìÞšá!n’âÿIžšã¬Aîã,ú­à•s®æ«iN‘å$QN¦èå‘®šé¡>’êùÉšë©Á.‘í°®C´ãÇûg¸¦{DGŠBL0ü|ÃcV¼hÇC”ã üþîB hoÐóòEÙô¡UÿÐu'€?@¼ß÷p€»/ùÞÂt'@ùÔÄ:ò 4êÃÂRpï5 -x @|—@ €Ñß,Ђ ô\F@·º«9( yN |P‚ûË€Å× ®Ëƒ <ÈÙc>Ëð3(dˆ ÿYØÁB0†3Œ‰ ‹˜Ãñ‰#$¬ÅóCÌq!Ïq¡»&ÀÂ`Èö,°˜,±hbAv¸žV¦Š—¹¢B®³Bþ-üãâºøGC?=ñ"QÞ»GËÈ1!nÜÕ“H¾²2‡4Ò ÁôG‹z“ÜÎ#)Ƀ42#‹œÛ-Z„{-Dˆÿ,À|RBlj€÷JÙ‚ @ )4È+/R¨ ¨À —tIð@þ™² úƒaA*8/'»dŠ\FM d˜Ådá q‰}q„Þ W%R`à— fK¼(4ÊoÍ›`óøç®d žñc¢+3©ÿœ`Ôl5#HÄ|p›"øÝܕРt (¹,HŸ&@ „“&…r!̉Nu²„ׄà(°<ß…ñ¨ @*>Ó9ü, €ºl  ­_ ¶¹Í6€°€þ~ÑqÄŸ¨èEcR¨Ô´¦õèJXêEš¦™1ÜßKp‚ æÐ ÜçðT›âÔ~øg xJÄzpPcOŠ:>™ ¬JmˆËÊ×¾úõ¯€ ¬`»QÔ&T 1ÁwK B°h€N[`Pùí¤„Í¬f7ËÙÎzö³mÀ8_RU®¶T›m…`‡ê“€öµ°ý+ÐÅÔÑÿ.D|¨TUÒ0ʤµ,éEúØ‚€˜%+Lÿ£€²–§D[W°‚È&t)Pæ\»y0Ž  ·‡ šm2‚§JÀe»MÉ0ù‡R@ ²ýËê0!P¿¾°¬Ê­I4™BS0 BÐ]& ]ߟòo˜}Ô ]mS„à©­I¡0`A5¦%'Hn ž™\S– Œ)0mr;¸ X¬ùq¡>PÍñ²$Ã)±@2œ‚´2¹­$*w'Æ‘ ØTœ¹€r/<žý*e,^£‹Å³àôéáI(áÔàé Ô*M6òD¦\ä*KçÊUɲ—µä‡Y/DÐÚÙsPö¶»ýíaÿ€^ªn7‹d±Ê{¬P½û½U »B¿~T 8¼â?rÙ¼ëºá€e•š`©Žbºxy#yʯæYßÍÌât•tÞó£ÙëåE¯y¥í\)§G}hþWÓÐ×fô )}Jb/{Ì쵦«¿}ë©öú¤ð¾÷–¡ýSmŸy»ÓæøÈçËïŸüæ¿üù“>_*€@3" €ÿ„ïüÙ@_û|Aè3ü®)çG¿UÔÏþòË&þò§ ýÕ~•è%ø—R±¬g±€¨¸Bœ—} ¨ëÇØM±€äw}æH ¨CïwøJ‚Öwsµq‚(ˆ*(#èDø‚XxhƒLƒ±1ƒJVƒ<‚X€9x€;8„Iჭ„-&„JèL¸ý77%h.…A1…«á„ñ'‘…Zø\¨^?WXb8†=Q†©q†•†D±†l¸n8p†&A‡u˜w(y(‡CÁ‡}x……h‡‰ÿ¸„¸ˆ4шŸñˆ‘—„’蔈–Ø‚˜˜‰<±‰R…(¡‡%‰ ¢hˆ}©H«X­Ø¯8±è¤˜8‚(¨X‹,q‹|1‹:è‹[X„ ˜‹“³‹AыĘÀxˆ„ÍH†Æ¸,èŠÓ؆Õ(‚ÈX¦H̘%ñŒVø‰âäXæÈᘎ"±ŽTÑŽ«ñŽðò8ô¨öx‘ Ò©£Œ@Ñþè]Û¸‚ç‰iˆ )ƒ9;ùÙQ±©Q‘y 9Ù‘ñ‘O’¢1’$9&é(*¹’Ñ’Mñ’ “2ÿù4É6ù8™“ ±“KÑ“˜ñ“@¹B©DyFy” ‘”I±”–Ñ”NyPy!GxŽUù‹ùƒ)ß8T¹•q•G!••1–d)fihIj¹–mYoÉqI–sIuyw¹•y9{i}Y•)Yƒé”…‡I‰y”‹É!_a) ”‘ù9—™“™é›))“ŸÙ¡£¹’¥É§ ©I’«‰b×H‹k‰±©­ù¯Ù‘·™¹é»i) QœÆ)ã—‚]Ù„“ •ÁI%`ÜwœÖiðʉƒ³9ŒIÑ.B.Kÿ¸œTX ÙœÒ3‘ћФžñœ ±Ÿ>ÄžIž]hŸ!ŸAŸ»ÃŸ”†î¹\YyžJ) Ž„ŸQ 6ñ›M È£ æIܹ؈•:7ž iˆž¦I¡j¡8¢ü¢¬)¢Ý)ª_*jþéj=/ê¡GÑ¢¤Q££1£ë££Æ¡%º¢Z•@zj0¨Ÿfx¤Á£ß„¢²y ª¤oȤá¤ᣠq$j„DŠ FÊ¥šH¥xh¥¥¡¥)d¦Ìv£d ˆlÚhšj*DqÊrnÚ¡–ö¡ *¦Ú¨§Aʧa:tE£3¡LQ§Xt§4ÿ—¤€Š¤—ا„ ‹oŠˆŒJz ºŠ:G—ºqBê¥J›*¥™J†*ˆº›ŠHuŸzŒz¢’º¡Ž:¤¡ê£j Sú¨­&¨¹ »j«6ʃJ«y*¬{©ÅJª¯j·*˪«¥Ê’•ꈭJ‚Šè–×ê$Ó*§© {PŠ›"º÷t®}d®Ô•eDIÍʱº‘ã!€y¯„Fi…VFÉõAZÒ­3Y­•¸­Aè«?‘yUW5YÑaí¤OîZ« :¬´áÏw•Tøãd {D Ä^öA8ô¯ïª;*@èýàûŰ- ® ô[ýÿju°Á;±Éª@‹7´в5e б_h_6;²Œ‰Dµ–  tU¯ªÁpwPV/³GäRÕÕ´þ`[›¶¾âxȨP‚[G‹`+adõC¶8mn®úá.+$û• O"°  ®êJ²i·ùq ‡r¢³hF°O¸¸”±h¸©6©\¢¹¯f¬c⹶ƹW"º¼FºVbºÂ†ºQ¢ºöºbâºǬ–‹µD¹x"¹qv¹h¸·¼Ë&º«g¿;§Kê§E"»B»]‚¼ðƺP¼ç¼K½Kg¼·;¼Á;hÖ;$ÔK@Ûë#ÝÿËC¿¹¾k»Ü;¾¹[¾&ª$¸ëGêû¥Ï‹¾î[»ë{¼òK(ÙjØû¾´›¹ûK¿ÊÛ¹ÿë¿ßÛ#áÛF÷Kfü{²\À¥U)`$Ì‹ìɆ<ËQr`’ÕàE,´Dd?ôËúƒC^ŪnjÌK"³Ñ@%0ÊÐÜ"ÊÔ|CÕɺôÉÚì&ܬ«—"Þ¾€ò ñ/áÃ##fhx1`ÅŽ6Žœ2eƒ“/˵¬y`æÎj9ƒþ Z¬èΤKw=­9µê›¬/»~]36åÙ´gÚŽŒ;wÌÝŽ{û~ |±ðá-‹#>Ž|¥òÃÌ›§|N8ºô“Ô[¿^2;àíÜGzÿï >|ÈñzË›ÿˆ>¯úõÛÛ}£ü¹ôëg¼/7¿þ‹ü½å߸րNd Z&Ñ‚f5èà^nù&á„ A(Ö….¤aXv˜Ð‡]…(âA$6e≥xÓŠ,äâI„ÐŒ1&V!aLpcZ9’4£IpÅAŠ4dI=ŽP€ÀÀA8Ƹ$IM ÐfH& Ò•#eéc^‚)¦’;fæh~YP•,’)Ò›qª¹æ˜mÆ@#ü9 | çžÙ '*ú£":꤅0Á¥ȹ mJPœŽ0Áy [ŸŽm`$A”„f”ÿ¨44A­)€«“¡tkS’–¤A¬:B«¡É)”´ B¦ÉÊù+œ!è:P“#Hå7wþGé#·þY# àå­Å/ôËfÿý æÛþü{ÿxÀRh8íÎû:’@ß,# ÌÍáR@fh€Á© =„Aãhpƒ#êàr>B‰:$,a‹NXªPF,ÔŽ _¨#Îð…ÔHi“ÃŒìð5=¼Ë ÁUÄ‹üP5E´ÈK“ÄŠ,4MôËKʼn1—A\¯Å=<- ? “¿1@À½ ÀÀð|° ”ê $|JBj®9sÍlÆ™¯gê›°œÅ’§šiM°'¬.Ü0re4}2Á*$lH»ªÌ °¹"t+Ø@s¦†Ái¯ ¬Ù‰¶ À•&½"OHí4É%ÿª÷߀.øà„nxÓÀ7It†ç[ƒÊ'©}°çù~@ìŸËnžÀºJ)sL nú騣N€‰! ÷ÈUô)¡®Ú(š$|¸ëλÙw¬³ðZÎ3°ŒþñÝ;ð7äŒ ÐôÓ6..°ú˨I‚ äû=ლf÷Ÿ“ÿ©‰:°~e‹¯¼kÌë¤ÔÐ3–7õÅ^PyšÀ²fæ® h©]€á•EœÍå“Äxi°W ibk–ø)ª†Šì±b¿žEÀXEXLIFóŒ14eÏ=“Fð¬q3mìÎ1Gí̱2u¼Î%“Gêìñ1}ŒÎHç 21…\Î! “Hä,²0,Î#IáLò/•üÍ%ý’IÞlr/ÌÍ'ñJÛŒò.¥œÍ)ùÂÅ."d•sI%l` Y¶†–o±% ¿˜"]ž—ƒi¥+©5L ³˜‡á¥‰|I`ª…™¡q¦Y éi–…𛱦bމÌêu›˜Ñ&UÀYqþ„œ’1'd¸‰Luöq'OàɘœÊ•öìæCB@Q€ làŸ ¨@JЂô M¨BÊІ"ôà—>Â(à¢ͨF7ÊÑŽzô£ ©HGJÒ’‚”˜¨JWÊÒ–ºô¥0©LgJÓè;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Paraplex1.gif0000644000000000000000000000456610520670125021317 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìú40áଫ—"Þ¾€ò ñ/áÃ##fhx1`ÅŽ6Žœ2eƒ“/˵¬y`æÎj9ƒþ Z¬èΤKw=­9µê›¬/»~]36åÙ´gÚŽŒ;wÌÝŽ{û~ |±ðá-‹#>Ž|¥òÃÌ›§|N8ºô“Ô[¿^2;àíÜGzÿï >|ÈñzË›ÿˆ>¯úõÛÛ}£ü¹ôëg¼/7¿þ‹ü½å߸րNd Z&Ñ‚f5èà^nù&á„ A(Ö….¤aXv˜Ð‡]…(âA$6e≥xÓŠ,äâI„ÐŒ1&V!aLpcZ9’4£IpÅAŠ4dI=ŽP€ÀÀA8Ƹ$IM ÐfH& Ò•#eéc^‚)¦’;fæh~YP•,’)Ò›qª¹æ˜mÆ@#ü9 | çžÙ '*ú£":ê!L0ÁE’T¥d Q¥6¢$iIIhFe#)€ª°ÿúPž¢öé˜<`ê¨àcZÂBu g±žÂi¨@;P³r*P€@À*Àì±pv°l¶´bg«c«‘½þ¬ªªjíÒF¹Áªº5ÒZ;o½ìN 瓼jY€¡õ¨ôf­ %ÀÂãöê/89%»SëÀlÀk X»„`ì—ÒŽÌî«Q2°ÊÀ”\¨¯#Ì‹mwßôñÂ<÷ìóÏ@-ôÐD a’„&–jì¤O ¤€è+PÊ PÁóËõ«n• eÄÐÛñ´´«@žÝš4jI ôL@[I„&Ô5éd…RVÿPWT0u±p‚ÐA—Æޏ´Rÿý±ÆE¢ñÔ’€ñÍBæŒØ Ï-P¹é=¯Y—ª%Á” AÖ d=”­÷;ãƒJÉ®Ëän­´¹ìmgà¹gu‹T©Ó]:P–. ‚¥[n©‘›N°lö†núü!L?AõŒ¿Ô–vþtšfAÝvøöJñc8¿JõOxJù;¸?JýKÐÿN@ Ð$üÏK’@ý,$ ¬ÏGAøLP$\ÏC’Aól$ Ï?BîŒð,ÉCFNØ‘^‡…q¡t`—ª.í“ oHjD†ÍñaFÿ€ˆ!Þe‡<”ˆ/BÄá,Ñ"MôÍ+ÅÜLÑ/HL"D®8‘*Ò†‹ñâkÀ1ª†Œ…É¢‚Ƈ˜±4mtÈAÇ­q?9¼ïè¡<òf|‘ƒÈ@¢hÆ)¤![„Èå(r‘2j$t I gŽ©ã‘*©DIV‡’ÔäB0©Q*„”—1¥d@¹HU"•”q%•XiHYŠ“lô¤vhH[Ή—|ôå©€yGa$xÃeC&ကØ€4§IÍjZóšØÌ¦6·ÉÍnzó›àÜ&€9Õp  H§:×ÉÎvºóðŒ§<çIÏzÚóžòl”ÉÏ~úóŸ ¨@JPÄ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Fibonacci1.gif0000644000000000000000000000364510520670125021415 0ustar GIF89að÷ $$$000888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,ðÿEH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³fD rêÜɳ§ÏŸ@ƒ J´¨Ñ£B'Ø$IàÒ§P£JJÕç‚!–‚Ì`@«W’ ”~å˜s¬YeÏfL«¶­E¶n)ÂK×áܺïâÝkP/_…~ÿò ,¸/„ˆN¬ø0cÁ‹G~lv2bË”½b†ì83ÞÍA{¦)zoéÑ1O×UÚ%븯[¯ŒÝ–¶l”¶Ïæ¾]r÷Xß¼E×Ü9øïâ­‡G‹µòåd›~]#õš×«_Ì>“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzê/– ‚•¢:Rjž'êj¯rÿd£>n0¤•s†$fw±²T¨0Ù9ÐA^ùÁ Ô²Êvpl²d2+±ÐR+±¼Ò•@bAT RnЮVÒ*À¸ƒúHA¹ø˜Áž´ŽÛ®»åº»«L: dpëm¯ÙÈ/XžÙ. €À–ˆ æï© H¼å¡ Hp±ß›À*q0p¿Ý.ôm”ÄÊ[ðœWÞ[æ™t¸À•7zìð˜Ùü’#÷ìóÏ@-ôÐDó ܪÁc*,néœF>œpO?êªP‹°µÎ®œ’=#dÒb_$¬@€À  ÿè€ÂäÆ,A”ƒF°gyïÿ7Øñ¥}›­^L¤:ª¨RAÃ"е@ª:|¨d Aü¸îµž‹Àj¶q=àöÙ‡Ú à&5€ú¿ª¯jì#åûë´û‡;q¹·¸»V¶'÷ûRÁ;7¼MÅOwúñ€Üc­Ûp`H¤"ÉÈF:ò‘Œ¤$'IÉJZò’’L€ÖÈÉNzò“  ¥(GIJ¯;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Substitute1.gif0000644000000000000000000000416310520670125021707 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xîB!P0 QàlCò¶b¯mÐå®0} 'D+BÑÒi' q"”ðMé‚4ÕfðÀ¾­›Ð§LRP„Š@ç£!p)PÈ„ ooŒ©@;ª2¦šÂÔðG P­` ñ¾+ @³Ób:( Ÿº¬flð§šÀî9ëœ8=ô§bîitÀ2ß»QÛ\™Që ðûëúÑ ž“a[ÿᇫ˜åL² À,{SÄa3WfÀÔ7_¬³CÙ*,eÐÖ:¨­%¦cÚ«Ñ¢Á¼“XSM3A‰Æm÷Ýxç­÷Þ|÷ÿ=uÌÍÒ£üéÀ§Ž†=ôØi¤ê $ îè¾35à÷å˜gž9$†@Ü3oÝУLmâ£[*ã§>N§älÓuG ؽ€¦… 0uÕ6 ¾Ò¨#~,z®N§šïÖÉæª°7̯Û:i€õíÁÍ{ƾ«D³íÂ+P–L°Á¼L¶ë4 .“ïýÏ/—ÁÒ¸'VŠ¢›T€ÈAgÐçô@ü¤©_INwmµ¯Wàrf÷ "‡ r`q x ‡‚²ào0 ò†ƒþñ`n@¸Ú†„ø1álPX†…òqak`øª††ì±áip˜’†‡æñahÿ€8!z†ˆà1âfØ%b†‰Úqbe x)J†ŠÔ±âc°-2†‹ÎñbbÀ¸1†ŒÈ1caÐX5 †Âqã_àø9ú…޼±ã^ð˜=â…¶ñã]9Aò¥\ˆ!çBHØ,.lÍ#ßIÕLr0ˆLdB.©–Jž†“fñd³Ç"Q†”e1¥gP©˜Lj²M¤L‘*7ÃJªÌ3µüÉ-+“Kȸò•¦¯~)Lìs—’éeOùeò„™Œ‰å(Íb>$¸À¶ÉÍnzó›à §8ÇIÎršóœèL'9/@ŒY“!`€æIÏzÚóžøÌ§>÷É Ï~úóŸ (?Àwô M¨BÊІ:ô¡N@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Delta21.gif0000644000000000000000000000445110520670125020647 0ustar GIF89a=÷ $$$(((000888<<<@@@PPPYYYaaaiiiqqquuuyyy}}}………‰‰‰•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,=ÿOH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O"&HJ´¨Ñ£H“*]Ê´©Ó§P£2Íð³êÉ"HÝʵ«×¯`‘.``µ¬È̪uhÄÚ· ˆ€K× ‚uóF”«7ïÝ›6œP À‡ @8± p߇|Ãý[3€ ƒ ŸHÀ ! Ü02iµ”Q†X À®[h €…„OXưyÁ‰Ü§šn5µÉLà¼9À&X€W`î>4ÿ=š8ÂáÞ}ÿ/ ¼Cvæ' cÇŒ{4ví̇/~þÎñ$¿G¯þræØá_wö T_8á7’y·50Zb%x6e”ÐÞs l`w8W‡÷U‡a… ¦abV{ž€AaεØá Ò¤ Mò0Â… ÒX£L7Ö$f5F ‚>þS4•p˜A!<Ùã‡JÚÄäM$ìX¥@InÉÒ•7ð€–Jvé¥J`ÚäŒY&•gÆ”fMžÀ¦›SÆ9“(à矀*è „jè¡Ø©h›dÚg¦ž&!PA”Vj饘fªé¦œvJ¢vÖŒpBÚÒœ4U ¨¨?>jêH¨ÎÿĬ¾ùêK±Æd£Véê­ å “ qþ ¬G›’±Ên”l³&1 -FÏN;’´ÖVTm¶ aË­DÛ~Û‘·â>n¹‘‹.Cç®{‘ºî&Ôn¼ÁK¯]"Þ‹’½ú4o¿• 0EÿÌ¿l°p/ ‘„p¿GL_ó›oÆãḇ¼œ®Ç"ã[rÇ'7TñÇë»r¹Úœ²Æ3#ôžÌ5ƒœóA1;Ôò½/ûaC‹¦XB?Ó4·ïa×@ !MrÍKgÛtv2”t¼U[{µv9^¼3B]OûuÖbm²Ú…@n‡p‚¾}7õKD×AÏMÿP…`AÈ7•ínĦSµ@ŒAwtb•'H8Û90@‰sy·K‰ „ºõ roë(%k'l€µN†¯ËŸ'¾õF¥ Äœƒ‰É tÓi˜Ø‘§ËMûæœ4¨¹ï®Qï›`™` ø&9æÞvzÌC×½<‚æjþù觯þúì·ÀŒÞõœy–k£mïÜj˜c=tæškžBH`¾»H/#½Z̃—ìHÛ1ÏB€9À…H€ ÁŽ(s@Œ0Ž3lŽh#¹Ä4 1ËÉÎG¤œÔ]Ò1N/’·èðF #°¡uð² X ‡Èaÿ¢CD ƒq@Èfø­ö‹‰Ür¢¾ ˜-)Þ‹ŠÖ²"½°8--Æ‹‹Ðò¢»ÀØ,1®‹ŒÊ2#ºÐx,5–‹Àr£¸àx+9~‹Ž¯²#·ðh*=f‹ò£µ©'AN‹q2$´y&E6‹‘^rdA¸(’¤B¢!WCìHŽ1Îê É-’zÂZV¹O’R~%³¢‘34°ÆNºYkГ9 –"“bcÓ[V¯g7³/]ùKM2O$ŸäÌÍrƒÊ›ù®•¾œO)«$Å£5çf¢©^'g·çd3<ÛT’„é€rLŠbÍrö2“´"å:#ÿÊ)Ç7¸=É ›0S›Àü˜$Š# dhçôN:´Ð‡®h’ERB9VÑ[M´F}ÕGAR@$ðÒH;TR(@(õÕF3ÖÒߨ ¦)­ÑJTS € §y ãÜGÔ¢µ¨Èé+Y– €ŠÐéL-VS Ø ª¶Êç3qr¬Ê”©UATU:ÕˆÕ´XeuØYÏ´Ó­•¬`EbiÒº°·n©­ö±ëWµ*WŸÑÕ`zͪÛª¿Œ°Rk_¦ØÅ"@"d»  S˜Í¬f7ËÙÎzö³™µ€(Ë ê´¨M­jWËÚÖºµ 0,igKÛÚÚö¶¸Í­nwËÛÞŠ$ ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Plex1.gif0000644000000000000000000000441610520670125020445 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìú40áàíÓfÔµÛ=‘>Pk<«85\U|G!l¿€ŠµÓò!©/Pk—ÀÔ x ÃÉšt? ñ$yÓœ@ò& <ï0¦9\ü6g– ¶œ¼æÇ‘à/„€WSh.À‘ÐXlÕ CUÍW5<Õ yr¾ý‰^;܉þÿp’CRqVE Õa•DO-±UMÜÔUEKMñTUœÔI•ÅEm1T]DÔgÒC"þ°]c”ÉoÆ@¥ÑRmôÓáâŸdj”SÈj;…&˜#[H0 ¤2~,ˆ¬ÖÍx(RgT— ×b6˜í•‰ÏP£š’`jÿŠ$Èzª8µAÇ^&ßsùGNò,¨, YéçÓ\o¦Ó·ÝÒ,¹ì ûÎàQEÃe-SxÌ«$s—<ë4£IË8ž©šV©c±ÉÌÒù‘›~ôf”ÀižADšêT;뢽<2¤CéŒä½L™ó+ìÍ!)’‘>÷ÅORÆóHó¼ÌtP %”BjÀÚ£‡.èxC’è(iQ•`{¥è:J!ï¤(M)JP&R’?m’ ‘Òè¥ëÁèL‡eÓá=Ø)8ZКUàuF"*)ÒSý…J]jà\ZT6•DOuà@VÕ^5DY]ÐW/Våm•b]ÜX)TÖý¬uAmÅÏ[×õÌu?uEÏ:@J0Nª ±ÀìDØÂö°ˆM¬bë& R€UHÀDÙÊZö²˜Í¬f7‹%$2²  ­hGKÚÒšö´¨M­jÙ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Sign1.gif0000644000000000000000000000423610520670125020435 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚x®Bd9- 8ÑÔ®C¼ëÚŠ½"´A—»¾tlAwB”@½}ê·1¥ ÒT›iÀ ´.B@@‚ °Ù¡!й$¦˜j*а–L²¦\~0í’\À²û–ÅÕ &¼ñAC°A¥£Æ©æ˜b> @Â6BÊ2Á„àðjÊy&Õ°&àqÎUa‘o$p/ØkAcuª890K»±© ,K‚LºLç‘<Í{†©Š‚çbÙ8KHôeO-°cÁVIJ§“ 04,lHÛÿu*„Ø0êŸA p°ò°_ ârHH!)"‡Š²bq°¨ - ‡‹òâoÀH 1ò†Œ2cnÐè5Ú†ûqãlàˆ9†Žõ±ckð(=ª†ïñãiÉA’†é1dhiEz†‘ãqäf Ib†’ݱde0©MJ†“×ñäc@IQ2†”Ñ1ebPéU†•Ëqea`‰Y †–űå_p)]ú…—¿ñå^€Éaâ…˜¹1æ]ieòå‰PÌYÄÌÙ8s.Õ„Í5á’ÍÖló-ÝTÍ7Íh"dœj çiÐiu’†eq'§™"yzžŠ)§9©µƒOØs3ø¤Ê?1П ´2…Œ>ûyzšè ’IhO ú‰ò„¢Œ‰@¡¨Q†>$¸ÀFJÒ’šô¤(M©JWÊÒ–ºô¥0)K/@€Œy”!`€vÊÓžúô§@ ªP‡JÔ¢õ¨HM*QÀ›:õ©PªT§JÕªZõªXN@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Fibonacci2.gif0000644000000000000000000001244610520670125021415 0ustar GIF89aD<÷  $$$(((000888<<<@@@DDDHHHLLLPPPYYY]]]aaaeeeiiimmmqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,D<ÿ[H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£J*D†«X³jÝʵ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊKW® š ÔÝË·¯ß¿€ L¸°aº(È$‘€ªãÇ#KFH EÌ«“3kÞÌyè‚—3tMº´i•ŸCŸ^ͺµëˆ©ab~M»¶íÓ±_ξͻ·ï©¹]îþM¼¸q¡Á[?μ¹ó˜ÉY.N½ºuÑWN¿Î½»÷‡ÙUnÿÿN¾<ùð)Ç›_ÏÞ9z”êÛËŸÏûýÉøôóëÇ Z¶èýÈŸjh`fö™„ß 6ˆT‚%-èà„ú!IV¨á†4]8R††("jýéö߈(¦Ø’‡"¨â‹0^ÄbH.Æhã ÍR8öèã@:~ÄãDÚ¤GC©dŠGv”ä’PrØ$GOFiå„SnTå•\˜¥F[v)æ~_fæ˜hÊW&Fg¦éfyk^Ôæ›tr§EsÖ©çswV”瞀×'EjhoƒNTèA(`°À£F*餔Vj饘fªé¦œvŠ)*L¨‚ž–jꩨ¦ª*¥XFR¢-ÿZP h0­¸æªë®¼öêë¯À+ì°Ä ,8ÈÂëì³ÐF+í´¼bp@¨#Á‘¬Y°Aƒ ˆÐ Š1H¯–(܉!ikœ4È­qó äîCõ¶p/qðÊËnùîÛPÀêØ/ƒùþF0" ìÛÁ&ìÛÂþ¥Û ÄJÜÅ&ZÌ Æÿ+ Çëz| È#‹ Éʩܑý¡¼²Ëû±,ÍÁÌ›ÌjÌ›ÍÚᬑηñ\³Ðô-Òm›Ñúù|›Òé1-cÁBŸÔ¶Q ŸÕ9]›ÖIƒÍž×÷™M‘Ø´‘=×µ¡­ Ú±ýšÛòÁM›ÜÒÿ-‘Ý®áÝžÞ¯ñ¡ß°a àg#þá:žâ2¾á®AÞ¢äÞšåæaÞšæ4rž#åû^žè¬‘.Ð!Pi:Cž³¦:y¬¯æú h »ÉÞþøìÖÙ| H Ê·ð`º`¯Pí« ï]î§±œ‚h €-Œ/hÀ¨Çj}BØŸ¦}wܛƲ¼@ æ·€~ ½û]¶Ú—Ÿùq§~¥¹_þZ@þ‘Ï ï´ô>„ÄÏ4¼Iò]ÈŸ °ôŽwXg°x!¬‚αþ `€Ø…€†!ô 'h&ä‚¥É`ñÿ|È× ‰ˆ"i„X ŽÆˆHB"H&Rlj¢“¤h/*ždéA \µ0ò!'ð€@< ÆÀÎ&V|F p`ŒáõÂF2æD‹l˜M@Ò0v yøð·¨q„ ß H“8úf(0ÈRHC¶± æó% ò=Cž`'€4ÈÅE} ²$lÁ "ÉÀ”@ '¸e N0¾¤à–%8e-2‚üy0 újbÉÞÈä@6ÉÀ®`„ù¥«Ì7B]–ø[Á,Ïx“Tp!D̹‘XÎRßÕÔw%eLÕ¶ºõ­p«\çJ׺Úõ®xÍ+OÐJ‹4´Òó*/É·T²u‚ÝäIôÊØÆæµÒTG3ÒPNîÏ¡ Á£ùªH ²¬-ð|i5r@­01(oÕtþt‚!üÞLÙÒòÿå)§muÉT^mU(C&‹‘ÊjU ãËçL7{[Œ@‘d\éù )›ÊDµ·9ÀG]øÓH €!Ì'aÉwõ™ðѳ#E—©⊀§Â¥ªo[Fu5›ék£ÝhVt¥@Ÿe6/pa*`¦•Ìé|€;Õ…öµ"uLŸ0[À; d¿'H…mÅx }aìí9bhFÖ!ÄÍÉE ÂOf*X>x153C\ œ_U¥Ê‡ 'Ø_@qÅ„|²Ï,È‚dX»œºìgÆ“I1+ç[9#÷ìÁËqLj<+ ÉKV2v˜l'Ê’‘²¢´Üe0‡ŒÿÊUƒ³~̬0,ÿŒÍ-“s½5;O Ï7Ósù¼5?w ÐAô|è<1CÇ ÑKS´|e7{jf¥ïli`Ò©#tÙ:ý22QÒíÙôŸIÍ‘O£š=ª>4«sfê(¾ºÉ¢~›£÷ê¯ÝºÌ¹ÎÛ® ×ë´ýº<±~ô¬‡Vë-›<Éæõ²3âj.·pÚº~¶³­µ`nØ™+öÜ´íhÛWó¥›]no7Ýac÷ ¹½8w_Ü£wßÈÝs‡Þ©v’?fïÐá»uú>¿¹ãï||mò®Þ¯Óp„?¼nïáÄ­SqÝÜã—SÂS]ðÕ}¼{#ÿßI °J±¼A°@ƒ0@Îu«Û##8€¨ÅóžûüçÆúXР@OºÒ—Îs@6äxêë°ªª«*°ºÖOÞ2ˆغØ;€±›=Sì+‰Àmƒ‚Š6ðÍÚkÓö·¿&îˆÊ8›NÞ“ºÛ½5x¯ÞEÞ¿ÿ}5¿ÍÜicøÃ›&ñ¶YükïxÒ@¾6’w å+ß™ËÓ&ó­Ù<ç7ãù×€ž5¢}fJïšÓ¯&õª— ë[ãúÓÀ>ö™=kjošÛãÞ1º_ ïKãûßO%øòmŠoü¨ ß4Ã' ó›ÿ”ç—&ú£™>õ›b}Ò`¿3ÚßþÿRº?šïs&üâO ù;cþÍ ?ýGY?gÚ¯™÷ÿ(òß ý3cÿû%ÿš±“Ñþˆ ƒu…çvx|r—€~Âwøƒ0„ÀSÆEh„.„R1„RÑ„NÈPRTX…*q…P‘…P±…\ˆ^ø`øb8†&Q†Nq†N‘†jHlØnØp‡"1‡LQ‡Lq‡xz¸|¸~ø‡ˆJ1ˆJQˆ†Èˆÿ˜Š˜ŒØˆñˆ¢„k¶€”–x‘ˆ“¸‰щFñ‰GŠ¢X¤X¦h¨˜Š±ŠDÑŠEñа²è˜è>šx‹$ø€7§y è‹+ŒÊÇvÃHŒ2hŒ[¶|ɨŒ9ÈŒ%ÄÏ@(yFÖ¸ŒyŒ¡WÛø¹ˆ»¸-¸¶Ž1ŽAA‹D‘Žêhìî8ð1?QBqø(úh!åR½øOˆ¦yÝxŒtŽ yÙüþøÉ ‰¹ù©!é#©Ž%™'Ùw‘%±’8Ñ’ø’0ù ÿ@Y y‰cy“$@e —…y?‰bç¨) ÐV,å“Þˆz6)”@Qåu¦·”ò¥XYQiOSI•ÉxW–íÄS\Ù•Uùzi©–•ei–͈Œr KI©x^9\}•ppQ ˜pÑD§,`˜oáŒé ¢v}¹ùbtð˜m1˜ÉÐ ²,°™¢ip‰9pw Þ.â Ð<r.P³é‡r÷7“)Y)‡k¹‰;½¹#Á‰l%œ¿ |¨D£q›öÓ”Y4œ¶FoUvœÛÛ†šmöBÔÙ9»™™vÌ™@ÎÿÉßIÒjÛy@ÖHaFpé©Aë9oØymÚYŸó™÷Yoï9Dµ™‰ç9gÅ9<ûy=݉åYáÉAã¹Ê”ý©iZ ?z ú úD ªê— žJ?Jcñ)qÿ¹g*G%ªq':h)C+ºwú.!ªž/úCªI1Zúœ7ZÉ™£wS£ðù£I$¤Ñ¡1C¤üiŸí™š6çžNúf-ºoU:iLÚD#e;ª€WJrFJ/]J›_ kYzE[šfcº„ù9Sš23 ”eê›ozds*œqÊ/gª¢aÚEoImHú9{ £}êJÚ4Ju$F~ÿ”f´i4 Boäb…š#>ß„÷uJÊ›yútH ¡HáƒZ ¤_—5Ip4¨ÍfêcQÊ@ЖBñ©Þ¹¦áN´T¶„Kº4X¾LÂä«ÄdT¥Kì…S—ŠêsK4Aßä*·dK´õK¶úGºÊ‹w¼:Q4´Oô4–§*Pú[áO ôb¥Ke©ujÏJ«­bQ¹´?±jÅI³ºQÛjŽ¡ê$õ]'@)å<,Å\ÈE°q`Ñ@Õ…ª.ѣ䙦ê3>ázTIÕ@ê3`TC)à±>«ú¯qU!±\åUµPbEVeYÞ$±-Áÿpv8›³:Ë)0=¡>>®bX½Ã± ÄKÕ¯åd²rÚ¦+a\›L d ë<ßõY1{\F³,Àt`¶b ,`±{ISü4NF‹K'p§Usþ°”É´µI™\°\`Õ±Ð5Ò%³ ¯c¶^w^éµ¶4fR#K·_é´*Q_Š:©ø¥ú….™JSþ`!`Ñ©ûcñZ™ªBQa#ÐaG•¹k”>X+bklÝ*+V-&ºƒ[¨Aê;V=ÖªÍZi³{Oš¹;º´v¨é&¥Çۼś±ë¢È[hr ªÃÛnÁËi×+ŸÏÛmÙ»jÛÿk¢Ñ»h®ZDi$k¡Žû0å{h†¾ë;·Õ[4í+¦º›¨-¾mS¿Ov¾¡¿Àÿgæ¿!ÀÓ¿;CÀuv¿ÊoÃÀæÀgéiø+?,¼Î;fpŒA¬½¥PjÁü½²¾,:¾XŠÂʦÂ2 Ã<Âà;Â&\Á¥vÂÓ;j2ì¥, ¦;œm=L¦?l¦.,mC̦ݫŸA,ló[²O<64œÂ6œÃ8ÜjDSüÂUŒÅ q:ÜÅ}Å:JÆCzÄç–ÄþYÄt*ÆÔ«ÆÜÊÆÀ†ÆÿÇkÇ4JLJÇM»ÄnêÆ<,ǧÆÇzªÇGÈ/ÿçr-w €3·V\ p" ´û‘ “B­^|ÅÑÚåXª¼Ê¬ÜÊ®ÜV Ŧaɯ\˶|˸lO Гfœ¤œ—‡G“ÀL}Â<ÌÆWÌÆŒ{Ȝ̪·ÌÌÌyÎüÌŽÍÒüwÔ\ÍowÍØl(ڼ̀ÒÍÞ¬'àÎt2Îäì&æ|Îh’Îê,&ìÜÎ\òÎðLieQ%ÀHë­µ Á¦<Ï/‚²é³™Û?!Ñ©`ÜÏþœ"ÆÅ ›<¡{<ɳ<0PÍ#>Ý!0>Í“ÑÍK†q_œÐBRMT½£>õ>ÜÔ;åÅŤG&õ= Jÿ Ó4 ±Ò"M!$­e]ÝÔ ÐPÍ!ÆETúšV_ûA-BµAá­ÄßÃ>4×8íÔÓ8Ö1’Vg„ÏÞõ@3TC[VÅ>›O‘tJˆ­¹´Ï9-ÖzýƒòÙ82Ù”m$øû¾—]$–½Ù/ÒÙžÍ$™ýË¡}# ]Ú"rÚ¨-%£½Ú\ˆ=®]…@Ê(Áµ2¶º½Û¼ÝÛ¾ýÛÀÜÂ=ÜÄM,à™1Ñ(;»ÜÌÝÜÎýÜÐÝÒ=ÝÔ]ÝZ§Ø2ÛÚ½ÝÜÝÝÞ ýÝàÞâ=Þ7;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Prefix1.gif0000644000000000000000000000415110520670125020766 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xnCdÙ¦ }0ô.”Á²ŠÚн"´A—»Î4ÁžjpBj:`§BÀLÐú”.HSm¦A8¼.CÓ™è"pI軡AÈtrIBðB©@¨LBœ¢ñ»T+˜` ðÆ uŒ©”«é¨œgî9Á¨Š@+©«¦‘â»oY@Ε uÏ­ÐÀª)/ˆ@A"ˆP€³fŽúÁŸL;PËNš ŸvÿÉçÕUyðõÖ:”èàˆ'®øâŒ7îøãZp@á( A–]~*žv®y)­‚¦5Ъšc:¨£»Ô䬷îºëxƒç,vBBT:°.ù9¤n«y0°t®Ýå¤ÓþÓÄ€øð 6€Ö\ÛHùI¹ TúÜ»wÜ;÷Ë‘:{f¼ßYÕ31ï‘_Cÿ˜àÕG}½IíV*P»µ;¾ÿ#½DÀvÙÍF¢#à¼JV³²Dò“LPt»”lV€èÚg3< z¤©`J `µ‡9lyìCD¸÷Qˆ…Èqáƒ`X*ˆ†Â±ápøˆ‡¼ña€ÿ€˜!ú‡ˆ¶1â~8%⇉°qb} Ø)Ê‡Šª±â{°x-²‡‹¤ñbzÀ1š‡Œž1ãxи5‚‡˜qcwàX9j‡Ž’±ãuðø=R‡Œñct™A:‡†1ärYE"‡‘‚qdq ùI ‡’~±äo0¹Mò†“xñdn@yQÚ†”|I¡ s?™r6¨œË+aK¸Ì²5µ|Ë-U“ËÁ¨r•é¥Zvyaš…˜!leŠc–…™žq¦b~ LjUS ÐÜŒ4©’MÌló'ݬÌ7!CÍkF™& §dÆÙu>†ÎDb-9š†FéR’7} å@Q^¹•6)°À“Gf©¥jy]e|&]cÊX¦UÀ¡™&˜E²Ù¦L Àž|öé矀*è „" §œ XYç31F*餔Vj饘fšÁ¡ð&†v2ú—5u §§<Š)êH¤þØé§P†ÿº*K­Î¤¬1ª:+HµîÊ’®¾vÔk°)K¬FÃk’±Ê^”l³#1 -EÏN ’´ÖFTm¶aË­C­ÞøíGÞŽ»©(`®G宋©#Ðé®\²Î‹Ñ¶öRÔn¾áËoDûþëï¿ÌïÀGVoÂÚâÊ0» ? ®Ãodp¾W|ÐÅö’êÁóqÈ Á+/ÉÃŒò]¯¬¯Ê.÷ÛrÌ'+Äñ¼¯›cÊ13”³Î"÷|îÌ+{p˜ÑÆB7»ûó¸Ö× %ò,tÉD£up5rsσüðÖ£uß×1›,1Ù¥¸1Ú.?ý-€@·k°Y½æ]ÿPs„ã™@[rÿ›AUg÷¤a†AXPy&@€jY_=PP€¸@M{ähFŸ˜å…X· "0ùSáüÆ™9âwô¹@I›°œb®å‡æ*æ6O¬ç[¡¯ÇÎÑ쉀&,äêy0]hoX¹^pªýöÜwïý÷àk?Àp¿„|a±¦~ƒ©B‰†V_SðùršÆo4; Љ÷ÛÐà v²'?79äcBû€œîǹò¹H›1Ì4Æ@N1 (Ñâ÷ëÅKha –ؾ™§âÌ.8h`(4`GŸëYN#Hþ¸E¿‡í0[=dØÿ­Ä„ qZE$Ø¡•Ä-±YMäו6ËyÍŠQG¸Å‚D1_S<ÖíFbq^e ÖÝ•F_­q]mÜÕÍÇYÍq\u\U»8 †L‹]Ì£¨îø-A2j‚ÉŒ‚€Á8¦€“1äÖÈP À`@C$PñQf ynóšͦ6¤l›@04òqlQ'_äGÉ-D¬ÄŽ~ õ?¸À@Ãñ@Ž=±ú¤ll‘óp—ø™ŠÈÃëTÀ<ƒcŸ,! I¶Inç±4+©JmZ§DB:æÎŠãÍ1É-{ÓYNÛ”žÓMÓœ³Ô&2 ÔÿN-Î1`^ˆ.㛨œ3ÚÉÔ™ÏíôóJ„¼'DÖ)œ‡J)¢É[$C ÓPvÖ²buDDšLebÔZ=ÒI2qI)¥*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡ÚìÑDÂøB4ÁÇêå*s¦!Ï.ÓæºE›…:wdÀgM çÁÉÎ9G›l$@½Î1P€ÑÝUÍ‘¸\0Û_á ©a]o¸ûD¶GHÿx¶|jod® ÿLÂ_ç ïo}E¸­N{wôÁŒ§¸FÀýÕX` Ôx`þ–':OÍhú騧®úꬷ@¦´LÙM ¡þŠöç&„nfˆë¶N!˜¾€ÓÒ]žº›W`¯Æ¼‡îÚfy÷9Gtxü{Êc4´@ mBCW á&pÐùê=öð9Eðòàu¿æõ=@¿å³ëŠÿ£ö3ÓÿÀ1 0QÜÒ •@,-pP ŒÒA'M°O¼Ñõ”ÁmðNÔÐé 0N%|Ð Ý”B­pM-,Ð ÍCÍpL5ôÏ ·”ÃýìP:ÚAÿ˜VªþÝê‡ÈÛ@R.ÌèhAbq¶v‹‰Àyûë!~¤¨›ìü.\}ÓöD(¢ª`^D€\C›åpÇŒQ„ß©¼œç àÎFcâBa%HB’†eãQLÊ@à²Ô(2Gs䃴XM2ˆ“òñd@ùQ¦‡M"%{L Û5`AªL+»39 ½2”#K`ºWÆ<³”H„\GÌb³˜¨‘ ©Ë£ñ²Cx€~Ù`J§–Ñä5«cMäL ›Ù¦tºYœ p-œF¤9Ù#N䬓Ë*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(͡ڼÓö\Ϻáì©Îùká.àoйò„Doä°ÅæÜÉÐ&AYŸ¬^Ó;1PØÕE­‘ÃKû‹@ÒA™¸€ðÜ|mVŽ-ŸÙ¡ÿ¯¿TÛÛÔÍ—¶"h ÷NB{ôÁŒz§Ç7F~›°4Á*PòÚã…‹ÀÇ»Í(ú褗nú騧ž7€ÝM~Qå—oÜ[„ z  ¶ƒë›Nw‚è ÐVvÈ2Á/æÊ!DØ€¿˜1NvNtü{®[D ôö &f‚Ó^ ÏÀ,½Y|&¼äÄWÛ;G¼Ï^öfÎ/)þcêÿ(ÿ[ò£ˆ%&Š€Q2 ¡è$Š7r   " ö‰‚² ž0x! Þ‰ƒò @È Ɖ„2¡›P( ®‰…þq¡™`¸މ†ø±au<€/„,!8¬ÿ¥ƒ®‚¤,\ÑãŽÌî2½SÙî A¶«%Šª‰¤ÊŽàe€¾€@n 2Däh"p m–£Ä1’‹¡Òbpž³6ûYËo,˜˜:–*~º*cqö8‰ ?$Hå#Hݰl<ŠI\–DŠqŒ Ñ"ß“I m’=¼Ð'ÓJùP I£O)ß34`A©ìÎ*Ùó8 ½òŽxœezJ ºWƲ:º¤H„TGÌb³˜¨ó¸Lƒð²Cx€~)`v§–Ñô5‘cÍêL ›Šä­º) x-œÍ$çÞÄI+ub±rçýàù*yÂ/pl¦Áð©nφl³8öÏ?™ÖÏOÑSUmÝAO•Ðáñ³  èm*‰ž†¢È9@šÉ€§A4!8€‘FJÒ’šô¤(M©J}„€é£©ŒfJÓšÚô¦8Í©NQÄ;Âô§@ ªP‡JÔ¢õ¨HMjK;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/And1.gif0000644000000000000000000000325710520670125020241 0ustar GIF89ašK÷ $$$(((000888<<<@@@DDDHHHPPPYYY]]]aaaeeeiiiqqquuuyyy}}}………•••¡¡¡®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,šKÿWH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœIÓaŠ Cl8Q³§ÈVˆAOŸH;–X±tÄÒvšÑD„²jÝʵ«×¯`½&‘t„¨2ø`V`ÛŒ 2¨ )¢ÀÑžm ¤X±!ÃÛ·O ði!Ò¼nýž]Ø¢‰>/\8|6*ã '‡ zñqäÉ>_^á`ƒY²UÌ-è¹§d¤7W^‘õ†$ª8 aµÀÖ5_'õÀ€Þ¿!»=œã­ÇU§)©ÉسkßÎ]ò®.ÿø<üz÷óè/|ß~üòæŸg>}fuø‹GONÆÝÈ TŸL÷ùW‘j Sn¤ L ŽTAM¾¡HP¨\pÌiÔ5B†¤œÅT¡KR”™@8ð–#¦arfÀŒ5’8ÓŠ-µ8Q>î¸6Ò$KBJtÂŽ+ U‚^OÖ¨À^?nH]‡éU8ÖRø¨¢–j …0DM6HÑ’B°ØBjI'D$ȹ ¨•P #ÜåTžíù °‰ …À( ¤€ @Ö¦Z'—‰U¤þQ:Q¨)•dÿðY¬êIªE*l…jsª®ð¤‡“‹ÅÊ(£IPÀÌ6ëì³ÐF»VºJÚS¯Ï»éYÄ d¬<¹Q„`î¹è¦«îº!°• 0\¯ÝÂHh½±þZA§¶r„‚VðÊË+š ¥°æ@ë„“ld• ëo>ä¨C pª/xkEÄÛ`¯&MÜo‚\’È~6d2I(ŸTB<…ÑÊ#µlRlaZcUC¸1L±uàæÂ1"É3Ž5åY8íeôÌ=[øóK¢uðæÓEÍâÔ.‰6ÂÕ;C4M^ƒ­Í"Ù\RÙaí a ¨u\»ÔÂÉQ2”„vHj§¼YõýçÜLÖ-8Bl%ãß ~²´”WÎ,]1à‡ó²ëùçæbÀ• ¾’ä~j Uß„ºœ `øác/Þ ÄMû{¶‹Í{®Òë½·îñ¶£0É2M°0ðM@:èÔWo½¹À<ôºqЀåà‡/>³ÜÅýù觯þúì·ïþûðÇ/Q@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Or1.gif0000644000000000000000000000410110520670125020104 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú|ÒÓž¬Ξê\RcápÁϹò„Bg €i  ˆ@›Y@{Ä@Iw×´Hâô×´„ËVÖe !×ò}’Üp€ïZhsôÁŒl§ÿç6Ha 4¶¿q56ãáˆ'®øâŒ7î8èuÈ:Áû˜Æ^Z×:…pøWK÷÷G‰ÛfšŸÍyNtú{£ƒTA|œy\yoÁg¡ƒ»™¹kô@ï~S^mðŒþ>&ò‰*¿%ó†:%ôƒJ%õ€Zï$ö}j#÷zz"øwН!ùtš!úqªÿ ûnºÏ ükÊ_ ýfÚ/ þcêïÿ[òß~ˆ%⇀ÈñÀÝ…°>,º ’²pa&@2ÕêNUµƒ\Lج2¨Á‚eÇð2@_@ÐÀ…a„¨2apÄ%×Ðf9Üá@"¨›ç98Ï ÿIÈÃÛø` "ñ¬¥Ã¨mTGœÆL×À6±ˆ§aÙx“2¸,5¨âuˆÅ =P>e|Ðß“F­‘=mdšôÆôÄ1=tkÀ‚êž;‚goÒ#¯øÄ –àpzäcwü8‘=$$P£&:Ñ’9d‡ð(²:Œ¬ 9é³OJ'”Ò™) bJä 9ð+§«WÂŽ–·²%{ZY]“¾ô.iÌɳ˜4Ø1“Ù^ꦘÕqæm )ºaÆŠšÈ‘æi°Ym’†›ºñfeÀy›t“ X3béðŒ§<çIÏzÚÓG˜Ö©& ÀèŸ ¨@JЂE X"?ÊІ:ô¡¨D'JÑŠ®% ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Plex2.gif0000644000000000000000000000423610520670125020446 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡ÚÜÓzð àË|ÜΞêÌÑ„®Ï)¤Ó¾©—+Oø§ôFLáÀÛy‚pc;G‚Ë&h°ÝNH{Ä@Ww·µF];Ül 8€ÿïÉÕ[6Ûq딄pË7wFL§®lŽ¡áØÀy`@_GžÓ3&žÞâ1 Á´'Ï._(¦vÕšWÍSc3Önûí¸ç®ûî¼P€r‡,SÝ™ìÛc Êâ ݹY!Ô¾mÕ‘~ñÚyP½‹À4ÝŸ.õ9µÝÑNÿžõñì¼ @ã{ê&L ˜÷L«ÿûå{ŽSŸ!xØg&óqäðªe@IpL |Ô·AFMKLÔ£”ACmÐIÔoB@0D%ìÓ 5”B=­ðB-¼Ó C:ÍA5ŒÓ ”C7íP@=\ÓÿýD3 q?EÓñ“Äêx€\€d&*ÿ‘ ]IY¸03E* ¤‰Òñà Ò½í%p‰õ#r²cxmec[X½¨Æâ°"p m–Ã/V±`l Îs*—@ƒùñù $ÀCÈR-PWuÔ"g£1q!@Šzä­"y–G1)ËRsÉ9R‘“B£|Py!U¾‡•r%{`ù 4I–é¡%{˜Ö€á<ºLè$ÔKkò‹V¤b j×Ë_v'˜‰Pï¦IÍjRS5:&2µyevH3«Íî œ€§tÊY  “ êD;¥S1f’›óTœ&i•ƒÏõí3VýdO<‹Pâ3™Ü4¤6 :À¾Š¡Á;hB2PÝ@´zUÕE¥SÑÛl9=ÍG‹RÒŒT7è7µ‰.Ä0’LgJÓšÚô¦8Í©000¹T!€‘P‡JÔ¢õ¨HM*ŠPÈŸ:õ©PªT§JÕªZõªX]K@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Deparaplex1.gif0000644000000000000000000000473010520670125021621 0ustar GIF89a<÷ $$$(((888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìê…8w¯^¼7EL 8¡@€`¢ða¿ ûBŽ Øf„#@PÀx˜¼P2鵕S6@°„‰ 6hй@ƒ…M€ðl‚µ ¢O'4-üj꓊'4( ¸€ÀÍ WÀíøèÍ¿ƒ7H|»ÏãXpÿX`BîÞ˜/gÎ~³uï»Ãß žä{åÏcWO=ûxì÷Íg‚|âTI¶½&^aˆ©w™kg›Là|hÓ#QhØ`"¶Yl [„Ιpˆ]_†ÒÄaMç $Â@.zcŒ2ÍHÓ<–™vîÈ#L>ÎDb-9š†FéR’7} å@Q^¹•6)°À“Gf©¥jy]e|&]cÊX¦UÀ¡™&˜E²Ù¦L Àž|öé矀*è „" §œ XYç31F*餔Vj饘fšÁ¡ð&†v2ú—5u §§<Š)êH¤þØé§P†ÿº*K­Î¤¬1ª:+HµîÊ’®¾vÔk°)K¬FÃk’±Ê^”l³#1 -EÏN ’´ÖFTm¶aË­C­ÞøíGÞŽ»©(`®G宋©#Ðé®\²Î‹Ñ¶öRÔn¾áËoDûþëï¿ÌïÀGVoÂÚâÊ0» ? ®Ãodp¾W|ÐÅö’êÁóqÈ Á+/ÉÃŒò]¯¬¯Ê.÷ÛrÌ'+Äñ¼¯›cÊ13”³Î"÷|îÌ+{p˜ÑÆB7»ûó¸Ö× %ò,tÉD£up5rsσüðÖ£uß×1›,1Ù¥¸1Ú.?ý-€@·k°Y½ æUÿà¸#q0˜Nrÿ›AUg·œa†]@’Ùf}õ@ @â5ípƒ‘ ŽÚ-ˆ‰ëÁ’-záhª£hãß-Þ8ú¨’Ož–#®yCœ Äh 0~›bŒƒbñ‹@÷eø¤¡·å¶¢bŽoæ9fSÖ>y ‡æ¾;C½g7Á˜ý¾< $˜È7 !N~®mÖ; ä¶XÛº]¦<íþÎéÿ  HÀrj€ÛGÂgÃ, DÀzL°C¹O; ÞcÂìÆDŠq pþÙ®!œJ¾·ð-G¼NŠ6S¤ï‚¬ãüx£ÑØ1³KŸaÿG«Ú}Lh“ 3§@,N1Lg P"¦©ÐÀ±ˆCÝ0i ñ·œ1–(xØk‰ÚzÖ™%b©‰á›y&!™çF›¹À4 L€ÐÀú¢Ç 80ïçÇéðm<‚«ã–´w5 Œ'q:‘ DvF8Jž ,¼W %r7ãxò“LD%A §±Pf‹•s¥µ`)1YN‹–³%´Â¦ÊÁ1dkD¥.›…K† SYÅLØ1•L‚-“XÍü×3ƒM~MÓWÕÌ×5w•M{msV¼Tå7WÌOŽSTÝœ×9•N&3BR㘚gwj'Pdÿψ€‹& ‘@ÕKÙœÒ! _ óFAÚi”çYÀøæY•§E}Ñ/5&·I;úA@t*Ôüà €$ÇsQöĪ <(CÎó;„?iÄ~c?N€ä'…ƒÏ6Éí<œazr*¡ÁX§DBjéPOSÔ1ÉíwÓYNÛ´Ô:6Õ¥jFu´ÑŠÎ1àãñFd‚H§5Úɤ:ÖíTUKí4äÀW×{–Uby-â9Óô•¨}X` â$ˆ4ö¥]ì·îz%ÉFdDLUbfYˆ8 Èl(+¥Î>dh­h5 SÓ:$‰rR-d{i(½Úö¶¸½íEÐÈÊÔ%°E“$0‚ÙªÒµ A-†[Ü\m6aÈeˆ˜+%Ò)º ¡@s«û\‚a÷XÖåÑw‰Þ7XåÕÐy}•Þ­wWíÐ{gßùÌwUõ…Ï}E•_ïì—QýÝÎïàâ ¸MÎÇt€À”€©C,p€LYøÂΰ†7Ìá_Àœ„RB™øÄ(N±ŠWÌ⟘ý±ŒgLãÛøÆ8αŽwÌc;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Identity1.gif0000644000000000000000000000407010520670125021322 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xnD"LP©@8 ÑË’ð.Oé¸A—»Þ¤«@´.-fB)d+ò4Õfð¿­ Ѫ!pIkÅü.ù¡‚Z€iÀJÛÁ´$lÌYÂ;1@@µ‚ €ÃüJüP¦¨)' q&P€ÇÚ|æžH9,Ðè™wÚ”ïG½reýòÃ2;”)±"ˆðç™ð)Ò8:4Á~BšèP¯Ò(ëäÔ<ÝP¢p×m÷Ýxç­÷Þ|ÿÀ,·$êÁ¦½¦Î5ç*ö —n}¦ÀzS}Wnùå—àAbÀ½rÕ ‰ ëÖt]ñ¥™ŽÝøÁŸ–žÓÒP÷š6€ÓúÎP¦àÀ±¦9¤ªš¨´fꜰ|ìi 5í½-wijÔ.“L`A¼ðN /½öºëµ»äw/oÀÏ·SEמX(ê¾Ò‚Ê{rYÈOšý*¡@Ò¢è=€È1 ‚XˆÂq ø ˆ‚¼± 0˜ ¶ñ ~@8Ö‡„°1¡|Pؾ‡…ªq!{`x¦‡†¤±¡ypއ‡žñ!xÿ€¸!v‡ˆ˜1¢vX%^‡‰’q"u ø)F‡ŠŒ±¢s°˜-.‡‹†ñ"rÀX1‡Œ‚1£pÐø5þ†~q#oà¸9憎x±£mðx=Ά|q_¯ȹø6…„Ë![“È·,R5Œ  ˜ìÁè‘§‰¤Z0ù?Kºˆ“¡Ñ¤Y@éQ–…”›1¥b&II„¨’*¨ÄÌ+ËÊÌa­œÈ-{RKÉì_¬Ìe¿„é«`{Çìåc~ic3§j%4ùàȦ6·ÉÍnzó›à §8ÇIÎršóœâ¼ FM†p€ ˆ§<çIÏzÚóžøÌ§>÷ÉÏ~úóŸúdÚIЂô M¨BÊІ:4:;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Generate1.gif0000644000000000000000000000375010520670125021267 0ustar GIF89að÷ $$$000888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,ðÿEH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³fD rêÜɳ§ÏŸ@ƒ J´¨Ñ£B'Ø$IàÒ§P£JJÕç‚!–‚Ì`@«W’ ”~å˜s¬YeÏfL«¶­E¶n)ÂK×áܺïâÝkP/_…~ÿò ,¸/„ˆN¬ø0cÁ‹G~lv2bË”½b†ì83ÞÍA{¦)zoéÑ1O×UÚ%븯[¯ŒÝ–¶l”¶Ïæ¾]r÷Xß¼E×Ü9øïâ­‡G‹µòåd›~]#õš×«_Ì>“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzªQ/úQ— ©IÄ'êj¯^ÿ„¤,à‘s&´€­Mê*]€ªRP •’Ùª ¹Á²)ÐÍv¹Á³"ìYÀ²Ø$À¡Ôv 힦î+K  DðýhP>ò)‚˜p£TÖÛj¼Ô[ ðúÈ«@=Y¯àK: d¨Ëî¹¹ké¥` eÄúc\ $‘)‚­žénÇ"|<®E¹eg‚ISlñ{O¤qÜèã<¦¤Ðq•Jλ0–î (¦VΩd™R³¤@Ï`‡-öØd—möÙgÀCðmê7椘 %¸n]lÖtbÿ)7A h #×0ë—a# íBòù»ðD ètó}¥<¬$É `î7Ÿ‘;0ù@Œ©7ÎçtJô¬¸z-Q°+Ö¼ø(©IP)åZ ©µS€ûTZ{É ´ç£¿3A—ßB¼:J ¼¸]ÓÓEéAŒþW×î]©Ïl²ô¡~Jaúêñ[Ù·ÐûÑï\ü_Ù?þÄÉ!ûþ£ÿ´¢?ñ p)dÏm’@û,;l_Å@í(‚ê› ö*(@rÐD”‰-ÂÔ”0Q#dÛ ñ”BÆ­°M-¤ÏäÁb$† Áa§jhCøñ°‡ÂºÍMóBïq;EDß‘øÃ%^¬‰NÜà£X¿$ŽŠå±¢¹°8‘!†‹Y„"ó£EÕñ‰S<£…XÆ yÑ?m4Ð 2Ç;¥Q*#RÇÆì1wü#õøÇ>(Ž2¤!Õ¢HD.È‘ ‚äƒ$ù?Aæ’!‘,™¨ª5!PWFIÊRšò”¨L¥*WÉÊVºò•°Œ%++€ä݆ 0€.wÉË^úò—À ¦0‡IÌbó˜Èf4ÀÉf:ó™ÐŒ¦4§IÍjÖ% ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Printer1.gif0000644000000000000000000000357110520670125021161 0ustar GIF89aò÷ $$$(((000444888<<<@@@PPPYYYaaaqqquuuyyy}}}………•••¡¡¡¥¥¥²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚæææòòòöööÿÿÿ,òÿGH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Mš$èÜɳ§ÏŸ@ƒ J´¨Ñ£H‡Zqs¤ ’JJµªÕ«?Ñ4$…]Ê|@A¬G̪åhÁÁÚhßʵØv.Ƹvó>¬«—"Þ¾€ò ñ/áÃ##fhx1`ÅŽ6Žœ2eƒ“/˵¬y`æÎj9ƒþ Z¬èΤKw=­9µê›¬/»~]36åÙ´gÚŽŒ;wÌÝŽ{û~ |±ðá-‹#>Ž|¥òÃÌ›§|N8ºô“Ô[¿^2;àíÜGzÿï >|ÈñzË›ÿˆ>¯úõÛÛ}£ü¹ôëg¼/7¿þ‹ü½å߸րNd Z&Ñ‚f5èà^nù&á„ A(Ö….¤aXv˜Ð‡]…(âA$6e≥xÓŠ,äâI„ÐŒ1&V!aLpcZ9’4£IpÅAŠ4dI=ŽP€ÀÀA8Ƹ$IM ÐfH& Ò•#eéc^‚)¦’;fæh~YP•,’)Ò›qª¹æ˜mÆ@#ü9 | çžÙ '*ú£":ê¤m0ÁÈIPØ™¤%m`$A”:4QF9*œhJÐôÿ*IðÀª¥6tê—Ði‘_ʬœ ´*P¦ÕèªM³’$¶™+C»²z)ª­z‰¦ Àš¨ŽP¬–pbkhSÍŽ”ìF;íB§rå§nBœhú¥¸±VP@!PA¾¦õyP¯ì&¬ð 7ìðÃGüp„YÓ©\ÊÕ±–›išó¨· H™gX銴€Â´e1MÕ²Çy†\ìt¬lš(ìØì¶,л Å,ÐÌø‚k— |ð¤dpòj>#æB{öòL–z*¥q p§#€M¯–N°ÁbÜ™/ý_Ê(É­Ý'Ù]Þ&éÿ ß%ù½à$ ná#â")Îã!9~ä I.åYÞægm(Fœw¤9r¡s4úp¥ÃåùçtUÚê¬S”ºF§û6{Fµçvû]°Ç.ÑîåNð ÿñ¯ò~õî;DÌO¤|iÑK4=hÕGtýÛ®·æüóe_Ø÷à3$þCÛkv¾Cé_¶þåƒÞ½läÇ?âü·Õo?Šøó¦ÿþ-ê_pþ@ Ð8, Ž†Ó>ʼïH üÝ—“À>p! üÔ¡SA^P!tÌ%ÓÁý!!\Ì ©TBû­ðP ß«ÓÂø½pN5,ß I•CðíPk1„Þ ^µÓÃçýP ðQMကØ€§HÅ*ZñŠXÌ¢·ÈÅ.zñ‹`Ü"°¬×p  H£×ÈÆ6ºñpŒ£çHÇ:ÚñŽrl–ÈÇ>úñ€ ¤ IH¹;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Nor1.gif0000644000000000000000000000413410520670125020270 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú,RbMðqa¹ÊœiÈ753º@›…:‡Ô˜ø¢+‚ D‚S›…óG twMƒ„@¸˜e.Ù&L@¸Z­Sz-_Ø¥¦6Àý ^ÿp7¾WmíÑ3ÊÝ]7öÀÛçïZÍ(ùä”Wnùå˜g@‚M´M¼E¸1\`Â_ ”úør°­ençÁg°þ¹®‚wô@ôì¿fõ•jo&÷’z?&øŠ¿%ùŒš%ú‰ª%û†ºï$üƒÊ#ý€Ú"þ}ê¯!ÿzòß…x'>ˆ€t2 ƒ'ˆnr € ¸& ú‡‚f²à~0Øî U+ÕônÅÁê )C[€„6Jk¹˜*°X±°…Í;Uv /ôU[Ø ÿoèBäì"p m–Ãâ°`; ÎsƆ=k9Q E,N*ŠðŠXÌ!©¶8‰ !´¡³¨–G1)ËRƒÆ!²!Ò ~ð¨!=Ö‡ò£|) 4Iï!ä{ÔÖ€!’=Šdá$ÔH+^1’é)äùÈô`’"¢Óœ(GIJQ  F`DU* ¢É à"è$x>ÙI¾òdK%-«3[D–ÝÙ¥t*€Ë_ŽVœÛ1c•Là-óUÍÌÞ3UMééRŒ«Ì%« `V‡›ž»f6?5ÍS3vål6WéMéœS:íDÎ;‘Ïâ̳8è@*°A´q*Ä0’@JЂô M¨000ù3!€‘D'JÑŠZô¢Í(ŠPŇzô£ ©HGJÒ’šô¤(ÍI@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Tail1.gif0000644000000000000000000000370210520670125020423 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xîFY¶;A¥‰ð®¼ðþ”n€t¹kUj°gš† °®TÝûÑT›iÀú ´.G ÀjÓbŠé eìT+˜,¬ïÃE“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzZ/f°Á£"Q€c*Bÿ$¦©‰ºš­Ù裱†$æ£HÙ´ IdçáÊR žd'?’ B"|°Am@mµ§¤-¶}K&‡î*–¤›®¶V @-»û)»Rˆ‘yÏþ¨«ôèãÕî*= BþeÂ,,€ÃJ@T¶+WÚ˜¤Ås—Pï½òB¤«ÁP`瞈%T‚‚¡¿ZåŘJ'9y¥˜ÐJP‘Ë|¦Á"H0pÐy–œ!‡<ò{N;d#¥Žd™Yž)аÜ$ #Ùf‹@öÐV\©×GW, D¢¤@Ôxç­÷Þ|÷ÿí÷ßÀCøÞ˜-A‹ðž“޹@5[Kæ:yåUBIì«!c 7–H“n—»åAÞlKJvz‹¸@€:€ô I.•kÓY@gþÈûœ>>ª«@Ÿ«]{|Úë¦tauêê¡Dª«‘JzÒ/’Îj«I¦¼A—ágß½šßw鬾èrÖMÓõ@íªSý)…t5P¿]UߟŽÛéŸÿÀ·p€þ9 qØ"j¥€ÉqàR è Ú„‚Ó± v4è? –‡ƒ÷ó`DDhÊ„„A!ÿ¨!ÖŠ…4ra²`è¡ÉO*´ £ªòІ>4Ñ í]3Ä/åpElÒ²DÎô0ˆ*z"(Å)V¤‰ÿK⌰˜-²ˆ‹ôâ‡Àh+Rˆf¼¢K—ÆV±${#WˆÆ9ƱŽv¤ãmÈx+9æquxü#×ÈûiA†új¡ MhOú‰ò„¢Œ‰À©Ä©Q‡>$¸ÀFJÒ’šô¤(M©JWÊÒ–ºô¥0)K/@Œy”!`€vÊÓžúô§@ ªP‡JÔ¢õ¨HM*QÀ›:õ©PªT§JÕªZõªXN@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Multiplex1.gif0000644000000000000000000000460710520670125021522 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìú40áàÕýíÝ! ¡@Ž]v¨òäò¤øG¼È8F„ð`Ç.ƒ&r&sŠ® ‚Šõèì§û8ðN pûzŸ_TÙ|þµü²@Is_Ç…Ø…> €4mîQCê~aï_.ó\¼`WO $°@q€þ|&´ u‹f}0¦ör_ÑÙ7Кø(ŽÏ’³Ê'8 SñÜWÇ錠'HÁ Z˜VFºæ¶˜Tæ5˜ù߀ž@Î p@„œÇ8¢y€f€aª·»œ„àëãHÛr¢?Š0"hÕÿ œv0H`5 Pk¢6=šeMÊá‚z8™ o|ÈèÃÃ}12^¬Ì&@=3ràa’Y£ ‡$³D`‰*¢WÂ3¶X¯#Èãönf•, .tÖO•Hc-’TüÕ#CI^MÒS•ä yHHyer';ÄÉ%7õÉYÒR¥„Õ)'•ÊV­rQ­TÕ+ËSÍ2Pµ$Õ-ý”ËPíòL½œÉ&EÙIxS&¡¼É/£tLK-SIÍ„‹9©IN!«9 `¨ ´·«†¤2£A ¸X­/šÉ\7½™0p†Êl¦CÀ*C=ž¡F5%S_o¦cÿ.oF“-€<3<ß8Â!ˆdö¡H³]ÿ\K@%#Bâ†} CÕùÌ#Eô,íLEE6kªh£Üì(>j–j³ ½i(Iù©)v¶ÓXÓœæKH› ¥ý|KÓLJÈT¥=ª^"‘¥ô¡êRª]˜ÇM…°.¨_“ê‘z#­^ˆfâ*¼J¡ 5à@b}Yd¿!Õ¡6½i\ R‚ž5­,ZkE„tÁ¾úõ¯~@™æª×ýÔµIx€ðJ¢Ââ§­‰cCäØõL ²<ŠkeÑSaeÖ¦›$aÝ9W¸j–´¥ì…B«G¨Þ µsU-…X»E×lî ¶q•í‚h›?Û6 ·6Õ-‚x»áø1.~Ë;ßR ¸ì<@æÊ€Î•–!8€¶ËÝîz÷»à ¯xÝ„@êº ©˜ÖËÞöº÷½ð¯|±Ä€ª¢÷¾øÍ¯~÷Ëßþú÷¿0s;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/doc-files/Demultiplex1.gif0000644000000000000000000000472010520670125022027 0ustar GIF89a<÷ $$$(((888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìê…8w¯^¼7EL 8¡@€`¢ða¿ ûBŽ Øf„#@PÀx˜¼P2鵕S6@°„‰ 6hй@ƒ…M€ðl‚µ ¢O'4-üj꓊'4( ¸€ÀÍ WÀíøèÍ¿ƒ7H|»ÏãXpÿX`BîÞ˜/gÎ~³uï»Ãß žä{åÏcWO=ûxì÷Íg‚|âTI¶½&^aˆ©w™kg›Là|hÓ#QhØ`"¶Yl [„Ιpˆ]_†ÒÄaMç $Â@.zcŒ2ÍHÓ<–™vîÈ#L>ÎDb-9š†FéR’7} å@Q^¹•6)°À“Gf©¥jy]e|&]cÊX¦UÀ¡™&˜E²Ù¦L Àž|öé矀*è „" §œ XYç31F*餔Vj饘fšÁ¡ð&†v2ú—5u §§<Š)êH¤þØé§P†ÿº*K­Î¤¬1ª:+HµîÊ’®¾vÔk°)K¬FÃk’±Ê^”l³#1 -EÏN ’´ÖFTm¶aË­C­ÞøíGÞŽ»©(`®G宋©#Ðé®\²Î‹Ñ¶öRÔn¾áËoDûþëï¿ÌïÀGVoÂÚâÊ0» ? ®Ãodp¾W|ÐÅö’êÁóqÈ Á+/ÉÃŒò]¯¬¯Ê.÷ÛrÌ'+Äñ¼¯›cÊ13”³Î"÷|îÌ+{p˜ÑÆB7»ûó¸Ö× %ò,tÉD£up5rsσüðÖ£uß×1›,1Ù¥¸1Ú.?ý-€@·k°Y­RæqÿPsD$L@‚@ƒs0X“‚ç$÷¿Tu6K†f½·À`f·Hä†Y_=PPà¸@M7¤˜@¡˜£yàÚêÙÝâ’¢… "Œfwîš?ɤn¾C¸eçžg@莗ÎÐéÏa¶œb«_fèrêa‡ßÖ-¤yÎ)fX«ç=fPAg´´8¿%мò 1ßø¤¿À—¼©—›õåmy÷  Ld p€Ó¡ÞmÔG<»p€SŒ 'HÁ Z‚Ü<"¿Ít†5ŠyþºG¹þ‰8ÿCOó²—¦È0ƒc`ñ©p~ ažÑðÀñx wÁ¡ ÿC„½ …ÌÛŒu’6»Æ ii´"ÞÇ„ö9Ùt숡6s™Ám&i!frÓ@@{Etö—¦2jÀ: °hžúɰ!ñZg®ˆ¥,r„oæ¹À@3Anp˜Žá"„½ pà¯qä"7s ¤’†s¤Š—È;ÎP!ÏãŠc½ï4ð“Á!’hJTJD•ÙZ_Å`i-YJŒ–Ó²åÃp -]2Œ—Í ›+äǩ͕ÀT–/–Ìc-“`Í$Ö3ÿÍ`M“_ÕôÕ5ó•Í]mÓ^ÝœÕ7çÎU ™ÅÔØ1QYNQÓ]ídÔ;“!åðöÕ0esÿÊŽðEdšÍ½([€€æÍ³© +Ïs9†n &*OïbµOˆöÓ!!ºvôƒ€èT¨?ø)À´'<ŒG£ìáè>åvžz€¤ø¡ŠÈØš'†0ÝYqây'š¦È:8ýgÛÈ3˜ìæIA5¨Ž*1¹=0ÎaÑÒS7”j4GQ èiˆÚ¦Å9¦é ‘ôHd"¯65ŸLÝhÈ:¦w$s ªpèª%»HpUHa¤º¾^ɯqD+Óa"ö[†•Òc#2qI)²Gš,D€X6WT}˜f²4uö³‹šéGaRE9¶±®4ÔgKÛÚµÒvŠÒ§jÍÒZ4 @#€-*GëÒà·ÁmG‰Û ÷²¡esBäBw¹«ý$fy4]em7FÝ=Öw5^b·@å Öy”^_­w>íÝÕ{áßYÍ×;õ]Õ}·“_Qí·8ýeÔ…à; e:ê  Sް„'Lá [øÂÆÀFÇà…T€P ±ˆGLâ›øÄ!f€X;Ìâ»øÅ0ޱŒgLãÛ8F;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ProcessRead.java0000644000000000000000000001136311105701167020175 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Reads one Object from its input channel. *

Process Diagram

*

*

Description

* ProcessRead is a process that performs a single read * from its in channel and then terminates. It stores * the read Object in the public value field of * this process (which is safe to examine after the process * has terminated and before it is next run). *

* ProcessRead declaration, construction and use should normally * be localised within a single method -- so we feel no embarassment about * its public field. Its only (envisaged) purpose is as described in * the example below. *

Channel Protocols

* * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
*

Example

* ProcessRead is designed to simplify reading in parallel * from channels. Make as many instances as there * are channels, binding each instance to a different channel, * together with a {@link org.jcsp.lang.Parallel} object in which to run them: *
 *   ChannelInput in0, in1;
 *   .
 *   .
 *   .
 *   ProcessRead read0 = new ProcessRead (in0);
 *   ProcessRead read1 = new ProcessRead (in1);
 *   CSProcess parRead01 = new Parallel (new CSProcess[] {in0, in1});
 * 
* The above is best done once, before any looping over the * parallel read commences. A parallel read can now be performed * at any time (and any number of times) by executing: *
 *     parRead01.run ();
 * 
* This terminates when, and only when, both reads have completed -- * the events may occur in any order. The values read may then * be found in read0.value and read1.value, where they * may be safely accessed up until the time that parRead01 is run again. * * @see org.jcsp.lang.Parallel * @see org.jcsp.plugNplay.ProcessWrite * @see org.jcsp.plugNplay.ints.ProcessReadInt * @see org.jcsp.plugNplay.ints.ProcessWriteInt * * @author P.H. Welch and P.D. Austin */ public class ProcessRead implements CSProcess { /** The Object read from the channel */ public Object value; /** The channel from which to read */ private ChannelInput in; /** * Construct a new ProcessRead. * * @param in the channel from which to read */ public ProcessRead(ChannelInput in) { this.in = in; } /** * The main body of this process. */ public void run() { value = in.read(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Plex2.java0000644000000000000000000001323611105701167016756 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Fair multiplexes two Object streams into one. *

Process Diagram

* *
 *    in0  _______
 *   -->--|       | out
 *    in1 | Plex2 |-->--
 *   -->--|_______|
 * 
*

Description

* Plex2 is a process whose output stream is a fair multiplexing * of its input streams. It makes no assumptions about the traffic patterns occuring * on the input streams and ensures that no input stream will be starved by busy siblings. * It guarantees that if an input stream has data pending, no other stream will be * serviced twice before that data is serviced. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1java.lang.Object * The input streams. *
Output Channels
outjava.lang.Object * The multiplexed output stream. *
*

Example

* The following example shows how to use Plex2 in a small program. * The program also uses some of the other plugNplay processes. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class Plex2Example {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel[] a = Channel.one2oneArray (2);
 *     final One2OneChannel[] b = Channel.one2oneArray (2);
 *     final One2OneChannel c = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Fibonacci (a[0].out ()),
 *         new Squares (a[1].out ()),
 *         new Sign ("Fibonacci ", a[0].in (), b[0].out ()),
 *         new Sign ("              Squares ", a[1].in (), b[1].out ()),
 *         new Plex2 (b[0].in (), b[1].in (), c.out ()),
 *         new Printer (c.in (), "", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
*

*

Implemntation Note

* For information, here is the run method for this process: * *
 *   public void run () {
 *     AltingChannelInput[] input = {in0, in1};         // in0 and in1 are the input channels
 *     Alternative alt = new Alternative (input);
 *     while (true) {
 *       out.write (input[alt.fairSelect ()].read ());  // out is the output channel
 *     }
 *   }
 * 
* * @see org.jcsp.plugNplay.Plex * @see org.jcsp.plugNplay.Multiplex * * @author P.H. Welch */ public final class Plex2 implements CSProcess { /** The first input Channel */ private final AltingChannelInput in0; /** The second input Channel */ private final AltingChannelInput in1; /** The output Channel */ private final ChannelOutput out; /** * Construct a new Plex2 process with the input channels * in0 and in1 and the output channel out. * The ordering of the input channels makes no difference * to the behaviour of this process. * * @param in0 an input channel * @param in1 an input channel * @param out the output channel */ public Plex2(AltingChannelInput in0, AltingChannelInput in1, ChannelOutput out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { AltingChannelInput[] input = {in0, in1}; Alternative alt = new Alternative(input); while (true) out.write(input[alt.fairSelect()].read()); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Successor.java0000644000000000000000000001056611105701167017740 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Adds one to each Integer in the stream flowing through. *

Process Diagram

*

*

Description

* Successor increments each Integer that flows through it. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Number * The Channel can accept data from any subclass of Number. All values * will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows how to use the Successor process in a small program. * The program also uses some of the other building block processes. The * program generates a sequence of numbers and adds one to them and prints * this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class SuccessorExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel a = Channel.one2one ();
 *     final One2OneChannel b = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Successor (a.in (), b.out ()),
 *         new Printer (b.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Successor implements CSProcess { /** The input Channel */ private final ChannelInput in; /** The output Channel */ private final ChannelOutput out; /** * Construct a new Successor process with the input Channel in and the * output Channel out. * * @param in the input Channel. * @param out the output Channel. */ public Successor(final ChannelInput in, final ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) { final int i = ((Integer) in.read()).intValue(); out.write(new Integer(i + 1)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Plus.java0000644000000000000000000001241111105701167016701 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Sums two Integer streams to one stream. * *

Process Diagram

* *
 *    in0  ______
 *   -->--|      | out
 *    in1 | Plus |-->--
 *   -->--|______|
 * 
*

Description

* This is a process with an infinite loop that waits for * a Object of type Number to be sent down each of its input channels. * The loop body adds them together and writes the result as a new Integer * to its output channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in1,in2java.lang.Number * Both Channels can accept data from any subclass of Number. It is * possible to send Floats down one channel and Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows how the use of this process in a small program. * The program also uses some of the other building block processes. * It generates two sequences of numbers, adds them together and * prints them to the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class PlusExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel a = Channel.one2one ();
 *     final One2OneChannel b = Channel.one2one ();
 *     final One2OneChannel c = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Numbers (b.out ()),
 *         new Plus (a.in (), b.in (), c.out ()),
 *         new Printer (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Plus implements CSProcess { /** The first input Channel */ private ChannelInput in1; /** The second input Channel */ private ChannelInput in2; /** The output Channel */ private ChannelOutput out; /** * Construct a new Plus process with the input Channels in1 and in2 and the * output Channel out. The ordering of the Channels in1 and in2 make * no difference to the functionality of this process. * * @param in1 The first input Channel * @param in2 The second input Channel * @param out The output Channel */ public Plus(ChannelInput in1, ChannelInput in2, ChannelOutput out) { this.in1 = in1; this.in2 = in2; this.out = out; } /** * The main body of this process. */ public void run() { ProcessRead[] parRead = {new ProcessRead(in1), new ProcessRead(in2)}; Parallel par = new Parallel(parRead); while (true) { par.run(); int i1 = ((Number) parRead[0].value).intValue(); int i2 = ((Number) parRead[1].value).intValue(); out.write(new Integer(i1 + i2)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Multiplex.java0000644000000000000000000001335211105701167017746 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Fair multiplexes its input Object stream array into one output stream * (carrying source channel and data pairs). *

Process Diagram

*

*

Description

* Multiplex is a process to convert multiple streams of * objects to a single stream in such a way that it can be * {@link Demultiplex de-multiplexed} later. * The protocol on the outgoing multiplexed stream consists of * an Integer, that represents the channel identity of the * multiplexed data, followed by the multiplexed data. *

* The ordering of the channels in the in array makes * no difference to the functionality of this process -- the multiplexing * services all channels fairly. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in[]java.lang.Object * The input streams. *
Output Channels
outjava.lang.Integer, java.lang.Object * The channel index followed by the multiplexed data. *
*

*

Example

* The following example shows how to use MultiplexInt in a small program. *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class MultiplexExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel[] a = Channel.one2oneArray (3);
 *     final One2OneChannel b = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a[0].out ()),
 *         new Fibonacci (a[1].out ()),
 *         new Squares (a[2].out ()),
 *         new Multiplex (Channel.getInputArray (a), b.out ()),
 *         new CSProcess () {
 *           public void run () {
 *             String[] key = {"Numbers ",
 *                             "            Fibonacci ",
 *                             "                          Squares "};
 *             while (true) {
 *               int channel = ((Integer) b.in ().read ()).intValue ();
 *               System.out.print (key[channel]);     // print channel source
 *               int n = ((Integer) b.in ().read ()).intValue ();
 *               System.out.println (n);              // print multiplexed data
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.Demultiplex * @see org.jcsp.plugNplay.Paraplex * @see org.jcsp.plugNplay.Deparaplex * @see org.jcsp.plugNplay.Plex * * @author P.H. Welch and P.D. Austin and P.H. Welch */ public final class Multiplex implements CSProcess { /** The input channels */ private final AltingChannelInput[] in; /** The output channel */ private final ChannelOutput out; /** * Construct a new Multiplex process with the input Channel in and the output * Channels out. The ordering of the Channels in the in array make * no difference to the functionality of this process -- the multiplexing * services all channels fairly. * * @param in the input channels * @param out the output channel */ public Multiplex(final AltingChannelInput[] in, final ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final Alternative alt = new Alternative(in); while (true) { int index = alt.fairSelect(); out.write(new Integer(index)); out.write(in[index].read()); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/package.html0000644000000000000000000000257510522104430017376 0ustar This provides an assortment of plug-and-play CSP components to wire together (with Object-carrying wires) and reuse. Primarilly they are for education and demonstration purposes, but some have value for general applications (e.g. {@link org.jcsp.plugNplay.Delta}, {@link org.jcsp.plugNplay.DynamicDelta}, {@link org.jcsp.plugNplay.Plex}, {@link org.jcsp.plugNplay.Multiplex}, {@link org.jcsp.plugNplay.Demultiplex}, {@link org.jcsp.plugNplay.ProcessRead}, {@link org.jcsp.plugNplay.ProcessWrite}, ...).

The educational purpose is to demonstrate how simple it is to build layered networks of communicating processes. Each component works to a clean channel interface. Component instances can just be wired together. A network of such components is itself another (CSP) component. Network design and analysis takes place independently at each level - we do not have to think about the whole network hierarchy to reason about each level. This enables us to construct components with arbitrarilly rich behaviour without running into combinatorial explosions of complexity.

Examples are given of networks with 20-30 processes (threads). Because of the component layering, we never need to consider more than about 5 at a time and it is easy to see what they do and that they are without deadlock, livelock, starvation or race-hazard problems. jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Nand.java0000644000000000000000000001275011105701167016644 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Bitwise nands two Integer streams to one stream. * *

Process Diagram

* *
 *    in0  ______
 *   -->--|      | out
 *    in1 | Nand |-->--
 *   -->--|______|
 * 
*

Description

* This is a process with an infinite loop that waits for * a Object of type Number to be sent down each of its input channels. * The loop body then calculates the bitwise NAND on the values of the * two Numbers and writes the result as a new Integer to its output channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in1,in2java.lang.Number * Both Channels can accept data from any subclass of Number. It is * possible to send Floats down one channel Nand Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows how the use of this process in a small program. * The program also uses some of the other building block processes. * It generates a sequence of numbers, rounds each odd number down to * the nearest even number, negates them and prints them to the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class NandExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel a = Channel.one2one ();
 *     final One2OneChannel b = Channel.one2one ();
 *     final One2OneChannel c = Channel.one2one ();
 *     final One2OneChannel d = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Generate (b.out (), Integer.MAX_VALUE - 1),
 *         new Nand (a.in (), b.in (), c.out ()),
 *         new Successor (c.in (), d.out ()),
 *         new Printer (d.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Nand implements CSProcess { /** The first input Channel */ private ChannelInput in1; /** The second input Channel */ private ChannelInput in2; /** The output Channel */ private ChannelOutput out; /** * Construct a new Nand process with the input Channels in1 and in2 and the * output Channel out. The ordering of the Channels in1 and in2 make * no difference to the functionality of this process. * * @param in1 the first input Channel * @param in2 the second input Channel * @param out the output Channel */ public Nand(ChannelInput in1, ChannelInput in2, ChannelOutput out) { this.in1 = in1; this.in2 = in2; this.out = out; } /** * The main body of this process. */ public void run() { ProcessRead[] procs = {new ProcessRead(in1), new ProcessRead(in2)}; Parallel par = new Parallel(procs); while (true) { par.run(); int i1 = ((Number)procs[0].value).intValue(); int i2 = ((Number)procs[1].value).intValue(); out.write(new Integer(~ (i1 & i2))); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Tail.java0000644000000000000000000000764711105701167016666 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * The output stream is the tail of its input stream. *

Process Diagram

*

*

Description

* The first Object (i.e. head) of its input stream is not forwarded. * The rest (i.e. tail) is copied through unchanged. *

* Two inputs are needed before any output * is produced but, thereafter, one output is produced for each input. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
Output Channels
outjava.lang.Object * The out Channel will send data of the same type * as that sent down the in Channel. *
*

*

Implementation Note

* The implementation uses an {@link Identity} process for the copy loop: *
 *   public void run () {
 *     in.read ();                        // accept, but discard, the first item
 *     new Identity (in, out).run ();     // copy the rest of the stream
 *   }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Tail implements CSProcess { /** The input Channel */ private ChannelInput in; /** The output Channel */ private ChannelOutput out; /** * Construct a new Tail process with the input Channel in and the * output Channel out. * * @param in the input Channel * @param out the output Channel */ public Tail(ChannelInput in, ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { in.read(); new Identity(in, out).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Identity.java0000644000000000000000000000732011105701167017552 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This copies its input stream to its output stream unchanged. *

Process Diagram

*

*

Description

* This is a process that simply copies its input stream * to its output stream. The difference between a channel and a channel * into which an Identity process has been spliced is that the * latter has a buffering capacity of one more than the channel * (which is zero, unless explicitly constructed with a buffer). *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any class. *
Output Channels
outjava.lang.Object * The out Channel sends the the same type of data (in * fact, the same data) as is input. *
* * @author P.H. Welch and P.D. Austin */ public final class Identity implements CSProcess { /** The input Channel */ private ChannelInput in; /** The output Channel */ private ChannelOutput out; /** * Construct a new Identity process with the input Channel in and the * output Channel out. * * @param in the input Channel * @param out the output Channel */ public Identity(ChannelInput in, ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) out.write(in.read()); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/0000755000000000000000000000000011410045054016064 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/FixedDelayInt.java0000644000000000000000000001016111105701167021424 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This holds on to data from its input channel for a fixed delay before passing * it on to its output channel. * *

Process Diagram

*

*

Description

* FixedDelayInt is a process that delays passing on input to its output * by a constant delay. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
* * @see org.jcsp.plugNplay.ints.RegulateInt * @see org.jcsp.plugNplay.ints.RegularInt * * @author P.H. Welch and P.D. Austin */ public final class FixedDelayInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** * The time the process is to wait in milliseconds between receiving a * message and then sending it. */ private final long delayTime; /** * Construct a new FixedDelayInt process with the input Channel in and the * output Channel out. * * @param delayTime the time the process is to wait in milliseconds * between receiving a message and then sending it (a negative * delayTime implies no waiting). * @param in the input Channel * @param out the output Channel */ public FixedDelayInt(final long delayTime, final ChannelInputInt in, final ChannelOutputInt out) { this.in = in; this.out = out; this.delayTime = delayTime; } /** * The main body of this process. */ public void run() { final CSTimer tim = new CSTimer(); while (true) { final int i = in.read(); tim.sleep(delayTime); out.write(i); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/Plex2Int.java0000644000000000000000000001375411105701167020413 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Fair multiplexes two integer streams into one. *

Process Diagram

* *
 *    in0  __________
 *   -->--|          | out
 *    in1 | Plex2Int |-->--
 *   -->--|__________|
 * 
*

Description

* Plex2Int is a process whose output stream is a fair multiplexing * of its input streams. It makes no assumptions about the traffic patterns occuring * on the input streams and ensures that no input stream will be starved by busy siblings. * It guarantees that if an input stream has data pending, no other stream will be * serviced twice before that data is serviced. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1int * The input streams. *
Output Channels
outint * The multiplexed output stream. *
*

Example

* The following example shows how to use Plex2Int in a small program. * The program also uses some of the other plugNplay processes. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class Plex2IntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new FibonacciInt (a.out ()),
 *         new SquaresInt (b.out ()),
 *         new Plex2Int (a.in (), b.in (), c.out ()),
 *         new PrinterInt (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* Note: this example does not produce easily understandable output, since * the multiplexed stream contains only numbers -- there is no indication * of the streams from which they were sourced. To get that indication, * we can either use {@link MultiplexInt} or sign each int * stream to be multiplexed with {@link SignInt} and multiplex with * {@link org.jcsp.plugNplay.Plex2}. *

*

Implemntation Note

* For information, here is the run method for this process: * *
 *   public void run () {
 *     AltingChannelInputInt[] input = {in0, in1};      // in0 and in1 are the input channels
 *     Alternative alt = new Alternative (input);
 *     while (true) {
 *       out.write (input[alt.fairSelect ()].read ());  // out is the output channel
 *     }
 *   }
 * 
* * @see org.jcsp.plugNplay.ints.PlexInt * @see org.jcsp.plugNplay.ints.MultiplexInt * * @author P.H. Welch */ public final class Plex2Int implements CSProcess { /** The first input Channel */ private final AltingChannelInputInt in0; /** The second input Channel */ private final AltingChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new Plex2Int process with the input channels * in0 and in1 and the output channel out. * The ordering of the input channels makes no difference * to the behaviour of this process. * * @param in0 an input channel * @param in1 an input channel * @param out the output channel */ public Plex2Int(AltingChannelInputInt in0, AltingChannelInputInt in1, ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { AltingChannelInputInt[] input = {in0, in1}; Alternative alt = new Alternative(input); while (true) out.write(input[alt.fairSelect()].read()); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/ProcessReadInt.java0000644000000000000000000001140111105701167021616 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Reads one int from its input channel. *

Process Diagram

*

*

Description

* ProcessReadInt is a process that performs a single read * from its in channel and then terminates. It stores * the read int in the public value field of * this process (which is safe to examine after the process * has terminated and before it is next run). *

* ProcessReadInt declaration, construction and use should normally * be localised within a single method -- so we feel no embarassment about * its public field. Its only (envisaged) purpose is as described in * the example below. *

Channel Protocols

* * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
*

Example

* ProcessReadInt is designed to simplify reading in parallel * from channels. Make as many instances as there * are channels, binding each instance to a different channel, * together with a {@link org.jcsp.lang.Parallel} object in which to run them: *
 *   ChannelInputInt in0, in1;
 *   .
 *   .
 *   .
 *   ProcessReadInt read0 = new ProcessReadInt (in0);
 *   ProcessReadInt read1 = new ProcessReadInt (in1);
 *   CSProcess parRead01 = new Parallel (new CSProcess[] {in0, in1});
 * 
* The above is best done once, before any looping over the * parallel read commences. A parallel read can now be performed * at any time (and any number of times) by executing: *
 *     parRead01.run ();
 * 
* This terminates when, and only when, both reads have completed -- * the events may occur in any order. The values read may then * be found in read0.value and read1.value, where they * may be safely accessed up until the time that parRead01 is run again. * * @see org.jcsp.lang.Parallel * @see org.jcsp.plugNplay.ProcessRead * @see org.jcsp.plugNplay.ProcessWrite * @see org.jcsp.plugNplay.ints.ProcessWriteInt * * @author P.H. Welch and P.D. Austin */ public class ProcessReadInt implements CSProcess { /** The int read from the channel */ public int value; /** The channel from which to read */ private ChannelInputInt in; /** * Construct a new ProcessReadInt. * * @param in the channel from which to read */ public ProcessReadInt(ChannelInputInt in) { this.in = in; } /** * The main body of this process. */ public void run() { value = in.read(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/DeparaplexInt.java0000644000000000000000000001422511105701167021500 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This demultiplexes data from its input channel to its output channel array. * *

Process Diagram

*

*

Description

* DeparaplexInt is a process to convert the single stream of * int[] packets sent from a {@link ParaplexInt} process on the other * end of its in channel back to separate streams (its out * channels). It assumes that {@link ParaplexInt} operates on the same * size array of channels as its out array. It conforms to * contract required by {@link ParaplexInt} for a process receiving its packets. *

* In each cycle, it inputs one packet and outputs its contents in parallel * to each of its output channels. * The parallel output means that the process will wait until each item is accepted * by every channel -- in whatever order is demanded by its environment. * The ordering of the channels in the out array, therefore, makes * no difference to the functionality of this process. * *

Channel Protocols

* * * * * * * * * * * * * * * * *
Input Channels
inint[] * A packet carrying the paraplexed data. *
Output Channels
out[]int * Most channels in this package carry integers. *
* *

Example

*
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class DeparaplexIntExample {
 * 
 *   public static void main (String[] args) {
 * 
 *     final One2OneChannelInt[] a = Channel.one2oneIntArray (3);
 *     final One2OneChannel b = Channel.one2one ();
 *     final One2OneChannelInt[] c = Channel.one2oneIntArray (3);
 *     final One2OneChannel d = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a[0].out ()),
 *         new SquaresInt (a[1].out ()),
 *         new FibonacciInt (a[2].out ()),
 *         new ParaplexInt (Channel.getInputArray (a), b.out ()),
 *         new DeparaplexInt (b.in (), Channel.getOutputArray (c)),
 *         new ParaplexInt (Channel.getInputArray (c), d.out ()),
 *         new CSProcess () {
 *           public void run () {
 *             System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n");
 *             while (true) {
 *               int[] data = (int[]) d.in ().read ();
 *               for (int i = 0; i < data.length; i++) {
 *                 System.out.print ("\t\t" + data[i]);
 *               }
 *               System.out.println ();
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.ints.ParaplexInt * @see org.jcsp.plugNplay.ints.MultiplexInt * @see org.jcsp.plugNplay.ints.DemultiplexInt * * @author P.H. Welch */ public final class DeparaplexInt implements CSProcess { /** The input Channel */ private final ChannelInput in; /** The output Channels */ private final ChannelOutputInt[] out; /** * Construct a new DeparaplexInt process with the input Channel in and the output * Channels out. The ordering of the Channels in the out array make * no difference to the functionality of this process. * * @param in the input channel * @param out the output Channels */ public DeparaplexInt(final ChannelInput in, final ChannelOutputInt[] out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessWriteInt[] outputProcess = new ProcessWriteInt[out.length]; for (int i = 0; i < out.length; i++) outputProcess[i] = new ProcessWriteInt(out[i]); Parallel parOutput = new Parallel(outputProcess); while (true) { int[] data = (int[]) in.read(); for (int i = 0; i < data.length; i++) outputProcess[i].value = data[i]; parOutput.run(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/FibonacciInt.java0000644000000000000000000001132511105701167021266 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This generates the Fibonacci sequence on its output channel. * *

CSProcess Diagram

*

External View

* *
 *         ______________  
 *        |              | out
 *        | FibonacciInt |------>
 *        |______________|
 * 
*

Internal View

* *
 *         _______________________________________
 *        |                                       |
 *        |  _______________       ___________    |
 *        | |               |     |           |   | out
 *        | | {@link PrefixInt PrefixInt (0)} |-->--| {@link Delta2Int Delta2Int} |------>-- 
 *        | |_______________|     |___________|   |
 *        |        |                    |         |
 *        |        ^                    v         |
 *        |  ______|________       _____|____     |
 *        | |               |     |          |    |
 *        | | {@link PrefixInt PrefixInt (1)} |--<--| {@link PairsInt PairsInt} |    |
 *        | |_______________|     |__________|    |
 *        |                                       |
 *        |                          FibonacciInt |
 *        |_______________________________________|
 * 
*

*

Description

* FibonacciInt generates the sequence of Fibonacci * numbers on its output channel. *

Channel Protocols

* * * * * * * * * *
Output Channels
outint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public final class FibonacciInt implements CSProcess { /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new FibonacciInt process with the output Channel out. * * @param out the output channel */ public FibonacciInt(final ChannelOutputInt out) { this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannelInt a = Channel.one2oneInt(); final One2OneChannelInt b = Channel.one2oneInt(); final One2OneChannelInt c = Channel.one2oneInt(); final One2OneChannelInt d = Channel.one2oneInt(); new Parallel(new CSProcess[] { new PrefixInt(1, c.in(), d.out()), new PrefixInt(0, d.in(), a.out()), new Delta2Int(a.in(), b.out(), out), new PairsInt(b.in(), c.out()) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/RegularInt.java0000644000000000000000000000751411105701167021017 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This process generates a constant stream of Integers at a regular rate. *

Process Diagram

*
 *    ________________
 *   |                | out
 *   | RegularInt (n) |-->--
 *   |________________|
 * 
*

Description

* This process generates a constant stream of Integers at a regular rate * – at least, it does its best! * If the consumption of data is less than the set rate, that rate cannot be sustained. * If the consumption failure is only temporary, the set rate will be restored * when consumption resumes. *

* The interval (in msecs) defining the output flow rate is given by a constructor argument. *

Channel Protocols

* * * * * * * * * *
Output Channels
outint * A constant value is sent down this channel at a regular rate. *
* * @see org.jcsp.plugNplay.ints.FixedDelayInt * @see org.jcsp.plugNplay.ints.RegulateInt * * @author P.H. Welch */ public class RegularInt implements CSProcess { final private ChannelOutputInt out; final private int n; final private long interval; /** * Construct the process. * * @param out the output channel * @param n the value to be generated * @param interval the interval between outputs (in milliseconds) */ public RegularInt (final ChannelOutputInt out, final int n, final long interval) { this.out = out; this.n = n; this.interval = interval; } /** * The main body of this process. */ public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read (); // read the (absolute) time once only while (true) { out.write (n); timeout += interval; // set the next (absolute) timeout tim.after (timeout); // wait until that (absolute) timeout } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/DemultiplexInt.java0000644000000000000000000001037511105701167021711 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This demultiplexes data from its input channel to its output channel array. * *

Process Diagram

*

*

Description

* DemultiplexInt is a process to convert the single stream of * ints sent from a {@link MultiplexInt} process on the other * end of its in channel back to separate streams (its out * channels). It assumes that {@link MultiplexInt} operates on the same * size array of channels as its out array. *

* The protocol on the incoming multiplexed stream consists of * an int, that represents the channel identity of the * multiplexed data, followed by the multiplexed data. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint, int * An in message is an index followed by the multiplexed data. *
Output Channels
out[]java.lang.Object * All channels in this package carry integers. *
* * @see org.jcsp.plugNplay.ints.MultiplexInt * @see org.jcsp.plugNplay.ints.ParaplexInt * @see org.jcsp.plugNplay.ints.DeparaplexInt * @author P.H. Welch and P.D. Austin */ public final class DemultiplexInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channels */ private final ChannelOutputInt[] out; /** * Construct a new DemultiplexInt process with the input Channel in and the output * Channels out. The ordering of the Channels in the out array make * no difference to the functionality of this process. * * @param in the input channel * @param out the output Channels */ public DemultiplexInt(final ChannelInputInt in, final ChannelOutputInt[] out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) { int index = in.read(); out[index].write(in.read()); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/PlexInt.java0000644000000000000000000001273511105701167020327 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Fair multiplexes its input integer stream array into one output stream. *

Process Diagram

*

*

Description

* PlexInt is a process whose output stream is a fair multiplexing * of its input streams. It makes no assumptions about the traffic patterns occuring * on the input streams and ensures that no input stream will be starved by busy siblings. * It guarantees that if an input stream has data pending, no other stream will be * serviced twice before that data is serviced. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in[]int * The input streams. *
Output Channels
outint * The multiplexed output stream. *
*

Example

* The following example shows how to use PlexInt in a small program. *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class PlexIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt[] a = Channel.one2oneIntArray (3);
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a[0].out ()),
 *         new FibonacciInt (a[1].out ()),
 *         new SquaresInt (a[2].out ()),
 *         new PlexInt (Channel.getInputArray (a), b.out ()),
 *         new PrinterInt (b.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* Note: this example does not produce easily understandable output, since * the multiplexed stream contains only numbers -- there is no indication * of the streams from which they were sourced. To get that indication, * we can either use {@link MultiplexInt} or sign each int * stream to be multiplexed with {@link SignInt} and multiplex with * {@link org.jcsp.plugNplay.Plex}. *

*

Implemntation Note

* For information, here is the run method for this process: * *
 *   public void run () {
 *     Alternative alt = new Alternative (in);       // in is the input channel array
 *     while (true) {
 *       out.write (in[alt.fairSelect ()].read ());  // out is the output channel
 *     }
 *   }
 * 
* * @see org.jcsp.plugNplay.ints.Plex2Int * @see org.jcsp.plugNplay.ints.MultiplexInt * * @author P.H. Welch */ public final class PlexInt implements CSProcess { /** The first input Channel */ private final AltingChannelInputInt[] in; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new PlexInt process with input channels * in and output channel out. * The ordering of the input channels makes no difference * to the behaviour of this process. * * @param in the input channels * @param out the output channel */ public PlexInt(AltingChannelInputInt[] in, ChannelOutputInt out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { Alternative alt = new Alternative(in); while (true) out.write(in[alt.fairSelect()].read()); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/IdentityInt.java0000644000000000000000000000726411105701167021211 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This copies its input stream to its output stream unchanged. *

Process Diagram

*

*

Description

* This is a process that simply copies its input stream * to its output stream. The difference between a channel and a channel * into which an IdentityInt process has been spliced is that the * latter has a buffering capacity of one more than the channel * (which is zero, unless explicitly constructed with a buffer). *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public final class IdentityInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new IdentityInt process with the input Channel in and the * output Channel out. * * @param in the input Channel * @param out the output Channel */ public IdentityInt(final ChannelInputInt in, final ChannelOutputInt out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) out.write(in.read()); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/MergeInt.java0000644000000000000000000002056211105701167020453 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Merges an array of strictly increasing int input streams into one * strictly increasing output stream. *

Process Diagram

*

*

Description

* MergeInt is a process whose output stream is the ordered merging * of the integers on its input streams. It assumes that each input stream is * strictly increasing (i.e. with no repeats) sequence of integers. * It generates a strictly increasing output stream containing all -- * and only -- the numbers from its input streams (eliminating any duplicates). *

* Warning: this process assumes that its input channel array has at least * two elements. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in[]int * Assume: in.length >= 2. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows how to use MergeInt in a small program. * The program also uses some of the other plugNplay processes. The * program prints, in ascending order (up to Integer.MAX_VALUE), all integers * whose prime factors consist only of 2, 3, 5 and 7. Curious readers may like * to reason why the infinitely buffered channels are needed. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.ints.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class MergeIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt[] a = Channel.one2oneIntArray (5);
 *     final One2OneChannelInt[] b = Channel.one2oneIntArray (4, new InfiniteBufferInt ());
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 *     final One2OneChannelInt d = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new MultInt (2, a[0].in (), b[0].out ()),
 *         new MultInt (3, a[1].in (), b[1].out ()),
 *         new MultInt (5, a[2].in (), b[2].out ()),
 *         new MultInt (7, a[3].in (), b[3].out ()),
 *         new MergeInt (Channel.getInputArray (b), c.out ()),
 *         new PrefixInt (1, c.in (), d.out ()),
 *         new DeltaInt (d.in (), Channel.getOutputArray (a)),
 *         new PrinterInt (a[4].in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
*

*

Implementation Note

* The implementation sets up a balanced binary tree of parallel * Merge2Int processes to fan-in the merge from * its external input channels to its external output. It's a nice * example of recursion and parallelism -- here's the run * method: *
 *   public void run () {
 *     final int n = in.length;  // deduce: n >= 2
 *     switch (n) {
 *       case 2:
 *         new Merge2Int (in[0], in[1], out).run ();
 *       break;
 *       case 3:
 *         final One2OneChannelInt c = Channel.one2oneInt ();
 *         new Parallel (
 *           new CSProcess[] {
 *             new Merge2Int (in[0], in[1], c.out ()),
 *             new Merge2Int (c.in (), in[2], out)
 *           }
 *         ).run ();
 *       break;
 *       default:  // deduce: n >= 4
 *         final int n2 = n/2;
 *         ChannelInputInt[] bottom = new ChannelInputInt[n2];
 *         ChannelInputInt[] top = new ChannelInputInt[n - n2];
 *         for (int i = 0; i < n2; i++) {
 *           bottom[i] = in[i];
 *         }
 *         for (int i = n2; i < n; i++) {
 *           top[i - n2] = in[i];
 *         }
 *         final One2OneChannelInt[] d = Channel.one2oneIntArray (2);
 *         new Parallel (
 *           new CSProcess[] {
 *             new MergeInt (bottom, d[0].out ()),
 *             new MergeInt (top, d[1].out ()),
 *             new Merge2Int (d[0].in (), d[1].in (), out)
 *           }
 *         ).run ();
 *       break;
 *     }
 *   }
 * 
* * @see org.jcsp.plugNplay.ints.Merge2Int * * @author P.H. Welch */ public final class MergeInt implements CSProcess { /** The input channels */ final private ChannelInputInt[] in; // assume: in.length >= 2 /** The output channel */ final private ChannelOutputInt out; /** * Construct a new Merge2Int process with the input channels * inand the output channel out. * The ordering of the input channels makes no difference * to the behaviour of this process. * * @param in the input channels (there must be at least 2) * @param out the output channel */ public MergeInt(ChannelInputInt[] in, ChannelOutputInt out) { if (in.length < 2) { throw new IllegalArgumentException ("Merge must have at least 2 input channels"); } this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final int n = in.length; // deduce: n >= 2 switch (n) { case 2: new Merge2Int(in[0], in[1], out).run(); break; case 3: final One2OneChannelInt c = Channel.one2oneInt(); new Parallel(new CSProcess[] { new Merge2Int(in[0], in[1], c.out()), new Merge2Int(c.in(), in[2], out) }).run(); break; default: // deduce: n >= 4 final int n2 = n/2; ChannelInputInt[] bottom = new ChannelInputInt[n2]; ChannelInputInt[] top = new ChannelInputInt[n - n2]; for (int i = 0; i < n2; i++) bottom[i] = in[i]; for (int i = n2; i < n; i++) top[i - n2] = in[i]; final One2OneChannelInt[] d = Channel.one2oneIntArray(2); new Parallel(new CSProcess[] { new MergeInt(bottom, d[0].out()), new MergeInt(top, d[1].out()), new Merge2Int(d[0].in(), d[1].in(), out) }).run(); break; } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/PrinterInt.java0000644000000000000000000001224011105701167021031 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; import java.io.*; /** * Prints each int from its input channel to a PrintStream. *

Process Diagram

*

*

Description

* PrinterInt is a process for printing each int from its * in channel to a PrintStream object (by default, * System.out). *

* For convenience, PrinterInt may be configured with prefix and postfix * strings with which to decorate its output. * *

Channel Protocols

* * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
* *

Example

* See the example in {@link MergeInt}. * * @see org.jcsp.lang.Parallel * * @author P.H. Welch and P.D. Austin */ public class PrinterInt implements CSProcess { /** The channel from which to read */ private ChannelInputInt in; /** The stream to which to write */ private PrintStream printStream; /** The string to write in front of each integer */ private String prefix; /** The string to write after each integer */ private String postfix; /** * Construct a new PrinterInt with System.out as * its PrintStream and empty prefix and postfix strings. * * @param in the channel from which to read */ public PrinterInt(final ChannelInputInt in) { this(in, System.out, "", ""); } /** * Construct a new PrinterInt with System.out as * its PrintStream. * * @param in the channel from which to read * @param prefix the string to write in front of each integer * @param postfix the string to write after each integer */ public PrinterInt(final ChannelInputInt in, final String prefix, final String postfix) { this(in, System.out, prefix, postfix); } /** * Construct a new PrinterInt with empty prefix and postfix strings. * * @param in the channel from which to read * @param printStream the stream to which to write */ public PrinterInt(final ChannelInputInt in, final PrintStream printStream) { this(in, printStream, "", ""); } /** * Construct a new PrinterInt. * * @param in he channel from which to read * @param printStream the stream to which to write * @param prefix the string to write in front of each integer * @param postfix the string to write after each integer */ public PrinterInt(final ChannelInputInt in, final PrintStream printStream, final String prefix, final String postfix) { this.in = in; this.printStream = printStream; this.prefix = prefix; this.postfix = postfix; } /** * The main body of this process. */ public synchronized void run() { while (true) { printStream.print(prefix); printStream.print(in.read()); printStream.print(postfix); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/0000755000000000000000000000000011410045054017731 5ustar jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/MultiplexInt1.gif0000644000000000000000000000467010520670125023152 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìú40áàghö€Òµ‚ö±‹Îlà—¡ò™Ï,ÓúÔ>‡jxÚü:S?ÖáÏ6;CÀk  ÄîwËÒ]oÂã!•XoL(L¡ WȺð…(À´2Ò5·©¤8SsYÒl³¼ãܯ8ï3ÿ8ó=Ã䎀‰ ÁÙºDx  `À‹´-' lHq.³,¾< ßq~GEêi(ŒöPËÐxvl‰Ó’ƒw¾œl IT¤P"¸¼I¦o˜@8З g‚«M ÿU8T@&ðcÑ&0œ?JFp|ܯä‘}7ËI„ìEŽ< Š %N̻ǔÒX{TÕ+ËSÍ’Wµ$Õ-s•ËPír'5Ä¢*áõK\'½ôT1a•ÌM-³UÍ´Ô3UÍIMóTÕ\Ô5I•MDm3TÝ Ô7=N?S&ÁDæ0ÛuΘó&åóUœ‚çŸ<ý×G $§Úårîƒé:ÕeÖºXhéO×z¯¬òªw¨LHŠdD×}Ùõª‘êkÃþú3 ˜‰¬=jë…2Ô€!öFŠ¥P‡ÔØÀ6² * ûXa¶"B‚¡hGKÚÑ  L—%lÍ4Û$<@}Ñg÷3Y×+¶,š-~&`[]U·ë©À°|Rà†·$2.(S X‡ 7DÊÕ£`)¦Ú>÷BÑ]Ðu)”ÝT2·¹Úš®ÆªûÐí.¨»û1/‚Ð{<ñ¢Œ¼Uï~Ø»žt° xbØé¿°€LàØM¤ö« €éÁް„'Lá [K È+ƒ7Ìá{øÃ ±ˆGLâ¯% ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/FibonacciInt1.gif0000644000000000000000000000372210520670125023041 0ustar GIF89að÷ $$$000888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,ðÿEH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³fD rêÜɳ§ÏŸ@ƒ J´¨Ñ£B'Ø$IàÒ§P£JJÕç‚!–‚Ì`@«W’ ”~å˜s¬YeÏfL«¶­E¶n)ÂK×áܺïâÝkP/_…~ÿò ,¸/„ˆN¬ø0cÁ‹G~lv2bË”½b†ì83ÞÍA{¦)zoéÑ1O×UÚ%븯[¯ŒÝ–¶l”¶Ïæ¾]r÷Xß¼E×Ü9øïâ­‡G‹µòåd›~]#õš×«_Ì>“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzŠ‘/¾(€€j—"Ep¨«6éÿ¸¨¤l Àeޤ¤’E$˜tUªJŒ9PeòJ³1;,¤ÐŠðAµ×»Á£JnBÃ:,É*Bˆ|ÉòÊ,¼&iëdúø#™\ ‘âÚJäöþ00þš¬t&9í€qYé®K«E¶> o³T‘ ŸvR)ˆ rDf°(‹ òÇLä–l¼0Ãnq`1Äê.Äî®Îbü®®8^Ù«˜"øi/Á›%ÓÝÂk3K ìlõÕXg­õÖ\wýp0ôó³;2Ç|™+¼" -€"8PeÚ8ð1½uà 5ŒeNÿMl\Xë{W”,Ùñ¾}ïÆ šÁÑs f•â.pxå‡ÿ3¾@Y@»…ŃÛU8E¤´*ª5«yÁ‹ ¯ê2ŒD A©Žü⣺Gð(¬À*û‹¬æyºJì{³ØÇÊ<] ,O¸ó 6¯›õÔç‡ýqÙGj÷-nÿ•¹É‰Oøš¯ùΩ¿ûÓ¹«üÙÃ_ýÔÛ‘þöáßÿŸâŸzÐG#¦Æ€‰ éè¡!O œ£ó½ šè®Áà—"ø< º©‚Ä}¦Á&>!TSX‘&Ä…Z! 'ÃÔð3% Ý i˜ÃýôðC7ôÏ·'D‚ñNÜa ‡¸)%ë6GD™( (ˆŠ ÂbõœÈCrQ‚Süâþ´8+ªÅŠf¼žňÂ$²qn|cÃ(Ç9Ê&•!£÷êHÂ5òшz ßÛHÇAÚ0 ‘ ‰¨I6!HW&IÉJZò’˜Ì¤&7ÉÉNzò“  %'+Þñ† 0€*WÉÊVºò•°Œ¥,gIËZÚò–¸œe4ÀÈ^úò—À ¦0‡IÌbz% ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/SquaresInt1.gif0000644000000000000000000000370610520670125022611 0ustar GIF89að÷ $$$000888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,ðÿEH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³fD rêÜɳ§ÏŸ@ƒ J´¨Ñ£B'Ø$IàÒ§P£JJÕç‚!–‚Ì`@«W’ ”~å˜s¬YeÏfL«¶­E¶n)ÂK×áܺïâÝkP/_…~ÿò ,¸/„ˆN¬ø0cÁ‹G~lv2bË”½b†ì83ÞÍA{¦)zoéÑ1O×UÚ%븯[¯ŒÝ–¶l”¶Ïæ¾]r÷Xß¼E×Ü9øïâ­‡G‹µòåd›~]#õš×«_Ì>“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzÚQ/J’˜Ô%ˆ¢®ÖªF[úÿ%Ig„€šñ½ÊR ºT+•}d])Æv°A²4+‚° ´lÙ,´"léÀª¹Ò•@bAÄß  Pm>Ö @bŠà@d>"Ð#½ùã¬gÒK¯ ©¤kº®d€+nÁQ™¤t¹ºìVIÁ"K/ q» ÐAAö+{F`'«tq€0 ¿Ç°E;hS,B»~¦k%–$‰½8 @’0ö;§º¸²¤ÀËPG-õÔTWmõÕWÀCüñ)Ж/p¬ÎÀzìn•µš-,™Œ6–i«|ãy3£äAÔ»ï^ÿùãÎ,o{`t•?Šù¶@TeâJÿœ%¤Ê’ŽaðrÞêÁD ¤*A(yAd£ê ªŽé/FÐ%ì°ï|èè¦v×òêmWÝ *] ß¹W”.‡ù[ÄšÐóQï\ô_Y?öÄIß ÷Zi/øK‰Ïù6™oúرï½úË{ߢûÝÑÿ)üÃËáñúkhjÿKþdÖ?ÿñ¯€N: M@–-0: | Fȵ¶‰‚{³à—0H 20‚¬ž/7Âqpz%dÑ ó“­ð /üL  ÎpS5´!s‘úç†ò!A«„x§qAGü¡·Ã%æÏˆNìÕmˆˆ¨)&ñAWÜ_Ë“Åùm‘‹Mü" Ã(FvÑ€e|¢Ó¨FÙP1SPdcÉ(ÇÆÐ±Žo|£ZòxFõÑ#`@ò€¦¡&àÊ€"ÉÈF:ò‘Œ¤$'IÉJZò’˜œd-Þp`¥(GIÊRšò”¨L¥*WÉÊVºò•ªL€IËZÚò–¸Ì¥.wÉËà;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/OrInt1.gif0000644000000000000000000000416210520670125021543 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú ’Ó^pPb áëΞêì¸âŠkÐr-°íND{„FsÔ±y}y@‚Ö¼‚œ\ï½CçʘÝ]ÕU°]fñ†k@×%mç>SÔeÿ aÚò±­‘¿n@_ò"`  ¼±wf}0#àé žÑoÃ[^â¾ç0j3†.ú褗núé¨ÿ àÚ!Ï41Ö›_×¹ãzï­¶N!„¾mÕYž‘kvƒ»r³ÿ6wÙfmÐáîïùž°|² | 4ÐÔ'XAõÈ_Ág¼WÞzµ|sô@øì9ofù’ª?&ûº¿%üŒÊ%ý‰Ú%þ†êï$ÿƒòß(†ˆ€}2 †¨'^ˆwràƒ H' 2ˆ‚q²`0è& ˆƒkò @h&c2!~PX­%Dx¥Ÿ®X(t$eáÂL€d&ªÛ©*l¹˜ÿ܆>ƒñð.>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú|Ô&Ï&øŒ¾7áì©ÎMfòBäoÓ-°-MF{„HW¤4 .'Ûc € ‚' ÂÓ¼…=öÉõÞ[t®<1PÜÝeM‘¿âÊëZc}!ÿ n¸]‡®¼~ûmçNÍÝ:e áÜòÙ=‘¿NÀÛd¯ß$ü5A\·¹rtœÃ6UÝÑ3Bžžä= oÞ Þ4pO›€¶r¾¾1NÍ(üðÄoüñÈ'@Ö2KO“`ª Œ>ï´œ /á½üûÛf… ü´U{D¹ƒ^=xßα¸Ùk/ðoÀlã9mÐ!úïYD€&Ÿñ¬g#Ð& ³U@ÁñÙT’ï*øLú^÷¼j©Ž#Ø {h¦JŠ„c2á£P¸%2Š…Xra¢`%ІN²á px#Ї!òaŸÿ€¨!!ꉈ2âø %Ò‰‰ rbœ X )º‰Š²âš°è-š‰‹ûñâ˜Àˆ1VÇD;BÆú˜Q:è*HÊÂÅ4îÈì.ü;Ùr1€N„»# –Ì®/a3ÁÂ$H¼9…D€\C›åر‘ŽÌ#© œçø Äd& œì 瓥꠮YNì]ÖxIL²R7,bR—¥f–Œlä-CÔFù SCÅ|Ï1/”Lö,S>hR3ÓóÌ÷(­ š&xªÉÖI›Ö%ªÄy›Úì7+!å¹óð|§jDÎu‚ÇœÀD¨ÎêØ³;ÞÔgÙú)Vg%A‘cPéT l Uå­9‰ÒŠ¢´h¬0:B¾Š£¬§&ÉNQ‚< -ÎI'R’6$¥ºY©ú<ª*™J¦·±)rpz‡§¤ñ©nÐr2àj.]ˆ`¤¦:õ©PªT§JUa``JªB*£®zõ«` «XÇJV1”ZM«Z×ÊÖ¶ºõ­p«\纖€;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/DynamicDeltaInt1.gif0000644000000000000000000000544110520670125023522 0ustar GIF89a<÷ $$$(((000888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿQH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O#*PJ´¨Ñ£H“*]Ê´©Ó§P£2Åpâ§Õ’ Lʵ«×¯`Ã"}àªÙ 6œ]ëA¶p1·®Áìê…8w¯^¼7IT XÁ€ €¢ða¿ ûBŽ Ø¦„+Pp@€˜¼P2鵕S>PÐ@Š >xÐÙÀƒ…QˆðŒ‚5 ¢O'4-üj꓊+<0 Ø€ÀÍ _ÀíøèÍ¿ƒ7H|»ÏãXxÿh BîÞ˜/gÎ~³uï»Ãß žä{åÏcWO=ûxì÷͇‚|âTI¶½&^aˆ©w™kgLà|hÓ#QhØ`$¶Yl [„Ρˆ]_†ÒÄaMç DÂ@.zcŒ2ÍHS<–™vîÈ#L>Îdb-9š†FéR’7… å@Q^¹•61ÐÀ“Gf©¥jy]…|&]cÊX¦UÀ¡™&˜E²Ù¦L °Àž|öé矀*è „* §œ XYç39 F*餔Vj饘fºÁ¡ð&†v2ú—5} §§<Š)êH¤þØé§P†ÿº*K­ÎĬ1ª:+HµîÊ’®¾vÔk°)K¬FÃk’±Ê^”l³#1 -EÏ+Âh ˜ð‘´ÓJTm°¹â`qÛ-D­ÞØlaÚ‚ nGæžë©0pd‰& „/c ,f˜…‰ß`ˆèÜy ÄvYy+æ‹P¼ò2Dj t X¤pP¢VÜ&”hBÁ£1 À$(ÖXŠû)àn…&(pÛAG¬Ð·ða7PyϹ\nš—"Ð,§7Xh—ø°¬6s„³w:¶XÏïMžÐ¼rÏ«èbcÉtÓÈâºjgæy¶\@fPõÁ)–b;×ÙBˆxÿ óÒdô´wlF®›M'‚®ÁöÚ‰ LÇÌZ£Ð€Ìfùt(Lþ7à kvè->Ør¡ÌÝØ¤W4¸²øADÁ»²ÞúD¯ïnPhÚ®n;“ B¾?t¡Â¿ûÄa_å§ÔWoýõØg¯=õ {òõ¾@ËúÀη.þøÀ£y¾@链>ø@¾/öøÍŸ¼LǺþø#ˆÿÀÂï{LH 8@²y |H›½J,ÈØ@˜çîòÞróx z(ð ¶RHBÎd…¼]+Ò@àÆ0³ãHÂb(Ã3yOÿÈUdˆ"Ù þj€ÁÄÌK‘ D „°EWÄ–k®…E1©7) ¹¾h¤iëZO­x#3†D‰ãc"¹¦×¯é„fq 3€BtÃk]ÆPËQv<”/•qM1ê±N‚T ü0Mè#"=°HžÅp†‘c‹šˆËÑ!ª€ C œÙ©'7Øñ@fH0^Š&¨u€s4 u©„")›˜DbR"šdÏŠDP¡Hvm5†òXpNéœýŒQšJô%Ñвsˆl&ftVžk¾Ñ—¿ä )âÍåÜha\XaHKe– 3¨LÏmD '¶È6•ËÖ,y9ÿ5­¥ˆÝäå7r¼pgœ±¡búH³<É\ßÃÌH:r5Íü¡b0EÛ4”­ÐeInF:mÅØ/Ò ¡ñ y*!¯åp„O =p¨°1ÓñÀ`pʶ ܨ„æÉ! „Zñüt§B½€D9Bœ6õ5W½¤A òS‡Lð …K‘¯à¨¬ÅQQØŒ-Ag’Ë­u¬àÌà>Ñj˜ƒnUqµà>ÇS£ÕÝ!d=Ö>GÓ×øÀ4ƒ%Ö`·ÆÖ¿$±ÁjiKûRÇÞ%¯¿à/?PYË>³+ g Ö‚•—©@Úûyv ©=W ÕÚ¯ÿF,¶,ù¡vËÛÞú–Oà¼÷ZØbÖ.'È”r—ËÜæF*¸§Â€må…Ûi º,®lŽ»Õ3¡ÊµÅ­.´ €«éžëÅ5o·*øZõNK¼Ms/´ª+˜ÌI! Œc\zù6«ºüA÷ÖP'†fÀ“ñ¯²(‚ËÍÌq·¤MfÆØ!^î™ø)щ*íÞ’»™[áàY´èEä‘Ý"kºÔ®±'VÖßy訟ôÅøá—hºBKæh; >–ŒSdãçÆŒå™" ó$søE§ þ¦7Ô1¨_6®iÐ^\'#2A&“±½‰È7ÔìO×&Ûå Ùÿ/a|ב'Îp îË€½y/xÞÕœâ$ˆÆÚ´¼=+ECĨZbôªýOJ’¥ÒàÝ.UQNà¦Ò>OãÊ6ÔöVÍêV³šŠêp¢A“R`(¢ÃKk˜túÖ¹uŒ{ýàZ×k¶Y,€lL‡Ú€£nV¦meMûNÕ>ÖµÛ”mbm{LÝÖ·µn_ûJåÞÕ¹¥”îY­ûHí^Õ»yoQÍ;FõfÔ½5”ï;%€³Úu€<ì $À¹O¸ÂÎð†7W¨ ÁrßZüâϸÆ7î[üyâ ¹ÈGNò’›üä(O¹Êá;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/PrefixInt1.gif0000644000000000000000000000424710520670125022424 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xîAYZÐÁ´ Q0ÁTJЧdï@ù ´A®­Ø+Bt¹kKì™0 Q@ )¿°¤›¦eÐÓ&ðNSm¦A,кý)±˜Š°$ !pI‚HŒ) úî§3Óù.ÌÂé²|³Á|z\T+˜l0Ê©l#¨j@Aœ `Á§{fš8œÏŸv=æp' q Ôu×,{±Ké‚„AÛMWÿf@ÛQ—L5Ar&œÖš‘2Œ6¨«¦‰& h°¬ÊV t·£ˆì”<·”÷G@ß %*ú騧®úꬷîzÛàôHj¶K*Î{.Ð5½ŒiæƒÚù¨•;Š1­ªv¬R¯7ïüóÏàAbˆÞôàé™ Ç<¦¾³­è÷ÃCZ¼Çcl&Êëö±N œ¾ÀÄ‚ À·~ØGŠqöZ¦Y3¤<ËT¢²€³ V£êšÆHÀ>¹©síCÉç<¢ÀÍï1¡#ÝÉf'’ 8‹ X–@äõA|ͬ^_ˆMhB:ëlZ—ʦÂe%€až{_N"à6ú¦(ÊßKÿ¾u˜l%ìÈ|!ºä $Hp˜ÃUĉÈI⃰X-*ˆ‹ÂñâÀø1ˆŒ¼1c€Ð˜5ú‡¶qã~à89⇎°±c}ðØ=ʇªñã{yA²‡¤1dzEš‡‘žqäx ¹I‚‡’˜±dw0YMj‡“’ñäu@ùQR‡”Œ1etP™U:‡•†qår`YY"‡–‚±eqpù] ‡—~ñåo€¹aò†˜x1fnyeÚ†™|Ñ¡ÃA9s6МË5a“M¸l³5Ý|Ë7UÎÁHsš)§ZÆyuš…¤qgYàÙÄjºˆžž‘§bΉŒNjõS øÜŒ>©PÌ ô'­ÌA!ÃÏÆž,J¨dÚ‰>†¢<±(c0j™†:”è×ÀBúQ‡„€Ø€JWÊÒ–ºô¥0©LgJÓšÚô¦8épÄ’*„ P€P‡JÔ¢õ¨HMªR—ÊÔ¦:õ©P]*8àÓªZõªXͪV·ÊÕ®zõ«­ ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/IntegrateInt2.gif0000644000000000000000000001300010520670125023075 0ustar GIF89aj<÷  $$$(((,,,000444888<<<@@@HHHPPPUUUYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÊÊÊÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,j<ÿ[H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£JJµªU†,8`ØÊµ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊK·®Ý»x편*0‚ y L¸°áÈ+^Ì/ |5TàK¹²åËM  ¸:æÏ C‹¦é@gÏ£S«^ÍZcéÓ­cËžM[àk«këÞÍ›òíª¹{ NéoªÁ‹+_Îüæñ©É›KŸNÝäs©Ñ«kßνâõ¨Ù»‹ÿOžàw¨áË«_?ýüÓôìãËïíÞ)üùøó³®ßô¾þÿ^ÆSþhàR ¸T6è q¦á†ÚƒV!lf¨!P *Åà† †ÈR‡I}(â‰(ŠD"R&¦èâ‹­xT‹0Öh£C2Eã<öh^„ÀMèãD"”cQ;©$ŠG•ä’PnØäPOFi%…S Uå•\˜eP[v)¦~_æ˜hÆWæOg¦é&ykúÔæ›tngOsÖ©§twò”瞀×çNj(oƒêT行ΖhN‹"‚Tj饘fªé¦œvêé§ †*ꨞnÀ…&P@ꪬ¶êê«°jÿzA %=ŠS¤y €"ôêë¯À+ì°Äkì±È&«ì²ÆN Áƒ(°³ÔVkíµØf+lœ:’­7áZ{5ˆ€ ^ƒl@¸6‰KfÂKœ¼Åmõ.È ½ Ú;¾Äéû-¿ÐùûÀ ,Áì"ÂØ)ìÃ^R ÄÂI’Ã2AŒ± óÆqoƒT2L"o°ÆÿÌ[Ê­üRËõ¬ŸÌ»Ñì‘Í.áü²ƒ<ëæsG@·$tÃ:çWtmGs”4KKgL´ÅÿE½ÑÔ+UMrÓø=M›Ö®M Ö ×±‰=Ù±’×k›-ŸÛ²Á£Ý¢ÿ½‘ÚÊÍÞ±é}‘à'Ñ8ßìÞšá!n’âÿIžšã¬Aîã,ú­à•s®æ«iN‘å$QN¦èå‘®šé¡>’êùÉšë©Á.‘í°®C´ãÇûg¸¦{DGŠBL0ü|ÃcV¼hÇC”ã üþîB hoÐóòEÙô¡UÿÐu'€?@¼ß÷p€»/ùÞÂt'@ùÔÄ:ò 4êÃÂRpï5 -x @|—@ €Ñß,Ђ ô\F@·º«9( yN |P‚ûË€Å× ®Ëƒ <ÈÙc>Ëð3(dˆ ÿYØÁB0†3Œ‰ ‹˜Ãñ‰#$¬ÅóCÌq!Ïq¡»&ÀÂ`Èö,°˜,±hbAv¸žV¦Š—¹¢B®³Bþ-üãâºøGC?=ñ"QÞ»GËÈ1!nÜÕ“H¾²2‡4Ò ÁôG‹z“ÜÎ#)Ƀ42#‹<ɘæµà  C¸‡”1'Ÿ”MÀ>ü•ªT¥A6à=°ò ®¬I' Ë‹j*0È%YRÁ"ÀaCôg<ªÑ&ÅdŠ\Fâñï8bApÈÀ>Îï\„ 5 bMab`_့ÂUɆT`Hæ@–¹ÿ’ ‚°œ8\AÊ(‚u¥ ”øÓ_ó6`Êÿ‘–™TÎ0n¶À›G cZpÐ Ð ‡¼` êÑù¹k…1lÁB €‡Îd˜éÓ yÒ¤P.>õÉO•øs¤Ùá4QJʦ4üKA©KlF´8,(ê2Œdƒ „S€ÃúÝ<€8ç§Î=¢3©KM%M`ú#ŽL4µiL •‚©Nu§=MIùN&•…bÖ÷ø>–à§ýìJU«NÐ{DôP³ÇQ®‚u õ[ž ûAľô㈠׆x±¨M­jWËÚÖºöµ:%€EiRÁÿ” ‡“!JAàE õ†ý N Ûâ÷¸ÈM®r—›ÜÔ“$b½ê÷,è¾É®Ëb½ìE°Ñß2ѳ2‰sÇKÞÕ]s}îBT€ÚŠæ%àìòÀ*ÐrÑ» nbõ£Æ–Ʊõ+èUzëîƒ÷µ@Ko‹ßà^&lHŸPÐÞÙM½ ]%à²÷ž$¾Âý¦#(V£žñƒLã~ó#U0 BÞ´[°þñ¯À!ö¹?»vÀ½­ýì’Ûæ© ]+Z“BaÀ‚jô°IVðàrõTÈmq[Ƽ·DžI6—âB| ›É–¯É`- ¤ÿÀ] ×<ç.YËan‰‘[Ч P•ž¹Àƒ¥<ž1+eg^cšÅ³ç>]ÀÂ3 %œwŽÉžçê:’º@†Þ…Üã¡y¼©^¾¢Lë«ùÏÌi´s9^×xÉÃ~ò˼éhï˜Ú‘Æö¹ì´:~°Ž¤¿ßý@NŸ á„vä9?ŽwP4 yÊÓý×#ÑÀ´ÅùÎ{þóÔÚ€T|ô¨O½ê9ÿÐêòÆ&ÉbEûX% µÏ}«&ðz…ºþ¨ üâ å‚=³wÃù5J5% €\Õ÷ôò¦ùÏ_Íÿ,¯›¸/$ñ,Á~ÿöGsZéïÆû ÿJÄ?þÐüoªÜ§ ú¢~•°¿ý˜9íTÍ_›ù‡ðú·—ñ~v²á:”wJqHúgWüG}ðF Ø€WQ $ "@ÐÕÇ2 ˜h|@!x3#ˆ%h‚V‚*8³ñ‚0H2ˆ(+xaxƒ–‘ƒç·ƒJÓ‚Gaƒ>@Ø}BH5DhFx„O‘„ Hƒ²ñ„PØR(KØ5MXVx…K‘…(v€`(bx€[¨õ—_x†H‘†±€NÔƒp8rØt¨hvx‡H˜‚:H…±ñ†~Hy¸k87]H„XˆBÿqˆ«±‡hÖ‡Žˆ…€„‚ØX‰?‰ª!‰˜µˆC±‰œØž˜ ?¢(¤XŠ;qŠ£‘еŠAÑŠ®˜°(²Ø†(a‹·x¹»H‹@á‹¿XÁÃH‰ÇXÉøËÈ|fØŒCñŒ˜ºaŒÔÖ( ‰ˆ¼xÚ¸/Ñ–µ1ŽäØæXèX†ëhˆ—¨„™Èê*ÑŽ¾ñ‰CŒ?qøˆúÈïXƒÓ¯8SH†‰@1WQUx‰i9ˆY‘6q‘U‘‘š¸‘II i"9’2Q’Sq’«* ,™ ü89þè0ÿ“1“Qá’ª‘“:É< >™@”1”OQ”£q”H‰JéL)Nù”•M1•¡Q•VIXÉZ \Ù•ñ•K–Ÿ1–d f©h‰j¹–Ñ–Iñ–——rÉty! 9‘y {yvixù— ˜F1˜•Q˜†yˆYŠIŒÙ˜ñ˜D™|1™”9–9˜yš¹™-ЙBñ™Vš›IšAašUš”©šR“%Ž&áš ›?ÁšTa›†‰›>¡›SÁ›é›=œR!œyIœä¤ei¤j¢FI¥Ýi 1ª¥sh¥!¡$a£ëC¦”¦3Ø—é–jêHXPêRê‚^JžqÊ¥á§#²§a¦#¦ ÿD¨¦(¦zˆ¨Æ4§6Á¨)$©Þi†º€ê„‚*Ÿ3§©Šˆ|J•ŸšŸ˜{G±©*Ñ©^xªÿé¨}:ª‘˜ª¡¨"a©Bd«Ó‡´ú‰¼*¸ºŠEÁ n¾Ú¦H uy¬ì–¬è¦! §²šÊš©ÌÊ—x‡¢¿ŠŠÎúà Å:Gߺp«Ú­±X® ®1®ˆ¤®rw®×ªªIJ­¡êŒèª‹ðú}”Zî*IÕª¬š®Êˆ°ú ‹‹ù*Œûš~ýJÿêI uÜ:¯Ë÷öº­ÐŠ‰ÒŠ’‹xÛ‹;Š«¢›u­ËÚÍš°¹°Ê˜² ÈŒÿ¹… µm¶ ueõJ ±e䳪dNЏ²Û²~!0}\³T|5VF *6NúU@Dѵ-áó…´ý¨´ôرô)PZ¶…#¦Rtt«J%@+€]svJ¸…c{Ûf^¤F ÀA>-¶<¸±iË´±áÏ£W¶µDF%àE t66+4d$¶F 0Yà§åµ B YkȦ,‹­³¡ O@Ñb`žµá”V$¶+`¸.ä³,$M\„N~EY÷·-Yë‚R)5„$ø¸K »³¡`|Øë¶;U pKAøÿCü`ÅPë_üÓe(&\Dåµ*żï+ác§½ök)  €—®¥:,°z«'Œ…»”[0Cºu¾º5U”[ñ«¼‡YpQðÛ`œÁ¾’|¯K¯JÂ^Ü‹L0FV¥À.TJdëÀ(¥`üf$·Kõ;ý“¸hR²ëá·+$\ÃPº_[J´RP46Pð;@´´-`Ä>+>7|¸€?hÄ‚n¢Ãêq #‹ñ=a'kìz¤Ô{%^L ´½Ç„YL³u˜&iìGqÜ¿>RÇšvÇj»$z¬(!›kxÜ# q|̸VRÈ·ÿÈê&Ç|HÇŽ¬%ŒýÓ€ÔB­'D]ÔtrÔHýÏù¶Ô©ÔN=&PÕ±|ÍT½ŽS}Õ ÏZYÝÕ~¬Ñ` %^¶t;b=ÖJ²NkôxQJC×ËÕjý"l=à5IdrM}-±V}×!²YãÛcit¹bB]Û@i´B#Vb•ÿ#Y;BtVFUÙHûÕ„Ô) `% `Õï3¢N+P?‡ÓR¦‹FÐ-µ¨}Q”Ù¢MÚ¶íRĔ֟Ý#'öÚ%UÀEÒR^ÛªTÙƒÜ[•ÙAØÁ=ØÃ!ÅíO dkåMOÜY•Û?Ý´eTVÇk¶žÝªQÜ¿Û Û»½AKuXD´B FÕ@"ð@ôÞ)ENþ]×ûìÞ.ÂJ¬„KJ•JíÓ@í¶]¼Ôà“Üë>ðà~Qï³àjÅáNÐÞ%Z5R@Ñ&gâ'~%ØÅ?D°ÂýâÔØÞ6~"8žã!²ã<.%²¬.?¾Ž'j¥wzœäJ¾äLÞäNþäPåR>å§£Ç"|÷»å\Þå^þå`æb>æd^æµG,>äj¾ælÞænþæpçr>çtÞ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/SquaresInt2.gif0000644000000000000000000001021310520670125022601 0ustar GIF89aT¥÷  $$$(((000444888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÂÂÂÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,T¥ÿUH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£JJÕ¡‡ X³jÝʵ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊK·.Û K4°Ë·¯ß¿€ L¸°áÃn Hôƒª#Kž\B¤X)kÞ̹3ÏÌGA{Mº´é¢‹¦>ͺµë×W• »¶íÛ’iÕ»·ïßFyÿ¼¸ñã4‰÷T޼¹óç"™ï”½ºõë©çÔŽ½»÷îÜo†ÿÿN¾¼ññ5Ñ›_Ïþµú™ïÛËŸÏ9~Lûôóë—ŠÿeÿýZ˜(àFö_K &èàƒðœ„VhálÕà…vÒ†*èáˆ$V$"J'–¨âŠ ¥h’‹,Æ#Œ$Ñ(ã#Ú]†8öècD:¢ÆãDyPiä’E"ù‘“LFi”Q)啨Y¹‘–Xvé—éå˜À‰y‘™d¦iš&*©æ›²I‘œpÖ9ái瞔陛|ºžŸ*è¡OÚt'`ÀÀ£F*餔Vj饘fªé¦‘6cJ¥Aœ–jꩨ¦)'0µªÆÿ*묨Z`‚CŠ2$|àë¯À+ì°Äkì±È&«,°<ðÀRÎz°ì´ÔVkíµÀF ÀR4À¶à†+®µêB¹¢ è@" à[ ´Š” œ{Û#$•B·öÖ€‹®»œÀ*dÁo””c¿1ðAR%ð›eØÁ+ÜØc¾9 ±Ä¾Q¬+ÁÓŒ±o /Ìqo#ñÄ—l1C'÷–òÆ ?ì2Ƚ‰¬îÌ ÕŒÛÍG1ܱÎG½rÌ?xñÁ(k\ôʸµœ4ϸùÜ"É:1'ômDe4ËH¥tÏLo ´B_ÛvQcW]vQggvBéªM3Ô6Kÿ-6Õ·Ym6Ö·i7×Û™Ì÷Ð~à ¸m‚ÓM¸m†#”÷áOg¬rÎÃ\±Ó{kŽóÑ/ýù„™G½9é;{.3èA/vãDÅøÜDÕ]øÝ–#ޓײ»MûP¶CŽûPºSÎû‘¾‹§¸èSs޺鯣ºê£“]:Ú§«ö<öѳ~µëM[;ôK?>õå{Ÿzß«k?=÷Õ[¤ ~öroow÷ Ø% pàJ€‡>Ç©opäÓ[ @Á¨@ àoúc\üú7¿ÿÕ! p€ P``PƒøC`þÞ'BþÝλàA `,`/TÁÿU C–0|éÙ'Á„´P p@!†³á K˜ÃÄ€€ ð`   &^ñzû ŸüÖG¿ö%¤° ‚G | ‡$È£C˜E‡ÊÓ¡PŽÇ$Îq‰ul¢†)<-’‹‰ôâ")I‘?ˆ()‚   $o«Ýã*2J‘œÒ ­<È+5¹ÜMÎ#¥´ÀDЯ‚”r–²4åK*Ǽµ%¤m#Ô~fN$ˆ¹GR¹à®xqfAHDŒ8 ‡ÑfA¾É‘Zî$0Hò<‚A R°A˜ÁƒH³$ÄŒMóB‚ÿ—‰0ò"`ÀØ)‚W*p€"Ø# øCð’] 4 CUàЃÖ¡ §F¨¹“›!( *6j@ í%Ij@ðVÀN™RZ$¨iLgºsîDHç@ÖÙ ö…¼àC/èÒ–*õVAĨ5:’|M(ÀòìˆdNdƒg$¢yxÁ Êó‡a¬ Ýi€="0¬`¤àÎHA‡šh•b­ˆŽêDlH'ÂLºªÑÁýxRà±ô`[ÙJxЋ5ÀI™‰À·~À²d¥åñvrU DåˆQWxF3ºs¡w¥ *h€ÿ¼ƒyÅ ñ¹Õ«î$è Vÿ„ÅŠlð°@a{x[œ®UD €H×ãJY[kð®=¤âZ§9¼` ƒõÕ*C:VÆT` & Ķ&WçìQMiF ¬v¾õëZQÐßÕöt´:ñzÔÔn¤tî/ Þ²Úª°Õ¯ Ä[D’X• hÁ‚‡«HƒxU"C¤bXÉÚ\ùZpˆÎü¡e0Æo~›t€]# ÃñnD ²‡Lä"ùÈHî`’š‘å–¾$AŽÕ»*hõor¥ErÓ‚Îä¡7šä2›ùÌg>H‚ÁoêRÿ X^@r[,1žq—Vp‡G"g4ûùÏ.@¾¸zGdˆ,Ä« ÈúÞ B×ÇQLcS‡¨œ’ ºZ汞ùÚ×òê$ €8°^ÂŽ•¹Œï¢éëP)Ÿ´ÑõÜ  X¨åx¢œMª˜ï{`¡ wÁÁ-‹ÊkÈšÖt–èbé cN‡äÃAS ‚,ÅÄСôyÁ<_9kúÑrv€c1ÜÂqSŒ0)³ñÇF7fį9¡@E}«ÁJÄÉ/DîH@Å4ZpŒÖôy'àX[c·ßaÍ5 JÑ å¼„€Â¬‘1ãW¦§3r!°Aæyˆíæ­µU¢àVWœÿœˆ'2Ê@êÑ”¿b(= J Xž*øã›W®›ß|…0¦']¾xãDôˆ½EÊ7Ç<§ÌnÃKéÇ Æ¿ºÄ<³û0©³<”­|3×{”„QjÏH)çÆu­ÿòê:åÛ…HAz¸· þíGä}òB¥ü5F·‰ $ÐK,}$gì€xyâÓœ¤ Kûi -4I@@ú»kߓˤ?\ÎwÒx HÞ4”WÁåzWÜÚpž'ž7MérúÒ¤~õÅ„c åHB:šÐ»Ñ|k^¿“Ø—fö>©=in¯÷µ6Ä׉ñIƒüž(4Ì7fWƒçzOeú£©>ÿO®ï™ìÃŽm܇¾÷~ψ'äïŒù͇þªò’‹ æÎÌô~ý>Ñ~ñ~:œ1î£{…Ä{[ä{]|@ñO èH½I¿'Iò|ÿgIµA€9a€›€“¤›€Wj®á8‚š!‚¨€•dHˆ`¦7l¯á‚›D‚Ãg‚°‡‚­¡‚7Á‚”ƒÁ§ƒ¬}9!€œ„6!„“A„(|GȃÅ烬Á„5á„’…Ã!…§„8¡„›…4¡…‘Á…>!1È€—䀙]h„_H…Òg…§A†3a††#‡¦†7!†š‡2¡‡•wÑÖ|2¡†ÝǰÿAˆ1aˆTÁ‡Ÿá…H‡Ih‡²Gƒ´gƒ®A‰%㇥ˆ6!ˆ”‰0!‰SŠ]c‰£ˆ‰a¨‰ÇljÉ牭ÁЉ#ФAŠ5aŠ“Š/¡ŠR‹¿ãŠ»‹(‹ÔG‹Ög‹¬AŒÎ£‹£Á‹4á‹’Œ.!ŒQ6Áˆê爯-¡PÁéaŒÓˆŒ¥¨ŒáÇŒã猓‡ˆ•§ˆ÷ŽžA3a‘!Ž,AŽOaŽÉA0п1…W#p¿¡!'0öbÐOp˜†³/ƒà.JòXP/JñMù!À/#g‘ñ h.ù’0“ Ž7!f“8ÿ™“:9d €y.°“B9”/©îˆ{ú„(JÉHé[Kù”äÑ”y•T™%ôRY•ZÚ·•^éY9_9–er•þa–d™–S–ª‡–jù–NÁ–l —tY%n9Hu™—¤!—w©—~…]ù—‚É}"…9˜ˆÙ‡‰"‹™˜Ž‰•ù"‘ù˜”i˜Y™˜Y„ü—™œ ˜›Ù™ ŠŸš¤©˜—Yš¨ ™§™š~Ùj&QPs2™5"›¬ '*¦h$ZáB˜ƒµ™˜vÐp"¡›¡jûG¿ù—RÆ›°y?-”@”FckäNðDW˜EAndgû¶h¶¦b*„XTÿ•”£¹œu™F5-„Ž_ôC(à0]‹Df„(°7Ÿp¶¶&ÀF"`R½©™æ9˜& Žåq•jïiA0rvj='S0F®ÕB·BV,–jõ”œ x ~Y]¯ôCô0/Di?$eðeÞY¡ @„ E/Ú¡Pæ“䩜"J—úf'V —AçJxœ°b=dFðúy? Oáik¨¦X2LNYž=š– wFà$?$ *àhƒe§BÔÅG?5Ê•B·²¦kÊM9µ¢ :‚[Z™ÐT«™§y)O:ê|é§„ú$´¹#…š¨[r¨Bp¢¨Žz&Œš$:©þ©@©šúNF±/0.¢:ª¤Zª¦zª¨šªªºª¬Úª®úª®º(‰#´r«¸š«ºº«¼Ú«¾ú«À¬Â:¬Ä:¬Лš¬Êº¬ÌÚ¬Îú¬Ð­Ò:­Ô ­;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/SuccessorInt1.gif0000644000000000000000000000424210520670125023133 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚x.Ad¹,L¼‹Úн"´A—»¦4©šŠÂÄgAÑjzRº Mµ™<€¯@ë Dk£L‹i¥p9PÅ w 1 T*°LÝ%8Oô´ÒÉe‚bŒý Ä2lµ–¶gš»nŠë‚ä î×^ƒm£ç úèŸ8C çÀ&p,þîO¢Ä ±&&J©€XÓþ.u)U *QÒ"_Y40¶ô=†qîcü:bÀm Y2ܲB¥•‘€„0¡²„/ dIb.œ€ÄÚ5 $^7\E0&e©R+_Nÿ" J¦(2u¶Ö‘¨Ï3JŒEçLQAU\ΔEäl‘@],ÎFáŒÑ?eüÍ÷“FÞ¬?mÌÍëGÛÌQ>uœÍß“GØì‘=}lÍÓHÕ Ò<…<Í!Ç“HÒ,< Í#»IÏLR;•ÜÌ%¯“IÌl’:¬Ì'£JÉŒÒ9¥|Ì)—“JƬ9­LÌ+‹KÃÌR8µ,Ì-“KÁì’7½üË/sL¿ Ó6ÅÜË1g“L¼,6ͼË3[M¾±^ ©æ\¦©mÂ…›§ñæ[ÀIqæšØLˆ9ÕBÎЬÓ,í„âYÏͼ³,õÄÌ=ƒ‡Ît¶iž)ÊgeöIJ† ?1èc ™~ú3_õ•C#ªAŠ*”1 íÉES¥³£}Hp ˜ô¤(M©JWÊÒ–ºô¥0©LgJÓ—^€ )C8Àøô§@ ªP‡JÔ¢õ¨HMªR—ÊÔ£2€:ªT§JÕªZõªXͪV·€;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/ProcessReadInt1.gif0000644000000000000000000000414410520670125023375 0ustar GIF89aò÷ $$$(((000444888<<<@@@PPPYYYaaaqqquuuyyy}}}………•••¡¡¡¥¥¥²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚæææòòòöööÿÿÿ,òÿGH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Mš$èÜɳ§ÏŸ@ƒ J´¨Ñ£H‡Zqs¤ ’JJµªÕ«?Ñ4$…]Ê|@A¬G̪åhÁÁÚhßʵØv.Ƹvó>¬«—"Þ¾€ò ñ/áÃ##fhx1`ÅŽ6Žœ2eƒ“/˵¬y`æÎj9ƒþ Z¬èΤKw=­9µê›¬/»~]36åÙ´gÚŽŒ;wÌÝŽ{û~ |±ðá-‹#>Ž|¥òÃÌ›§|N8ºô“Ô[¿^2;àíÜGzÿï >|ÈñzË›ÿˆ>¯úõÛÛ}£ü¹ôëg¼/7¿þ‹ü½å߸րNd Z&Ñ‚f5èà^nù&á„ A(Ö….¤aXv˜Ð‡]…(âA$6e≥xÓŠ,äâI„ÐŒ1&V!aLpcZ9’4£IpÅAŠ4dI=ŽP€ÀÀA8Ƹ$IM ÐfH& Ò•#eéc^‚)¦’;fæh~YP•,’)Ò›qª¹æ˜mÆ@#ü9 | çžÙ '*ú£":êRˆLPArŠÂœnéC:ÁÉõéØF¢D €#¡ÿe¯F¤¬MDè§ì™º˜<ê« Ð^†P¤œ˜B³}ð)¦©R '>ŽÐ%³† ôl¦Ï‚p«“g† ­@]^ ž¯‹ @°F+P^"å Ìúe³N e¾†F™oNjY@hf %Ìê¿ùÛð¬¸úhð½´Àk|ì"– ûꫬŠì!,(¬ L¹@0 $ BÒb{sγ6ɬ - xÉ@!„ %¹NNYtÈnÌ1CAƒlõÕXg­õÖ\wí5× ¦Gùr è‹/¬h›ëô¶œo “z´–ž¿SÿLs|p4«Œ»6ÓMÆõº -p5mÝÑÜ¥-ÐÑAé¤[@4©E* ÂZŠNº Þ‡ÃyxÐ…«½4žõ¦É&h€ yæ’sDù@–°”`«-Ì}+xŽ|Úíô© ÀôBp4GO@øê_1Óq]èíšyÀîžõ¾Q¥mí œ,Мr§ê o¶@ò³Ô6Eªc© Ð_þ&`¨ Là¡B©F5À ؈S6:OÇcÉAªC’jÉ1B–ŒpB%\É ”B•¬0A-LÉ C”Ìð?5<É õ“C“ì°>=,ÉÿáD’ q=EÉÍ“D‘,14ÿ=š8ÂáÞ}ÿ/ ¼Cvæ' cÇŒ{4ví̇/~þÎñ$¿G¯þræØá_wö T_8á7’y·50Zb%x6e”ÐÞs l`w8W‡÷U‡a… ¦abV{ž€AaεØá Ò¤ Mò0Â… ÒX£L7Ö$f5F ‚>þS4•p˜A!<Ùã‡JÚÄäM$ìX¥@InÉÒ•7ð€–Jvé¥J`ÚäŒY&•gÆ”fMžÀ¦›SÆ9“(à矀*è „jè¡Ø©h›dÚg¦ž&!PA”Vj饘fªé¦œvJ¢vÖŒpBÚÒœ4U ¨¨?>jêH¨ÎÿĬ¾ùêK±Æd£Véê­ å “ qþ ¬G›’±Ên”l³&1 -FÏN;’´ÖVTm¶ aË­DÛ~Û‘·â>n¹‘‹.Cç®{‘ºî&Ôn¼ÁK¯]"Þ‹’½ú4o¿• 0EÿÌ¿l°p/ ‘„p¿GL_ó›oÆãḇ¼œ®Ç"ã[rÇ'7TñÇë»r¹Úœ²Æ3#ôžÌ5ƒœóA1;Ôò½/ûaC‹¦XB?Ó4·ïa×@ !MrÍKgÛtv2”t¼U[{µv9^¼3B]OûuÖbm²Ú…@n‡p‚¾}7õKD×AÏMÿP…`AÈ7•ínĦSµ@ŒAwtb•'H8Û90@‰sy·K‰ „ºõ roë(%k'l€µN†¯ËŸ'¾õF¥ Äœƒ‰É tÓi˜Ø‘§ËMûæœ4¨¹ï®Qï›`™` ø&9æÞvzÌC×½<‚æjþù觯þúì·ÀŒÞõœy–k£mïÜj˜c=tæškžBH`¾»H/#½Z̃—ìHÛ1ÏB€9À…H€ ÁŽ(s@Œ0Ž3lŽh#¹Ä4 1ËÉÎG¤œÔ]Ò1N/’·èðF #°¡uð² X ‡Èaÿ¢CD ƒq@Èfø­ö‹‰Ür¢¾ ˜-)Þ‹ŠÖ²"½°8--Æ‹‹Ðò¢»ÀØ,1®‹ŒÊ2#ºÐx,5–‹Àr£¸àx+9~‹Ž¯²#·ðh*=f‹ò£µ©'AN‹q2$´y&E6‹‘^rdA¸(’¤B¢!WCìHŽ1Îê É-’zÂZV¹O’R~%³¢‘34°ÆNºYkГ9 –"“bcÓ[V¯g7³/]ùKM2O$ŸäÌÍrƒÊ›ù®•¾œO)«$Å£5çf¢©^'g·çd3<ÛT’„é€rLŠbÍrö2“´"å:#ÿÊ)Ç7¸=É ›0S›Àü˜$Š# dhçôN:´Ð‡®h’ERB9VÑ[M´F}ÕGAR@$ðÒH;TR(@(õÕF3ÖÒߨ ¦)­ÑJTS € §y ãÜGÔ¢µ¨Èé+Y– €ŠÐéL-VS Ø ª¶Êç3qr¬Ê”©UATU:ÕˆÕ´XeuØYÏ´Ó­•¬`EbiÒº°·n©­ö±ëWµ*WŸÑÕ`zͪÛª¿Œ°Rk_¦ØÅ"@"d»  S˜Í¬f7ËÙÎzö³™µ€(Ë ê´¨M­jWËÚÖºµ 0,igKÛÚÚö¶¸Í­nwËÛÞŠ$ ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/NumbersInt1.gif0000644000000000000000000000372010520670125022575 0ustar GIF89að÷ $$$000888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,ðÿEH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³fD rêÜɳ§ÏŸ@ƒ J´¨Ñ£B'Ø$IàÒ§P£JJÕç‚!–‚Ì`@«W’ ”~å˜s¬YeÏfL«¶­E¶n)ÂK×áܺïâÝkP/_…~ÿò ,¸/„ˆN¬ø0cÁ‹G~lv2bË”½b†ì83ÞÍA{¦)zoéÑ1O×UÚ%븯[¯ŒÝ–¶l”¶Ïæ¾]r÷Xß¼E×Ü9øïâ­‡G‹µòåd›~]#õš×«_Ì>“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzªQB]>tjªI€éA¬‚ÿjK>v@&A>T&Eg„€š²ÆU¨, ‘»æ B€ðA®ØZ湊ðì£v -™Ñ t¦¶×а¥±æ)ªK  D÷ýÓâ*‚˜V^ùcÆ^`£» ˆû£Xéãî:P¯Àø ’J²¤£@€ºìž‹‘‘€Æ¹+½øÎ @©uPit €Á  ÐAAž‰¯³!»ŸÅ,q ±Ä¿‡³EFîY®Wy&ÉA†d™I"€o¤s:`¬’2ÏY³K ì¬õÖ\wíõ×`‡v0Ô.Œ$-/•#Mg6¼¥É?{0™,l4–½^ÿßÏ*y°5ÕÒG+ŽCo ´Ô{{œ4ÜIJ%•’ßýcU[£¯ÞL;®^K )ª"\À読wYú©¼8« ôºµ/¢þú€»éÁºõÀ±…ûü)…t5¼]€/¿ÐÃoE/}BÔW”½sÖWÖýõ†Í ¾†ßµýtå7>ùâ¯ïdû¾Vç‹7ÿRõ³w¿MùÛ·?vÿ“^ÿF¿èÀ¯€ ô(¿2P{ìN?¥@å=0LMUA³mOœÞÛBÃ]p;#üÛ QèÀV¬….\àŽRؤb†3²a~pÈ"ćŸá¡¹µbH¬Ûq5BË“ÄM-‘‰0|â £(Å61AW\P´Åu1BU$ ¿ˆ!2²/Œ#Ó(›#ÒÅ#¢Ô¸FR±Ž2#ô¨9æ&¤# ­xÇ:úQ $B`3Ô„@]ˆ¤$'IÉJZò’˜Ì¤&7ÉÉNzò“š¬@°Å,À¨L¥*WÉÊVºò•°Œ¥,gIËZÚ2– Ѐ"wÉË^úò—À ¦0‡é•€;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/SubstituteInt1.gif0000644000000000000000000000440710520670125023340 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚È©PÐåA8»“ñR$•6DA¾‰ ¯Hé¸Á»›V›QªI0A´&´À”v’'BÑj:®MLư,À+ò4ÕfðÀÂnŠ™¦ª $†ÀåÅ3O ÁË0@ç’¡’ ¨}@èª;аŠ@@¢Nkã!üü—˜ü®›À&Pj¨ƒ’ð©£jª9­œÅê)å£bîyi¦ìÉhÂB*æ£,Ð6¬$ÿKç§+ßÌ…¼Pue$žõɆ ·´«Ž°"¬ijÔ=娓Šé  ú+Û™©­†>а–¾ìŸ£[ì‘Ôyà¸âV¿¾ûïÀ/üðÄo¼ãлEt†§Þa[©£ûç¶‚«ª¤J ,p´Ýуêº@c‹ +­:‹ÔÀñðÇ/¿üx»Wíæ§„þ¹jëÛ[ÀËœç?ÁiOt“ê@é:¨eqiuå#ÛÆb·>HÎvü) ~§7Æ q‹³Ñò(¬„¡®kP“£òv¬ $ÊŸJ‹š(0*A± aHÀ %­G¥pQäû¨ÿl8ÓM+}£ê@v;ÃéDŽë ctB*yšÀÇ2Ю L)^ìZY¬²$/ h±^È Ò842)K"Àâ€v/ÌákŒkTã@ 4/ ¤^˜^Ôœ˜“ä ƒ…©ŠÎE•ˆ”Ô1¥‚PUˆ•Îq%`¹Yˆ–ȱ¥pY]Âñ%~€ùaÖ‡˜¼1¦|™e¾‡™¶q&{ 9i¦‡š°±¦y°Ùmއ›ªñ&xÀyqv‡œ¤1§vÐu^‡žq'uà¹yF‡ž˜±§sðYì}.‡Ÿ’ñ'rú‡ Œ1¨pš…þ†¡†q(o Z‰æ†¢‚±¨m0úΆ£~ñ(l@º‘¶†¤x1©jPz•ž†¥|!¤'Ó¹¸”45…ËMC“Ó·ìÔ’#dÑO7ÓÓÁÈt¦ )ªZ†Š¥š…©•qjY *©*æ¨HmSPSDÕÇX•*]eÌWÖÄDàTH=kV%\`p«\çJ׺Úõ®xÍ«^÷Ê×¾ú5¯ ×Ú0@ˆM¬bËØÆ:ö±¬d'KÙÊZ6² àa7ËÙÎzö³  ­hGKÚÒö* ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/BlackHoleInt1.gif0000644000000000000000000000401410520670125023003 0ustar GIF89aò÷ $$$(((000444888<<<@@@PPPYYYaaaqqquuuyyy}}}………•••¡¡¡¥¥¥²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚæææòòòöööÿÿÿ,òÿGH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Mš$èÜɳ§ÏŸ@ƒ J´¨Ñ£H‡Zqs¤ ’JJµªÕ«?Ñ4$…]Ê|@A¬G̪åhÁÁÚhßʵØv.Ƹvó>¬«—"Þ¾€ò ñ/áÃ##fhx1`ÅŽ6Žœ2eƒ“/˵¬y`æÎj9ƒþ Z¬èΤKw=­9µê›¬/»~]36åÙ´gÚŽŒ;wÌÝŽ{û~ |±ðá-‹#>Ž|¥òÃÌ›§|N8ºô“Ô[¿^2;àíÜGzÿï >|ÈñzË›ÿˆ>¯úõÛÛ}£ü¹ôëg¼/7¿þ‹ü½å߸րNd Z&Ñ‚f5èà^nù&á„ A(Ö….¤aXv˜Ð‡]…(âA$6e≥xÓŠ,äâI„ÐŒ1&V!aLpcZ9’4£IpÅAŠ4dI=ŽP€ÀÀA8Ƹ$IM ÐfH& Ò•#eéc^‚)¦’;fæh~YP•,’)Ò›qª¹æ˜mÆ@#ü9 | çžÙ '*ú£":ê¤L0ÁE 4Á m:PžŽ°…Z©2IZÒF©Dÿ%WM2T+œ:AÝJ¯*çt}:¦A´:«¼ŽÂ›pv`¨@H+P“Õ¢©k³ÑTkµÞž¸#tysÅ:&ÈÉlT§M* %€v «=^¦@/ÍÚå—MBi¯¡YÌk±‹]º‹%ÀÅí¾+Ä[:éc†*°e“@à$¸…¦¬Q.[W (àñdè”YNéo¤©’m\,ôÐDmôÑH'­tÒ ¦IöR+¥Ç#L`°yz{ñ™¹jÊ«È^{,¯1?Ì/×<ûL,h M@[O—µ@Q÷ˆæ¹"Ó|n¥N:ÿ°+Ú†Í@³Pz4§™âéeÏO Ú¿-Æ"C|6Í,³½Pâì£^5¯Hé@×õ*@°ÉŠwt¡?S|˜HîYÜ$Uji¨ž^pé¨U hÕœŽ *§¢’ú¥6ﬥç:ï)¨6ZjãÚšY7¤ªÊ÷z¿øНùšŸú ªûºüÿÉoýúÙ_þõéOÿðñßH¸Š„€æ1`H‚„ÜqàG x žwˆÂˆ;BAél#lÎá‚Á ÒEv­)¡ )2B„9-ÌÈ ‡û¨p…©áEfèZ„‡¹ñaEñ€H!úå†8„ˆ'BÄ×,Q"MTÍ#ÅÒL±0HL¢C®ø*‚†‹ñbgÀø#-ɢ=„ÆÛ¨q#j#oÞGÉ18t¬c‹îhœ<êQF|\Žÿ¨£áˆ1{„Î ÿHÆ#2‡‰¬Î"õØÈ…ò2•TÈ%)“IÉL²ŽDÈ&#J*}Ž¥<Ô#·Iíœr©,HHµJ‡L Ã0°^úò—À ¦0‡IÌbó˜ÈL¦2—iL  q¯á@@ÍjZóšØÌ¦6·ÉÍnzó›à §8»ÙÔòœèL§:×ÉÎvºóˆ ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/xorint1.gif0000644000000000000000000000422310520670125022031 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(͡ڼ€ à› A—–«Ì™†o/ô\Aàö„óGø§óFNïÉÂÑæ  XØ!pÞNS{Ä@Gwwµœ6çA¸âîlž¥ö™güÿ«SÚe !Ûò½­ÑÜ~—l 4@0Þg¯ÙR·­Ó3žžá]lï¼Í¥&¶cÃù»šß»Í¨úꬷîúë°Ç>8€n+ S¯iœ`ãó.0zØ¡™N¹z–ç‚ê¾on»K©Æ¸jÐÀÅü^z¼®õ…vñ8mÐaòìqnÐ>›ÀAÏ&>Ñø²Ï¾ùÁñ¼-|ÜßÁÞõ‰ï&à=@[áË»ÿ$¥¿5 ðQ4Ó•À1-0Q ÜÒ A,MpPŒÒ•A'm°O¼ÑõÂðN%ÔÐ é” ­0N-|Ð ÝCÍpM5,Ð Í”CípL=ôÏÿ«óµ„”!AÜÏ¥ƒ®‚¤,\˜ Ò²Däx€k¹˜p÷¿ VU,Nv®¾€Àg “âQU°1"@®¡Ír¸³F*Ö/Tc ÎsÌÖE/ÖÑŽm Nv†ÃÇR}1VaÔMö®¾¥æˆI"~y–G1)ËRƒHúñl¥C$YJjˆ”ò1å…PùUʇMb%{\ùžè5`A²L-Ùƒ9 ÝÒZ ÜezJ º[æ<¤H„dÇÌf:³™¨‘(“ÙbvHÁ1»CÍêô›\Ûfuº) €3’‡|9‘S,~òë|8¥Ïð¥SUõTÞ4ï(xJƒí³Ÿ ™'rò ‡ µû'@bPÝ ´: ½ÍC¥ÑÓL9%ÍE‹“ÑÊlT7è€(Pµ…*Ä0’JWÊÒ–ºô¥0©000™4!€‘NwÊÓžúô§@ *ŠÐÇ›õ¨HMªR—ÊÔ¦:õ©PÕI@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/PlusInt1.gif0000644000000000000000000000427010520670125022106 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(͡ڜ ÓràÁÉ<ãËPb _®2g²Kž…®Ï-´œA lkÎaàŸÎL‚¸Ã=FÂcx‚@¼‚?›Pï½9aí Ý×y ¶cÃùÿ;ž¸öÊ‹€¸árp®Õ4ÉÝQÖ-Þ5=8ÌÖw¼,‚Ï‚@Â_o¬“â}0£ãéA^‘gUO å¡ù dwoÀ9ŒSc3öîûïÀ/üðÄP€w/ݒΉ`x¼·Ï:â‰Û­S½/@[uªSÄül!0;æLP½À¿óM¤o´A‡Þ¿þD<,PÐ&h0Aަ5|h&p * À£™%Ÿù^ê”§«øiädÏýÖdAFmÐLLÔÇBCpK%Ô ±”B@­0J-ìÓ C=ÍðF5¼Ó C”C:íPC=ŒÓÿ/D7 ñAE\Ó”D3-±@MÓÅ-MÑ?UÄÒ÷“EäxÀh9[©(x«.]IY¸0 ¤ ÄŒºiÕ ‚ lVn|£öT•À+s(;ÛÂÚ˜G8Þ¦kh35<æUëcpž3¸ Zë‘1äi$Ù¼Õœ![Ä&IÃÉÙhL\£# ¹ÇS±l<ŠI\–šTÒ£|P(ë“KíR>½,Ð/ßÌôP IÃdO1Á34`AÉLÏ2»c: =󒘜fuJлgF<ÚŒH„ŠGÎrš³œ¨&3ÙJ7r³Cx€¾Ùp"§šñ<™ÁÖ I~dù$=«cÏâT@Ÿ%#­ ªA…ÆŠ¡ä'DÁ3PéL4ym§?÷¹Î‹‚Ï¡¯ò¨t*Š‘"‡¤Å1iqPª•ꆥ·qém`z™ž†¦¤±)iÐ~2@k]ˆ`¤¢õ¨HMªR—ÊTa`` ªB*£ªZõªXͪV·ÊU1À’R «XÇJÖ²šõ¬hM«Z×Ê–€;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/DeltaInt1.gif0000644000000000000000000000455110520670125022216 0ustar GIF89a<÷ $$$(((888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìê…8w¯^¼7EL 8¡@€`¢ða¿ ûBŽ Øf„#@PÀx˜¼P2鵕S6@°„‰ 6hй@ƒ…M€ðl‚µ ¢O'4-üj꓊'4( ¸€ÀÍ WÀíøèÍ¿ƒ7H|»ÏãXpÿX`BîÞ˜/gÎ~³uï»Ãß žä{åÏcWO=ûxì÷Íg‚|âTI¶½&^aˆ©w™kg›Là|hÓ#QhØ`"¶Yl [„Ιpˆ]_†ÒÄaMç $Â@.zcŒ2ÍHÓ<–™vîÈ#L>ÎDb-9š†FéR’7} å@Q^¹•6)°À“Gf©¥jy]e|&]cÊX¦UÀ¡™&˜E²Ù¦L Àž|öé矀*è „" §œ XYç31F*餔Vj饘fšÁ¡ð&†v2ú—5u §§<Š)êH¤þØé§P†ÿº*K­Î¤¬1ª:+HµîÊ’®¾vÔk°)K¬FÃk’±Ê^”l³#1 -EÏN ’´ÖFTm¶aË­C­ÞøíGÞŽ»©(`®G宋©#Ðé®\²Î‹Ñ¶öRÔn¾áËoDûþëï¿ÌïÀGVoÂÚâÊ0» ? ®Ãodp¾W|ÐÅö’êÁóqÈ Á+/ÉÃŒò]¯¬¯Ê.÷ÛrÌ'+Äñ¼¯›cÊ13”³Î"÷|îÌ+{p˜ÑÆB7»ûó¸Ö× %ò,tÉD£up5rsσüðÖ£uß×1›,1Ù¥¸1Ú.?ý-€@·k°YM£y@ÿhƒ)4ÁxÆe}õ@TuöMÙømåFwÍå4¹†nBP ¸@McÄ_âµanðö[ßä æ <™ú˜kÞPœ+úEüá7†%˜[ã‡)fèt•_<~AÖŒd懗phî»[Ô»‰ `Æ ääh¸¶ß`&ª(Ú÷µÏ·=§ì·ïþûðÇ/?§ wJ×;¶@‰xϵb"ŸëÎG¤šÈ`œJªWþtæØùMÛ#àÐn|¾cún6¡}@N ÝýP""CŦ3(QsL°½º IKÙÓB¿¹É!ñZgBˆ¥žÄ<æ!œŠÿÌs#ÀEh ™ÀŒ8¸ÆŒ‡HlL7½«I@ˆ=´Ë´8rë€ób¶ÀX11Z‹Œ3ã´Ðø05B‹ sc³:ÈÅù0dj«£•Ç„íñX}$Ø‰È 2X…ä×!}•È|-rW´×#gÉyMrUtäâ%E•GMÞQc•t×&JÁdFH AÀ`ã<áŒòN¡ì]ÛZi#Ò 4|Ñ'+v@dry3Álj¹ š`È^àb¢Ê±'Vu”ÙGB„LìèÑ©PðS€ ,€{3wVœW¶InçÙž®‰Ìls1ìéßÇ™KíRbèL‘uØ)ÿK Ð%=iIsŽInÛ›Îrfi´ôÔíÿ4È@¡MaV"Ž)€L¢Ëø¦D'2fåŒv²‰È Z eäÜörºòžSiA€„J†¦žÛAé•dJ'Aħ&O¿¥S) 5"—”Šz¤£BÄx€RsS†9õ!@ST§º¨Š^Õ!”ÓVƒZGCÍï¬hM+Z (PUÔ¢f +š •‹_mHV@W»Rõ­yeˆúºÔª&,° ¡€_ Ø‹êѰC챘Ê#É‹²1²l°0«!Íúгòì®@+ ÑΊ´ó1íªP ÕŠŠµÞq-£`»ÙNÞ‰¶Å±m›з2ouˆ©â÷¸ÈM®r—Ë\ãb`Ÿ îB*@¨êZ÷ºØÍ®v·Ë]ë2€ Ò ¯xÇKÞòš÷¼èM¯z׫¡€;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/IntegrateInt1.gif0000644000000000000000000000417610520670125023112 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xîAœZP¥µ›¼´­Ø+Bt¹kKŸ"¤ÅyP¿ýëš½;Mµ™< ¯@ëÔ¯tv0-°Ò†:í@\~0í’K’ðA„&P¡$ 4qÅÿ¹q½e1@@µ‚ @ÃúF\P¿Ÿš<æ°Àj¢)rÑž©&‚& ´˜{:*' <ÿYÀÏAß sU=se}³Ã:Ä3Ë&ô&ú±"ˆ öd`#¨&“@Aqÿ@ÁÙiCš´Ké‚äØ|ÝP¢ˆ7îøãG.ùä”À4Tµ@£ª½&±ÐÚ¹–Â-uB»ÀæŽ pK T.ûì´ÓN€‰!€øÌeÄzçÒJ'±‘ ®eÞ .ª¿»~pY 4¾€¦… àµ~½« *Á£šìŠB¢E_ü§Í M´Çf½ÔiµTøGˆ}ýc‡+qæ"‘—¼ôæ,ù9ËYÒW»°© ,+V À& ‚ N©]„  Ha:‰ÀÓ*Su"Ÿ‚@œ’÷—ûyäØ;Í )â€GÕ¯… ¼CfˆRˆ‡Åñáƒÿ€(!*ˆˆ¿1âÈ%ˆ‰¹qb€ h)ú‡Š³±â~°-⇋­ñb}À¨1ʇŒ§1ã{ÐH5²‡¡qczàè9š‡Ž›±ãxðˆ=‚‡•ñcw)Aj‡1äuÉER‡‘‰qdt iI:‡’…±är0)M"‡“8Ô! #O”~1¥pP¹Uþ†•xq%o`yY憖|É¡(‚˹ØÒ6½„Ë/gÌ· 6ÅŒ.wÙ&Rºè˜­I¦Z ©iš…š2t&‹°Ik–…›¡ñ¦b–ÉÌ}•œž'Uйuþ„˜q'dÈYÎÃh3Eð¬Œ<{’cOÉì“'ý|LÜ¥ÃÖó!! À6ÀІ:ô¡¨D'JÑŠZô¢ͨF+z<ì  á@Ò’šô¤(M©JWÊÒ–ºô¥0©L[Ê€ô¦8Í©NwÊÓžúô§@ jt;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/FibonacciInt2.gif0000644000000000000000000001305110520670125023036 0ustar GIF89aD<÷  $$$(((000888<<<@@@DDDHHHLLLPPPYYY]]]aaaeeeiiimmmqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,D<ÿ[H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£J*D†«X³jÝʵ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊKW® š ÔÝË·¯ß¿€ L¸°aº(È$‘€ªãÇ#KFH EÌ«“3kÞÌyè‚—3tMº´i•ŸCŸ^ͺµëˆ©ab~M»¶íÓ±_ξͻ·ï©¹]îþM¼¸q¡Á[?μ¹ó˜ÉY.N½ºuÑWN¿Î½»÷‡ÙUnÿÿN¾<ùð)Ç›_ÏÞ9z”êÛËŸÏûýÉøôóëÇ Z¶èýÈŸjh`fö™„ß 6ˆT‚%-èà„ú!IV¨á†4]8R††("jýéö߈(¦Ø’‡"¨â‹0^ÄbH.Æhã ÍR8öèã@:~ÄãDÚ¤GC©dŠGv”ä’PrØ$GOFiå„SnTå•\˜¥F[v)æ~_fæ˜hÊW&Fg¦éfyk^Ôæ›tr§EsÖ©çswV”瞀×'EjhoƒNTèA(`°À£F*餔Vj饘fªé¦œvŠ)*L¨‚ž–jꩨ¦ª*¥XFR¢-ÿZP h0­¸æªë®¼öêë¯À+ì°Ä ,8ÈÂëì³ÐF+í´¼bp@¨#Á‘¬Y°Aƒ ˆÐ Š1H¯–(܉!ikœ4È­qó äîCõ¶p/qðÊËnùîÛPÀêØ/ƒùþF0" ìÛÁ&ìÛÂþ¥Û ÄJÜÅ&ZÌ Æÿ+ Çëz| È#‹ Éʩܑý¡¼²Ëû±,ÍÁÌ›ÌjÌ›ÍÚᬑηñ\³Ðô-Òm›Ñúù|›Òé1-cÁBŸÔ¶Q ŸÕ9]›ÖIƒÍž×÷™M‘Ø´‘=×µ¡­ Ú±ýšÛòÁM›ÜÒÿ-‘Ý®áÝžÞ¯ñ¡ß°a àg#þá:žâ2¾á®AÞ¢äÞšåæaÞšæ4rž#åû^žè¬‘.Ð!Pi:Cž³¦:y¬¯æú h »ÉÞþøìÖÙ| H Ê·ð`º`¯Pí« ï]î§±œ‚h €-Œ/hÀ¨Çj}BØŸ¦}wܛƲ¼@ æ·€~ ½û]¶Ú—Ÿùq§~¥¹_þZ@þ‘Ï ï´ô>„ÄÏ4¼Iò]ÈŸ °ôŽwXg°x!¬‚αþ `€Ø…€†!ô 'h&ä‚¥É`ñÿ|È× ‰ˆ"i„X ŽÆˆHB"H&Rlj¢“¤h/*†„à@ JÐ0žÀVYTè¨ðŒ'[bÅç Œ¶"ãAÔÈF6äŒzäõz¢E6Ì‹ Q€ô €&Ä„ ú ÒÀƒx`¹d BÐHÄ.|/©£oF€ƒ P‘4läA* Jƒ\ “Êë_AN =Τù¡¸¨/D~d„rÜß †GÆq0K‚èñcܨÇÚ²|(ù×MºD”½!$PÊœr 5ÒÀt¦°ÐÔ£²™Lm2pÐÈ+=Pÿ\p!DüY`¶À„ü£áN@CHÒƒà÷$ÀÐ 4€ã[#*ï‘q’ø;Ÿ/?ÎÞã,ç9b¾€| |€ô4ðJE>€ !´çKê?é]³bäPÐòÒnŠÌ(ùF¸‚pÓƒg\à$ÓùRîO‚-È©A_'Uß…‚ßh~€R”’s¥!H¸‚é]4€ˆ]N’Nß™|ÝÜŸú~ ÔCrÄe@QvÔ‘vd„é£^ÿú€é}u’å?ßJÆnµõê0G•(2°  ­hGKÚÒšö´¨M­jWËZ”*€—Ùêødú€Æÿ>à­¾ KÑ9δ’o’ ÜkM"ÐÚâ—µ(§BJ‘ËÚó¹•íj XôªÒ é+o*ÞÅQ}Šœ øIG±ÒçDuá)9BàÓ¡Ñ A%i¸VÎÒ°§<½k|÷çAS&õmÊš_‡Ä8"`,ˆ 3™>ËŒ`‚¶ú±eÀÈG>N×wgœã„é*ê™7”–Ï}+;¦O>2 Æ[…ñŒj¼²ïv¼å5bÖÌ·,,G,Òm©yÿ2`pA.ðÞïF¹=ˆ29c (רû}Ìü8¸ªÂþJtPûÚ.Ú¼ô‚íÄÞܱEŸìÎ=“ôÆ(]2KÓGS´_G—ÒÅÙófn¼Ë@WÔQÓôÏ8Ý2W§Ö[“õÔh}3[ëÕÄQµfX­(^/×eu£¶ì!ûmºîš±—æë>;oÑŽÛ´«Ví*^{pÙÞÛ¶¿Öíù[aá.ܸÓVnùœ{ÒÊ.5³åíìx§¬Ý‘Ã7{Þ½i{{{Äf¿gíï—™:Šú^ÏÀw]pŽ|ÝÞnx¬¾#ˆ›ûÛ“øÐ¾EŠŸã—Kwæ,~8“gáÒÿÖxFnòï \Û*oÇ ÙìKÇÛ-§9½mþ›‡mæ+ôt }žq¡÷ÚèÇ&zÈsôQó¹‡üî[ß{Öüþ6²¯ ãÛ&ù´Y>óKãüÚ@ÿ5ÒŸþhªO›ë»&ûÚç ÿ÷_ãýÖ€?üš¿kÊÏšó£2êo ûWãþ÷G&þ¬™ÿiêoÿÇà5úgü×TñBjÑG|˜hX¸€QÑ€¥ñ€¤øH8˜M±£Ññ ¸"Ø$È&x‚I‘‚œ±‚›Ñ‚.x0¸2¨4XƒEqƒš‘ƒ™±ƒ<8>ˆ Á''QB8„AQ„“„“±„LøN(P(R8…=Q…‘q…‘‘…Z¸\^`†91†Q†q†hxjèlènø†5‡T1‡TQ‡v8xGˆ'Iø|؇1ñ‡R¡‡SQˆ†øˆÿŠ(ŒØˆ-ñˆP‰Q1‰”¸–ø˜š¸‰)щNñ‰OŠ¢x¤Ø¦è¨˜Š%±ŠLÑŠMñа8²¸´È¶x‹!‘‹J±‹KÑ‹¾øÀ˜¨ÄXŒqŒˆ~2ˆ>±ŒÌ¸ÎxɘÔXqF‘H±ÜxÞXàxâ8ŽQŽDqŽF‘Žê8ìèÐØj¼ñóˆõXl×b{ýè>ÿi(i‡} h6±AáŽE É I9‘ Q‘?q‘C‘‘‰i!éf’~ˆ¨(I#Ù) Ù’ñ’<“Aÿ1“4)6¹8©„ ¹“•¨’•¶zA)”œH”f”HéˆJYk÷x”M‰=©?IˆR9•&Q•9q•Ó˜•ZI\‰^Ù:¹“cyeÉgI“iik¹mÙ’oYq©sÉ @ËRÙQÔ¯v¬QUγ@ñÄNËäL*4FÅd>Ãÿ”Ì”WïdЊ=ËR „P.µP õP+QUQo•Q·…R˜äQÎòd¦º<ÌÚXIJ9US©yW$ÖXŠ”M-µST+SÞõ®Èú¦ËI•T"ÛTOQu>¾CU0…`¾£UÙ%I1µàzâJ¢7AC#Ô[q•U"ô[ >'0d4¶+ð=¤N< ±‚)¯%Xaä[ç>FÒY“…`Ñ%²ñUœ›Vk p¦÷º°»œR0¸èƒe¡[)ö[”L3eO‹5¹«[”š4i›ýõ@ýSº`E]wû±×eºþÚ·Žt¶*°xÚ»½Ü ,0¢,ÿ;óÔõ¤bì”#ÐXÀû@ÿC¹{¼’j¹ ›]Ïõ_6`àãA½ –š &·,U½Y¶Ë¢ƒk¯þcb‰ V ,>KõÀtë?Ós?{ªð{9v­ƒä=vdräeC¶Fkdd?OéCK&ìúda¥²±¹ñcfdÖ–>*´cìŠF]FÁò«¶˜+qvte.Üokk¢Iœƒ–°‡–²;3üªS\4WÛ©À*¨¿Å™VÅ>ûÃŒzÅÇ!le ÆñëÅc#Æ‘–ÅUK|7jœjÎúoìÆfL©GLpKL£Aܤ\j{Ì£ÿÖÆŸÇÁÊÆ½ús[ÿ uˆœGȶcÈèÖÈÄ»sGúÇÈEjÉC‡É¹†Æ¬É\'ÉðæÉšÈñŸQÀ:JÉìÉÉ›jÊÐÊQÇ…œÇ 'ÊuÚÇSÊȲ쫎œ3œ=¤ŒÄ¾ÌË}CËSÌz|ÌÅKmºl¬<¤®œ©°\¬Î|¬Ñü©Èܧ¸œrÛ,ˆÊ|Ë¿ nã\ewü£ß sáçLÌëìuí<¬Ï £å\tÝLuù¼¬ñlvóìÿ,pÌœËÙÜ£¨¼6Ã,? Î=È]7 A ÍÎ mp-n×vlw €r7¼wÑ p"ðÄ’À—B`­!ÌÿÑv\8Ó:½Ó< Z ѧAÒ==ÔD]ÔFR ð—ïLƽ~wÙÔý÷ÔPý~R=ÕN=ÌLmÕ½WÕZÍ|\ÝÕ[Õs Ö{òÕd}(f}Ö’Öj]ÖbÝÖ4ÉÖpM'r=×nR×v&x×b²×|Í%~ý×§ÑX u[Êd^2}›7e½™„®´óÖ‚#šF|´¯ ±cŒ}P‹y:"ÙrY´M6>zäÀ±CK0>§< ;Y¥ÚËÛÌVáƒù3¾-`ìmÔMò•Ø¥ºÛÝ­—e] Yå]ºˆ•Sg{¶Ô½bé½Ùmß÷Mù`Ê“Sȃ¾í[ºã«¾ã“kEK `á€á`\ûcB|àÜà ¢¾ØæEØüDK8Ä@R„S 5¾3žM ;IÀ¥L 5²œ=â$n‡ýã8äBn$]ä°HäHþ"J¾äLräNN‰Må"2åT.%P~å@>ÌZÞˆ@ß$ÁµÒ½f~æhžæj¾ælÞænþæpN,ž1Ñ(²{çxžçz¾ç|Þç~þç€è™§Øòå†~舞èоèŒÞèŽþè;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/GenerateInt1.gif0000644000000000000000000000404710520670125022717 0ustar GIF89að÷ $$$000888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,ðÿEH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³fD rêÜɳ§ÏŸ@ƒ J´¨Ñ£B'Ø$IàÒ§P£JJÕç‚!–‚Ì`@«W’ ”~å˜s¬YeÏfL«¶­E¶n)ÂK×áܺïâÝkP/_…~ÿò ,¸/„ˆN¬ø0cÁ‹G~lv2bË”½b†ì83ÞÍA{¦)zoéÑ1O×UÚ%븯[¯ŒÝ–¶l”¶Ïæ¾]r÷Xß¼E×Ü9øïâ­‡G‹µòåd›~]#õš×«_Ì>“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xz:ÑD€éIêЪ© Šÿºš¬õø£ti)iЮíùh¯­Ž¤£@€JÒ]nÀ§@ðJ&Ñ´A®"€°ÁArË«P­´Jn@í·áä–Ú’‰íDRHWˆQv[+•ë­>Bêã³$(Àt&9å­ÿÂp•(<’bö{£Œ+]@½÷ÒêPÁAJÐh\ $‘¹å` eg m¥/“Œ²ÊCÒé°Ël@2AZ3X–)o\xì1Èï‰ÜP¾‹)€3Ä0–éãW‹ - M2ÖZ÷ëóÚe-Òb[9§ÒФ€Óxç­÷Þ|÷ÿí÷ßÀCܵ÷É Ï~úóŸ ¨@ƒ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/SignInt1.gif0000644000000000000000000000434010520670125022061 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xî@!P0‰0A¥ ÉK/CÜ+ÐË2$‚³*¥à]îŠÒrihª®Å1¬ñÉPý¢$ðGSm¦A,к$|Ê$ c:Pˆ@ç„À%¦ƒºŒé´Ž¦Ðï$@ð6®«ö.­:ŸÔÀìÔWo½õx§7M2±-Nx]"¼”Ο3AcÂàk¼“¶M<¤›‹Né°úúóËî–7ÝŽ#ØS×d6¨3ýikÐcœýž)A!msÓúÓFe¦³½m‚êc˜È€£´h€o|Œé 8²rdyš@—ìEÝYàw¿ìCä°†Y"Hÿà‚,Í«dË’dÕCüpƒ+¡N" ¸ ¦(ú[B¶aÏ"yRÈŸŒ%7‚$^º‘bN`ÅÍh1!LÀpv‘è‹ ^L@¤%­Wyctø§ A:‡2ärI E"‡‘rdq éI ‡’û±äo0‰Mò†“õñdn@)QÚ†”ï1ålPÉU†•éqek`iYª†–ã±åip ]’†—Ýñeh€©az†˜×1æfIeb†™Ñqfe éiJ†šË±æc°‰m2†›ÅñfbÀ)q†œ¿1gaÐÉu †¹qç_àiyú…ž³±ç^ð Å}â…Ÿ­ñç]ªòE€\ˆAçBÐÓ,. %ÍCßÑÐLt0MhB.ª–Šz†£fñ¨]È"‘b¤e1iePª˜Œj´M$M‘J%ÃRªÌô15ýÉM“Sȸô¥ª¯~*Ôu§‰‰À©4ªÔ¢>$¸À¦JÕªZõªXͪV·ÊÕ®zõ«` +W/@€:u!`€ÖÊÖ¶ºõ­p«\çJ׺Úõ®xÍ+]À³úõ¯€ ¬`KØÂö°ˆN@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/PrinterInt1.gif0000644000000000000000000000366410520670125022614 0ustar GIF89aò÷ $$$(((000444888<<<@@@PPPYYYaaaqqquuuyyy}}}………•••¡¡¡¥¥¥¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚæææòòòöööÿÿÿ,òÿEH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Mš$èÜɳ§ÏŸ@ƒ J´¨Ñ£H‡Zqsd ’JJµªÕ«?øÐ4$…]Ê|@A¬G̪åhÁÁÚhßʵØv.Ƹvó>¬«—"Þ¾€ò ñ/áÃ"#fhx1`ÅŽ6Žœ2eƒ“/˵¬y`æÎj9ƒþ Z¬èΤKw=­9µê›¬/»~]36åÙ´gÚŽŒ;wÌÝŽ{û~ |±ðá-‹#>Ž|¥òÃÌ›§|N8ºô“Ô[¿^2;àíÜGzÿï >|ÈñzË›ÿˆ>¯úõÛÛ}£ü¹ôëg¼/7¿þ‹ü½å߸րNd Z&Ñ‚f5èà^nù&á„ A(Ö….¤aXv˜Ð‡]…(âA$6e≥xÓŠ,äâI€ÐŒ1&V!aLpcZ9’4£IpÅAŠ4dI=ŠP€ÀÀA8Ƹ$IM ÀÀfH& Ò•#eé#^‚)¦’;f¦h~YP•,’)Ò›qª¹æ˜mÆ@"ü)‚ x çžÙ '*ú£":ê¤ M0ÁZP€"d£Bœ&ô©L’–¤‘QŠPD 1ÿ0åA ø¨ T+M¥’”A *‚ªi)À B|é)¯ڭ‘Ï>‹ë ÐJK-£ÂÔ+I¬‘Ädì°ÉFY@Û* e”0Ðê¥ó^ ‚¼RÆ;oõÞ«[Ÿ‘%ÀÁç¦[P”òà–”ù Â=¢éc°N¬¼ € 1ÅXÌ+ÁipðÉ(§¬òÊ,·ìòË.€@˜/Ei©¾NÚo®9[ìA« ÈK(Ï; T1¶’Jòb  L@[4»´î@Mî›ë¶=#í$¬ÑZñÕ<ôoK#6ÀÁO ¤0AS­3Øn;ù.”‹uÑ9ËÝ)Ùuÿ@ÚžEÝÒ{ 4…ª‡‹PAãwº¸âBÞ¸ÒYõÚÿ«çúyžèõ‰Žéð™~êë©nëæ¹^ìáÉNíÜÙ>î×é.ïÒùðÍ ñÈÿòÃ)–àˆbä|GÌû6=GÕçv=\ÐGOWÙ­uï=EÛk”=mågtþkéß%þøµÑúªÉoý¥Ù_þ éï×ûðƒˆÿ&¿ÌO6  C(‘j†qàe X˜*!|ˆ)“A‡l02üÑ¥wÀÛXp„#*!oNˆB©08,la‹^hœÊPF4\Ž o¨£á|Ð1!<™ã—Cèìð†A\È“D…,1M”ÌeE„<ñ0U¤Ò[˜ÅC qE¬ÎQØÅ9q„eLÕ/˜ÆÀ}Q€a LÆöÆ…L Ãù0 >úñ€ ¤ IÈBòˆL¤"iH @N¾Ù@@ÉJZò’˜Ì¤&7ÉÉNzò“  ¥(;Ù€ Ôñ”¨L¥*WÉÊVºò•r ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/TailInt1.gif0000644000000000000000000000377010520670125022060 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚x.Ed鮳Q଼$ЋP¥:¥à]îªÓ§칦Av: )­ŸÊÙŠK®“G[þ×›SÜùK"L°, !d™ûôö>/¼¶×|¾ªç®KVЇG§uG\~ZóÎ=ÿ õËY¯ öÈi ÷ÅyO øÂ‰ ù¿™ïú¼©¿û¹¹ü¶É_ý³Ù/þ°éÿÿ­ñ{¨¦‡€§1 yHއ¡q x è v‡‚›± v0ˆ ^‡ƒ•ñ u@(F‡„1¡sPÈ.‡…‰q!r`h‡†…±¡pp(þ†‡ñ!oÝ€è!憈{1¢mˆ%Ά‰wq"l È—âõŠ!Tœ‹[“E¸lQ5]|˧7;‘4aŒ¯˜2¦èŒ¡I£Zàè9š…Ž›±cYðˆ=*flDˆ©ÂÇÊ ò'…”Ì!!È@RË‘j$$ãF%ò1‹ìÉ%“ɬIr’$ˆ€ÂØ(JP>$¸ÀVÉÊVºò•°Œ¥,gIËZÚò–¸Ì%-/@€‰™’!`€†IÌbó˜ÈL¦2—ÉÌf:ó™ÐŒ&3À_ZóšØÌ¦6·ÉÍnzó›àŒN@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/Plex2Int1.gif0000644000000000000000000000431610520670125022156 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú|Ñ´x‚@|ÌülBÐWáì©Î@¸ö–ÇP_ uAà—+OøÇtEâ t±Ô² DÂc²y€±¼ÙæÁcTÓF“Ò1PÀÖÝ}MQØ™Åÿ›¼Tƒ01@@}çYjŸyöôMtw”„w˧÷DáR fÀ€ãõU/ßiœ â÷½Ú¿6EÎÑ3VžÞå…Ëó¼T@ÉT Ô˜Õ¥<êù»:NͨüòÌ7ïüóÐG@æ2K¤ãa‚œ!ßÃÌÜpÆ÷9Þ:… ürKG{DÙ——…“€x»ž?øø¡ïZ_­C_N6Ð!ö½ç}É]A&‚Ûq€c&¨@Ц5-ÅÀ×Q6­ó™%«Íäº< }ìá˜Jø(n‰…Œr!–`˜(F‰††²¡“p8(Þˆ‡€òaˆÿ€Ø'!jˆˆz2â…x'%>ˆ‰tr"ƒ ')ˆŠn²¢€°¸&-ú‡‹fòâ~À8&1⇌[2c}Ð(à !FCˆåÃFä « ) f$3Q ðTÝ;ÈÅD ;¬wù#©²cxí?[‰ª‚1"p m–ÃJ¤ŽÅadpž79^¯Z Ô(˜RšÒ“ŸTd¨V9‰ q$Èß“ÊÛ°l<ŠI\–\N‘½ÔÐ.Ù“Ì -3=Í|Ð3ÁÍ÷P IÓìN5Ù3Í-(›ÕÙfz`'¡ŒœÒ'xJ ’êùÉšë©Á.‘í°®C´ãÇûg¸¦{DGŠBL0ü|ÃcV¼hÇC”ã üþîB hoÐóòEÙô¡UÿÐu'€?@¼ß÷p€»/ùÞÂt'@ùÔÄ:ò 4êÃÂRpï5 -x @|—@ €Ñß,Ђ ô\F@·º«9( yN |P‚ûË€Å× ®Ëƒ <ÈÙc>Ëð3(dˆ ÿYØÁB0†3Œ‰ ‹˜Ãñ‰#$¬ÅóCÌq!Ïq¡»&ÀÂ`Èö,°˜,±hbAv¸žV¦Š—¹¢B®³Bþ-üãâºøGC?=ñ"QÞ»GËÈ1!nÜÕ“H¾²2‡4Ò ÁôG‹z“ÜÎ#)Ƀ42#‹t‰û2€¿ø5å“ÒÉ8æ P~j$ˆâ·¼tÒ ¨¼H¡6 ƒ\r&ü{ #xÄ¥ä’)pAàXÁµ,ˆ-@Ä‚¸ÿ‹&NnY>qÀ[áªdC*0 ôr ¿”ÉŽÈEb¶`øse2àJeR9À”Ùÿf~P 0œgÚ€ð±" ç@7 ö±&ÜüG&@ €“&…r!ÊyÎt*‚)ð¢;aè»À\ŒåN޹út™?s¸ÂPó¦Ä<Á3!àÁøH.¨N":>å½hL •˜Â”£5£ýø7P ’”ž'­ìù85¦3HuÊÁt‚"í` ðø;43'DµÍ=b‚¯&µ!üª^÷Ê×¾úõ¯€ ìF ÀϬ³%تU¨?.Úo®&)€`'KÙÊZö²˜Íìe N•T0‡Ôô`Áw«²°´ Ðc×Ù“höµ°í+еÔÎÿ.DzÝgTó÷Ö‘BÐ…è€»ÐøÐœ°t) øjiÂ*‚îƒ"p—i[PSf€A Ê8T ì‹#(Èmaƒf[…ŒÀ©pÙn]ÂZ‚H°™^Ì ÙZÕw8/"äOþ ´jæÞ÷^û™Ô™°ÀW‹;“¸¶ O!pê>kR( XPëmI Hp±,c »ÕŸ7).TÀ–YÞ“¬±îpŒ[àa€ø ô0ŽaÌ]¸z÷`©@LÃÉ‘ ¨4Ãã91R6°â5¶X<îÓÆ;“PÂé¾ÍÙ$_¢ŒeH=ù!H’ßóeîpC" swÆlŸ2oçÿÌ©‰š¹Ãæþ¸Y;pIæl§./GËWÉs¿öLåЙ°A‚N¡svh%ºb‹Zƒm•GƒçÎ á³vê|¶þxbh‰¦«Ãéaš:–FÏ©2jꔺožþnœÓ\èNzÕÒI5™#Í´FH×mæµÕnk ÏZÔµ–¢¯ l; ûkËP³;-çd 2Úš¶©Ÿ]7lgíÓó3‘«Íhb#Ü*w¼p}V·GÝ÷b7s´ krKA”® ½K$›OðX¿•³ïÎq{qÞÖOÁg4ptZ“ ÏÏÂuÔpü»9¯æw±A}ì=¼|XÅ#†îš…É@iL9 ;iDY” q”J!”˜Ñ”N‰P™RyTY•q•ÒŒÇÈ•,á•G‘•–±•b9difYh™–-°–EÑ–”ñ–i)—DA—|a—b‰—C¡—WÁ—\é—B˜V!˜UI˜Aa˜U˜N©˜\–Û—)™&–”±”%á˜Ei™>Á˜TÁ™>é™=šS!š5Iš¡œQp}Ðùß)ÿ0 )„Ö©HØÙÚ)íâ 䢇ò'™â•çéHé’幄ï葹šõ¹Ÿ;A6œO±žÈóŸòùZêj=ŠŽ¬ŸªŠX¡—ƒùI…ZÂ)º> iH± ¤1¢ñ¡!¢ Dtd¸¡]ˆ¢¡¢ Á¢)$£»V¢0j†8 4ú6*D=êl:J¡šŽô颺¸£n8¤ÀsŸ;¤Xä¤ÛV¤+˜ þ˜¤;7¡WZ¡Îx¡JʆLj‡TÊ?êR:GeªqVʇXZZªtðÙ¥Gª‰ý›a c:ˆkªgÚiŠH}Êpsê¦^–`º¥I¸§Šÿ8¨­Wˆqz ;i¢3Ñ M¨’”§Êh¤Š©‰*§mêŠoÊŸ‘j “ʨ‘訷‡‡l©ªN¥(‰ª˜èªÊç©_ ªÊ©$ʈwš›´ª%°:”*–ʘêI¿JI…*ª‡:™Ÿ*©Áú’²ú‰Ê’½ú›ššÃźÇŠKÉj&ÑÛ Ýš{×zœáÊ&ãj“ÓŠŠëú§ñ­ÝŠ+@OÚxq¤”P qBÕB¥<ë¶¬ÌØ¬ó!py–#ZüsÚtyTS ÑUL4VMUÖ®Q®/q®ã—®/‘wUT ˜DAÛ•C8fc´#¦V-³Ñ\ÿM.dúƒQû“ïZ‹ñÚ³3áÏu…Tøó`'›=-²{\äE:e?ôtV+CðA«?Ð[@g°Ò8ª¢¡pN@‘_`žÑ°öãEÐI„=˃M1D]§µNÀaÅA[».»±ãW´†Z§´¡ xˆëh S Kë=®„Cïô_àÃBúC± v‚—KDúƒF Љº– tMZ­¢Áo÷vðUj˶â#¹9+³›Û´;wúcR'À@ ¥±1!°ºÂë+G§ %¸Å¸¨»!¹Ä„Sµ yÛ^A·ûó°bå»_›& ›¶Bÿb9÷Ê/÷Ê]) Pbe 5¾•zkV}aÀa ÀA<ë&Ý‹ 0C˜·«¯P‡¿A+ÀU1Oö{¿Ü;À œ­=’¿Ã†«cÁЦ¨\BÁÝfÁW‚Á§ÁVÂÁ:'Áb¶&Â]BÂÊæÁQ‚ÂצÂPÂÂçÂKà çÀòÄU¼ÇR<ÃyLap pr¼Æƒ¬Àvÿ|È6âÇZ|Æ»šÆ:\$lÌH‰ ¸€|ÅWò!à  ‹ÌÇ=ÂÀù1pyXÌÈ6‚[°˲<Ë–µ_oRÉ”¸œËÿ·Ë¼ü~¾üËÕÌÂL|Ä\̰wÌÈÜyʼÌÒÌÎ|(ÐÍ2ÍÔ¼'Ö|Íu’ÍÚ|ËwÜÍ ÉÍàÊ<Îä(ÎæŒÇ¬œÎŽˆÎìüÁßüÎëèÎò¬SW©ñ\ÏQâ¼"Ûa µ9ë¬Ï)ÂÏA½‘V§“Ï­$8´B\±4LÔ´AÕ‹· …·Áõ°W,TÑ |£ÝÐ"òа `ë°Ù…FÀE½ÂZ‡µÿÀAÒAidVÚÕ?":Ò$ "MDÄZzÑ04Ô¿s¾^ÔE,TÔÖÓ¢üÓ.Ôµ?”Rˆ…ZU½³ TÔ„Óý”FY Õå,Õ6BÕîÄ?'mV«OõA\=% RzÄÖàÖd­Éfí#¥u ?ïÓµï“ô;†mØÄ=bÕÜSP àØÔuØêÓ}í#« ôÏ-Õ— %¥Lz›n–ýÙöGϦí"¨ÚLÂЬ½†^¨.¯½Šïii·vÛۺ½Û¼ÝÛ¾ýÛÀÜÂ=Üa§gÇ"@x¢»ÜÌÝÜÎýÜÐÝÒ=ÝÔ]ÝyG¦<ÛÚ½ÝÜÝÝÞ ýÝàÞâ=Þä½;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/FixedDelayInt1.gif0000644000000000000000000000431010520670125023174 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚x®@Y¶»Á§64Á"dI—ÁÛÎ"TéIé¸A—»¢TÀžjf ëCRŠ©¦šôiC´´@¼$üÑT›iÀ ´î™L‹)“'‡üÁ’ I‚ ,œ2»°žL§š.9ê´L¤ü[’Æ1@@µ‚ ÀÇügT“01|fqÖñ¤jŽik¬ƒ~ðpZgð§šÀ:;)·Ž®]Àzò ÜŠ•´Í%ß“ÉÙl’=„Í'ÓÊÖŒÒ<¥TÍ)Ç“ÊÓ¬<­$Í+»ËÐÌR;µôÌ-¯“ËÍì’:½ÄÌ/£ÌÊ Ó9Å”Ì1—“ÌÇ,9ÍdÌ3‹ÍÄLS8Õ4Ì5“ÍÂl“7ÝÌ7sοŒÓ6åôË9g“ν¬6íÄË;[Ï»ÌS5õäK{Å­|Îåži¬!‹JÂ… ¡1è[ê…fŸüŒ@SÄÐÍ8T-ÅÌEÍ’ÑÊl´,•ÌGш"d¤T écPú•2†¥)©I©5SÉ´¦‰Àèz¥SœB$¸À»†JÔ¢õ¨HMªR—ÊÔ¦:õ©Peê2Ÿ6„ P€V·ÊÕ®zõ«` «XÇJÖ²šõ¬h+8`Õ¶ºõ­p«\çJ׺Úõ®õ ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/PlexInt1.gif0000644000000000000000000000450410520670125022073 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìú40áà¤ÙÃÿh¶Â«D/DÞÍ6¼Ž<€‚û‰¡ªšè,)žŠŠÆ²"©°ø+-†Š‹¼ò¢§ÀÈ“ÿ]p‰ò"ãN,ˆ1nJ³r£¥à+9NŠŽ­²ã¢ð¨*="Чòc I*Aú‰¡2ä™93¶ðb¤LØxEFI’–²¤’0 ÿPpjD[ÈjjòHœdKR(DVë‹fÞ´·k{¤2ÌvÊ@g¨QMÉB¨¸E ’íJåZŠSpìeå3p„CÉ“–§’2ÏÂLH¦5<“NqxØÃ ›ÈT×6ÍÒÍ΀i&ô(UtMS¦ó^¸ U;I ÿMÍSsÓ1—-×yOz’ŸáφRO¾ záDþ™ÍAÔ.ë åß gO[Þ²]œsåAR$£{î+ŸÕTJe‡Ò QÀL½ÑEC”¡(¦4šé…º7$›s¥,ªAJ ?›âôE:½ˆôÇÔ¦:µ©(P“º ¢6IÁQYDUñ«ÃÚ*‰ººŸ €•G+%+~*0,´¦T­$kˆà"¹^ˆ®JœjKjW á†&mØ^WÚ×ýuA…EÐaÁXŠ 6¥‰ÝÏb£ØX=Ö£‘ÅÏdñ“Ùõlv=èP09¡2İ“jWËÚÖºöµ°­›00H)™v!“nwËÛÞúö·À .– ÒÛ÷¸ÈM®r—ËÜæ:÷¹ÐM@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/DemultiplexInt1.gif0000644000000000000000000000502510520670125023456 0ustar GIF89a<÷ $$$(((888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìê…8w¯^¼7EL 8¡@€`¢ða¿ ûBŽ Øf„#@PÀx˜¼P2鵕S6@°„‰ 6hй@ƒ…M€ðl‚µ ¢O'4-üj꓊'4( ¸€ÀÍ WÀíøèÍ¿ƒ7H|»ÏãXpÿX`BîÞ˜/gÎ~³uï»Ãß žä{åÏcWO=ûxì÷Íg‚|âTI¶½&^aˆ©w™kg›Là|hÓ#QhØ`"¶Yl [„Ιpˆ]_†ÒÄaMç $Â@.zcŒ2ÍHÓ<–™vîÈ#L>ÎDb-9š†FéR’7} å@Q^¹•6)°À“Gf©¥jy]e|&]cÊX¦UÀ¡™&˜E²Ù¦L Àž|öé矀*è „" §œ XYç31F*餔Vj饘fšÁ¡ð&†v2ú—5u §§<Š)êH¤þØé§P†ÿº*K­Î¤¬1ª:+HµîÊ’®¾vÔk°)K¬FÃk’±Ê^”l³#1 -EÏN ’´ÖFTm¶aË­C­ÞøíGÞŽ»©(`®G宋©#Ðé®\²Î‹Ñ¶öRÔn¾áËoDûþëï¿ÌïÀGVoÂÚâÊ0» ? ®Ãodp¾W|ÐÅö’êÁóqÈ Á+/ÉÃŒò]¯¬¯Ê.÷ÛrÌ'+Äñ¼¯›cÊ13”³Î"÷|îÌ+{p˜ÑÆB7»ûó¸Ö× %ò,tÉD£up5rsσüðÖ£uß×1›,1Ù¥¸1Ú.?ý-€@·k°Y= æUÿà¸U0Ý@|“pà !Žá&ÉýoUža†]pv+þ&dAØ1Ô¹A ÖxÖWÁD.PÓ7 Šá!$ˆð¤>¹$z½=vûovn»¸›`;ïv¯"0N’ãüƉzä¬äº@ˆå·m¦Øf Á{¹mça¢wÝc¶¢b–o;fØ}o )úó¤—nB ‡š^õr½ìL`˜ÉÝœ$ àgäsNýª“> HtKcr³=Ÿf‚µ+OK=›dS(L¡ WȺSÜ.R@ëf%ªv€4rM‚ô£ bÿ‚cÍìÆD4Ø÷úaæ#äŸÿ©p`€8² l˜Ó¹ö4&8>Írx»­YN¢ÙcŽGÊݨ~Oôáþ¤Ø ír²âêfhõ)F‹@‰D°C0N DH•8§ .F=ØYNÒ0S¢’1Žƒ‘Îè/¡uFXâcEøfž @HEæ¹â80ÃM`<˜@Xùšé€À<…N,E§¸ ÈÒ|+A€8Žò5Ç$aÿJ'ñHn/;ûI %†Å”Ü .Ó|X5³•M†mÓZÝLØ7§N‚Zåü×9›¶)dÊR›;÷8O‚¤“_ð<Ö=ó•ÿObíÓ^ý Ö?çP_ Ô]ÝÕAוÐY-Ô\ ]U;ëQQÉsžeÔCÇ•Ñ;T0™Ù\BpAÃÔ¬8mÓAùƒ¢“D Ð"hˆªzÊ $ @àm^s¢ÙÔf§mHè8Gü”HtÑNJÇ$·…n‡)‚Ž&QDž\ §4ÁxÊÓ"š¾H”!“Ûy²çý¤ç‰TÅc¬ãËV’©^ÕX5&ÖYǬøAkPÈž ‰«ì‰•Me³Lˆdo:cdÑÎzJ &G€Mêi–ª%Ç9¦ Ñe|S¢í•«F;YdãºÊ^i£ý‰ˆdIcZ)¡6BAr©A CZ”úεb¯&“â¤\ÝVb¹µVk\‡RKÃåQqâ€<p¾¬ –Ë  É¹Ð]Ô`©»<Ê »‚¬¡^HÞòš·¼PTM·[X™xMÀÂkSî*ĺˆï|£Ë^³8@¿RJnŒì› ì7À¿}ƒ%` -ØW .ЃwaMxVžÏ…W•aølXTö·âíŒøN%.Ή۔bá¬xL->Í‹‘›`†ÍøJè€t€é:ÄÈ”‡Lä"ùÈHNò10Õùx! ””§Lå*[ùÊXÎò” Û'{ùË`³˜ÇLæ2›ùÌhŽQ@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/PairsInt2.gif0000644000000000000000000001236510520670125022246 0ustar GIF89aj<÷  $$$(((,,,000444888<<<@@@HHHPPPUUUYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÊÊÊÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,j<ÿ[H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£JJµªU†,8`ØÊµ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊK·®Ý»x편*0‚ y L¸°áÈ+^Ì/ |5TàK¹²åËM  ¸:æÏ C‹¦é@gÏ£S«^ÍZcéÓ­cËžM[àk«këÞÍ›òíª¹{ NéoªÁ‹+_Îüæñ©É›KŸNÝäs©Ñ«kßνâõ¨Ù»‹ÿOžàw¨áË«_?ýüÓôìãËïíÞ)üùøó³®ßô¾þÿ^ÆSþhàR ¸T6è q¦á†ÚƒV!lf¨!P *Åà† †ÈR‡I}(â‰(ŠD"R&¦èâ‹­xT‹0Öh£C2Eã<öh^„ÀMèãD"”cQ;©$ŠG•ä’PnØäPOFi%…S Uå•\˜eP[v)¦~_æ˜hÆWæOg¦é&ykúÔæ›tngOsÖ©§twò”瞀×çNj(oƒêT行ΖhN‹"‚Tj饘fªé¦œvêé§ †*ꨞnÀ…&P@ꪬ¶êê«°jÿzA %=ŠS¤y €"ôêë¯À+ì°Äkì±È&«ì²ÆN Áƒ(°³ÔVkíµØf+lœ:’­7áZ{5ˆ€ ^ƒl@¸6‰KfÂKœ¼Åmõ.È ½ Ú;¾Äéû-¿ÐùûÀ ,Áì"ÂØ)ìÃ^R ÄÂI’Ã2AŒ± óÆqoƒT2L"o°ÆÿÌ[Ê­üRËõ¬ŸÌ»Ñì‘Í.áü²ƒ<ëæsG@·$tÃ:çWtmGs”4KKgL´ÅÿE½ÑÔ+UMrÓø=M›Ö®M Ö ×±‰=Ù±’×k›-ŸÛ²Á£Ý¢ÿ½‘ÚÊÍÞ±é}‘à'Ñ8ßìÞšá!n’âÿIžšã¬Aîã,ú­à•s®æ«iN‘å$QN¦èå‘®šé¡>’êùÉšë©Á.‘í°®C´ãÇûg¸¦{DGŠBL0ü|ÃcV¼hÇC”ã üþîB hoÐóòEÙô¡UÿÐu'€?@¼ß÷p€»/ùÞÂt'@ùÔÄ:ò 4êÃÂRpï5 -x @|—@ €Ñß,Ђ ô\F@·º«9( yN |P‚ûË€Å× ®Ëƒ <ÈÙc>Ëð3(dˆ ÿYØÁB0†3Œ‰ ‹˜Ãñ‰#$¬ÅóCÌq!Ïq¡»&ÀÂ`Èö,°˜,±hbAv¸žV¦Š—¹¢B®³Bþ-üãâºøGC?=ñ"QÞ»GËÈ1!nÜÕ“H¾²2‡4Ò ÁôG‹z“ÜÎ#)Ƀ42#‹É è½ dèK ’ p¯£ àAÔ(“OJ'£l€2`Êùáo!ñKˆ,qÒIƒØò"…Ú€ rÉ“xð ²Âà‘–l@ý,€ÃƒX€ˆ¤É¤r<à2‚üð™ÑÜcÂ0p3)fAúÄo…«’ ©À0°ÿÌ4Ó$Ili%‚ ௚ÿ#c 2`PX6 €Äá 2p†¦`|¬É1™òL œÅ'J Ͷ y-˜h7`ÑBp/OjAq‚Dž?âÈ {Ò¤P.À>ûùÏ’ÔƒÊó¨«Ù<šæ@0:zP›Ð<Á,¨Q›‡€G]vÎìµ@%=ãõèE—F°ÿë@ýî—œ¤OO}“B¥@¬bjQIrTl@‚Z-A5+¤G|ëc?èAS~ó­6Ù(Sر–•ö¡ZKàE”ºµ­H4k]1°/Ž˜ ³{mˆ;KÛÚÿÚö¶¸Í­nw+T€ô%u!áÚ€,öƒók`Iß B«"—©àœIxKÝêZ÷ºØÍ®v±Û‘:Sš%hâhÛ·UJ†¾ (N"°Ýöº÷¶@W_½«Ðö£ƒISÐV .ô¤,d,R÷gÞû•àÎ!t3ëUâ( ³¥)+ 5ÈAÆf`y0¢[S O™ØÕ6 FÁ}4ú&d€•€Ëò+’gòï¦A«!XÍgwÆAk `šF7&š]JXÀ€I¸ úû_4KÕŸöˆÔ1Y{0Ž„°­I¡0`A5²¸ÅáUãcs¸‚†·½h ÊæšYÿ eșé*àæ4±QW95˹¹ApO@B˹Œæ³M>Ü‚>U`¬÷äȰùåñ9)ÀóõÜF÷é$žI(áÔ`él’/ž.µ¢8íJ‹çÒèaõvR!‘¸º;°~¬µCë[ŽäÖÜɵ}v]^‰$À¶“ª™sê«»_ÈuèLØ g',Ú9£6‚¬]1l­AͶ ·ÁCl…$[;ÂîO¹§3îX{›iÚ>P»uýn«{ÝÒ™÷°ëýµxHßêæwÝü €ŸMà‹#8€ ¾ |äÜÕI÷Á«Må‰Õ:$§ŽÄ~ŠlÙ·r83¥]Â{w¼µ¾ÿ¶5É¥¨ð¬y\e ô¯W.È–ë‡á}Cø´MNq”{æÙæù¶_^³˜ÇKäÉx{Œ~/¤+ç%rº?iŽI›çêÓyÉîª`}FRˆÒùÄô…=bDÿYÙE}ö±7gã9ïy•SŽqª—oí½é:U¾®£¶Û€VÇß‘ä÷ sýìK;Òð>_­³\èòV¼ÔϲÂûð'ŸûÏE¢l¨óª€B?zÍC{$x€¶VÏúÖ»žZPÀƒJ€€¼þö¸Ïýê?`Z™þÚ$Ù@¬†«€øÈoÕ|ï @ ùÐÕ¢OýOA \¿ïön8 ¿F©¦à«ÿ£(3Ä+…ûÞ_ÍÿJ¯¸ÓüIAúG3ÛðïÆý Ñ{Kä?ÿÐüO¬ìGø—úÇüט1[beµ1€!Ĉ€–ñ€€²á€:HÈ X 8~GØVQ $ "@ЀäWbØ}&h(`ôƒJ£GQ‚5h7˜ƒ#8>øƒT„ˆ¢ƒTÃFQ„F(HxJØ5LXNø„P…í7…*Q€+q…XèZƒC(`†L1†È…sS…Dq†h¨j(‚tG‚4‡PˆƒIX†±‡xxsxlˆ^¨~ø‡Eˆ±N4ƒˆÿ8ŠØŒ¸iŽøˆQ‰û1ˆ‰ã†Cqˆ–˜¸“˜g•ø‰b¨‡Rȇ­á‰¦è¡¨£8…˜¬ØŠ<ñŠ©‹ðÉBQ‹¶¨¸8ºR¥ø‹IŒ¢1Œ³ˆ¾hŒ7Œ¡¡Œ¼ÍèŒ5 !Åh‰ˆŠ[¨Š¬QÜ(ØøÚ¸}w8ŽBQŽ˜qŽº!Žêøì( š89Óð-1–Ꮅ‘ú¸üXþh‡9éõXËxy(‘|QD˜Ž¹yi†y‘9‘‘V±‘}Ø‘ùŒÞH†uX‘%éŠ'¹†à¸¹’"’U!’«H’2ÿ94I6Ž8™“1±“SÑ“0ù“@)-I‡›÷Fy”û˜”‚ø’ª“NÉB™ ™:÷øTY•q•QA”SÙ”^™` b™]Y–q–O‘–£±–lYnép)r9—Q—Mq—¡‘—z|É~ €˜1˜KQ˜Ÿq˜ˆÙŠ©Œ‰Žù˜ ™I1™—Q™–™˜y!)É‘ù”Bš#9š,ñ™G¡™–Á™¨Yªi¬Y®ùš›E1›”Q›¶Ù¸IºÉ¼i›¿9ÁyÃùšÅ)ÇiɉšËÍYÏ9šÑÉ!Y9;[éÕÙ™×ùÓIÝÿi™ßéá9ãù˜åÙç)鉘ëÉíï˜ñ¹ó õ©—÷©ùùû9—ý™ÿéÊ–ŠÚj) ¡*/(‡P¹ˆÙ) i J%`(8¡"*¢ðZšKiIÑ.B.Çx¡’˜¡!±¡%Ñ¡±#£Ä³m £™(•jI–ò‰£Ò££‘ Î!¤A£$a£»ƒ¤>D¤tÉ£¢è¤:¥:Á¤ÈC¥”ÑFÊ`>—@ŠŸZêHVº—R ‹c JeŠXj=ijš x¦¹ø¦È´¦7ѦëC§§ˆr*ŒzZJ:xª@Ç’(º§L)™ª}|ÿz¨À÷ŽaꟋJn/ꨌš¨™9©î†]ÚU_Š—‘J šJoœÚ§É8ª¨"1¨)„ªWª–J©è¨¨…ÚJgpê“´ yÝ«› ©»Šy°º‡¹Z”Áz \jªÑèªÀc§6ÁªBĬ7¬©X¬cy¬’¬¾JªÀš©µz‹ÊšÒʪЊEãu•J¬)ª’ÞÊ«Dq«3± Lq®s”®YG­ßh­?Š­¢­ìЍ* šÂÚ¨û¨˜J°Èꬉ®æˆ¯Ȱ4a¯ˆ±}·®ÕÚ®¢ù®kòZK›Û˜›!ë$ ™ÛŽ%K‰³Ê± ‹±ûª±§é²6ÁR ÿÅPS- ³:Kx0‹’2{“Bâg>ZUJçY1Jž§e'Ë d+KŠ- [wE¥Œ5‚ögOÖA+€`U½´j?ë’ü:ð,AñZzõKnôµ-Ðd\Õ´nM/¶?¡E(S{™)KŸ*@ýCàu‹\-ÐËÃEc+A ¹d·j»p›±K@Õ7º°¸be ൠ^Ä?• AúƒCšK @º¶k)  ç§…+, {º'Õ¸›Ct·]d^ÊkR² ¹:!¼Òë+Øw°—ª$öuº¨Q¼ÙTG¯Ë¼ÿäB¸nB¯âŒ+$nTP«TPPQ`ä.<ë.(¥R'•Š&shb¾ÿq 3Œr¸wµ²(ÀGÀfbÀK×»=Àx¢ÀdÇÀ<âÀ~T¾LŒiBÁä›Á\®@û²,Á7¢Á›»¿ ÁowÁlÁ"l#$ )(Ìükx lÂ-\#/r,ܶD’Ãú;&3|y5 Ä'¼Ã+&A oðÊ%IloGÜ%MÜoK|%Qÿ|tFü¹`<È \Ç]ò!à P¡j´QÂÀ|2 ~ÌÃD‚ð^¨œÊª¼Ê×UdoRȽ‰‡°Ëh8Ë´Œ…¶|ËF˜Ëº\ƒ¼ÜËøËÀŒ€Â<ÌóWÌÆì}Ȝ̌²ÌÌl(ÎüÌ€ÍÒ¬'Ô\ÍtrÍØÜÈ»Íl©ÍÞ,ǤÎ Îä<Êš|Î%iÎêLáåÉág ahMšÈí¼$[õbiKR–í´FQÛh’|Ï{Má…ZQðlÿ<³;OMÐu²\—Õ/ÆATZßÄ?¦d¹\t¹ùµì,ÑÛÁGõAÀAGkRMU÷»· ÐJ„¶ÚkÏ$í#üó@ò³P­ËÒ¿ÓT d–{C™ë¼ÆÑ7&Ë5 Äd,´D-´Ñ{KÔŠeÔmÓI}#K=AUÕVKÄ@UE¹CÍDFF’„ÕY]#p‡ÐÜÓ+ðJ¯dMÔ¦L¯Kü5¾ž„Ôi=Ž#ý×8ìׂíŒ]Ø.r؈Í$„½Ø­8ŒêâØúè¢VA{¶7½˜Ùš½ÙœÝÙžýÙ Ú¢Íz {|!Ïw»ª½Ú¬ÝÚ®ýÚ°Û²=Û´M|°Ð’Ûº½Û¼ÝÛ¾ýÛÀÜÂ=ÜÝ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/MultInt1.gif0000644000000000000000000000416310520670125022105 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚x®B"dYi–ËD³µ[iCÜ;ÐÌ”n€t¹+Lb`¦ŒyШq"¬)A C kAL Ó¿Mµ™< °@ë&$&š$|ªª@"Ð9jt°*. Äòà @@„À%©¨­ÈT+˜t,pȉÙhi–:hÉ >Zp˃Šù( L=°*ÿ©æ²@ÆapЕpÑ#}˜“vP@œNÓù©£²ì°­K[ÿ¼¬,‹ì”wíóN¬ Ú %ªøãG.ùä”Wny ´I™¢YÀà«Þ½2¨™†µÅ…ÓªªÅ.5pùë°Ç;$†€âA»mP¦Ä‚*åªKçMzÕO‹nqĪOIë-‘ÝgÍØgë§{A™R@ZR[³šx“ hÖÄÛ êø}À´ÉCÝsY¬-=c‰3òæ%ÙÛî²,›ÁØ€ò å® ˆÀ^±šÒ²D¹‘`^韣lf¸²DkKLPt½•ä !Ÿ{_UAÒtp% З@2@Á öª"'DŽóÃâÌPA5Î ”Ãßì@=äÍÿÄÜ Ñ?E´Í÷“ÄÙ,?M„ÍëÅÖLQ>UTÍß“ÅÓl‘=]$ÍÓÆÐŒÑ“»v¹Ò={ÿÿ.q}Ãö-Ỽž²üùï«Ô¿ Üõõ`pÿ (B&!ØŸ‚$18ŸƒÂh`o&az‚”áw27áKv"t#nT¢q'®Uá‡!A°­ÈâG¥mŒn¥È›^ @ˆ€ ™£Œ3ŠØ\8°ÁˆP@EF@A” ,ÙälÍEP¥6npe–6âX“_Zæ˜Pš‰¥F¦c›)Ýõ \p&\°À{"—xž¤WW"ð\)Y@¥k&ª(›ƒqª)xzúH°A"Á¡"¼(Ptÿ)ª²ÊZ˜d«†¢®ÖkC$)s†Ä'¤Ðc ´A" &Ag$íH: T¨!0flÐÁ¸Ë’‰ª@ˆ;Щ}À®@î¢z¦ÉV*‘€d[:Ð¥»Z‰å¸‹Ðï®Æ•@bAD·Ñk¦Dzëc{£•>b™Á>~ð±Åˆ)$8*€©Â–‰¤‘=zKÀ[œÁËÓ&ì–É2ìð¯ {%±ƒ•¢¼'Œ8 F¯,æ"«hÕP~,*kg™v à@«Užé-KÛ!]$Ûsà =ld©U[­˜e„ä÷Fÿš¤£~ßûè½ÊB (™á"~êüím¤XV[çÆ")àöå˜g®ùæœwî¹çpÀÜU{¸T6>3©\; ¹OG»’ ¾‰ƒ½±Ø"¸K³ä¨Ý"Ð+y€9çÒ'ÄÔÎù1ƒÂè-•tÀç €ë@ÆhϽ/P7•æ·PÉuäìgIçÊkÇ…ÛÈ«'©·æÚÁ‹ D*¦°Z•@ºþŒè `Õ%Z‰À¤:Ôÿ"V)\ D€ŒŸ[p»ä½‡xŸú ]àA»€0„q;¡nTˆÂü°ð8-Ô l²5Ã~…†É±!qb8¼PñW>ü¡Îÿj(Ä!æ°ˆN "ݤÄ%b‡Ürâu¨(N‡ŠK±¢x°h-²‡‹Ø# ½ø3)ª¨‰fŒ"Óø1vÇŸ"£ýØX9šŽu„cjô˜(;Šñãèøˆ'A¦$¤kù%C*‘qdB$Ù)4Br–¼ä#oCIÓ0’%üÌ'Á¤É9rr”, ¥Pù!UÄ•wÚ+'ËÆ”ò޲¼åO©KLæ²—›\#0]˜ÉaÚò—Æ4L1YËÍÒ@Íl¦Z¢ùL5S HæA3Ô„€a§8ÇIÎršóœèL§:×ÉÎvºóê¬@Æ,ÀøÌ§>÷É$Ï~úóŸ ¨@JЂ4  Ѐ6ÊІ:ô¡¨D'ú’€;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/NorInt1.gif0000644000000000000000000000423610520670125021723 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(͡ڼ € Û"”Xi¹ÊœiÈ0y替 -WPÊ´å„óGø§³FžmlÓÂÑæ _óöµl¹vzEïÄ@iWwuFJ ׄ{žÝð&®Ý¿ÿpžNS{”„lË÷6Fžq`ÀLÃ{²Ë¿õ%ïâ&ÔëÁÛÞvNÌXxz‡_4[½uË»u¼èêÜl˜GSc3Æ.ûì´×nûí¸P€Ý…nÑpçŽ÷/¼åM¾ºc­£mV±/à:r¾W4áš ø—ºjÙÍ!>knÖ:ÿ^ôñŒ¯ 4´4ÁÇCÏo‚ú[O°¾Ô›ãÁgÏëÒª¸Ž< €àAŸ™ X)މ’rà– ø( b‰‚Œ²`”0˜( :‰ƒ†òà@8(†ˆ„€2¡†PØ'^ˆ…zráƒ`x'2ˆ†t²ap' ˆ‡nò¡ÿ€¸&!f2"~د%$|Qb}˜Xt=­nÀL€Œ6*JÇ'3ÈÅDPÌDŠòñ"r²“Åpõ>[عˆª‚±"p mœ+: DÅaãñS7¢ñ=€Ô ˜B–j€ºJäm9‰ |sä¢$Oòñ(&e pYj0É?þ±¦ì£7y¡C²‡•rez`ù 4I–à¡%{0×€á²;ºLOç$ÔKk¥2˜à)AìzùËê s"Ê4§IÍi  F©¬c6 ¢Ì à"h¦tžYa~3ŒâD9¥3sž’·Z'r*ÆwfSžçƒ'­ðɃžt‡Ÿ Óg¬š@¾Š ¼'*·i0…2ôSUBÝÑSMT:þÔÍE¡WÑV-t›½ÍF‹ÒÓŒT7è@6Pµ‡*Ä0’LgJÓšÚô¦8Í©000¹4!€‘P‡JÔ¢õ¨HM*Š€ÀŸ:õ©PªT§JÕªZõªXÅI@;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/AndInt1.gif0000644000000000000000000000334610520670125021670 0ustar GIF89ašK÷ $$$(((000888<<<@@@DDDHHHPPPYYY]]]aaaeeeiiiqqquuuyyy}}}………•••¡¡¡®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,šKÿWH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœIÓaŠ Cl8Q³§ÈVˆAOŸH;–X±tÄÒvšÑD„²jÝʵ«×¯`½&‘t„¨2ø`V`ÛŒ 2¨ )¢ÀÑžm ¤X±!ÃÛ·O ði!Ò¼nýž]Ø¢‰>/\8|6*ã '‡ zñqäÉ>_^á`ƒY²UÌ-è¹§d¤7W^‘õ†$ª8 aµÀÖ5_'õÀ€Þ¿!»=œã­ÇU§)©ÉسkßÎ]ò®.ÿø<üz÷óè/|ß~üòæŸg>}fuø‹GONÆÝÈ TŸL÷ùW‘j Sn¤ L ŽTAM¾¡HP¨\pÌiÔ5B†¤œÅT¡KR”™@8ð–#¦arfÀŒ5’8ÓŠ-µ8Q>î¸6Ò$KBJtÂŽ+ U‚^OÖ¨À^?nH]‡éU8ÖRø¨¢– õåP!¤–5Ù EKB@ à5Ôe É  s®°äŸøXã}25B zŽÀ'cŒõ©”ry‘  æß’ (°ÎDb-9š†FéR’7} å@Q^¹•6)°À“Gf©¥jy]e|&]cÊX¦UÀ¡™&˜E²Ù¦L Àž|öé矀*è „" §œ XYç31F*餔Vj饘fšÁ¡ð&†v2ú—5u §§<Š)êH¤þØé§P†ÿº*K­Î¤¬1ª:+HµîÊ’®¾vÔk°)K¬FÃk’±Ê^”l³#1 -EÏN ’´ÖFTm¶aË­C­ÞøíGÞŽ»©(`®G宋©#Ðé®\²Î‹Ñ¶öRÔn¾áËoDûþëï¿ÌïÀGVoÂÚâÊ0» ? ®Ãodp¾W|ÐÅö’êÁóqÈ Á+/ÉÃŒò]¯¬¯Ê.÷ÛrÌ'+Äñ¼¯›cÊ13”³Î"÷|îÌ+{p˜ÑÆB7»ûó¸Ö× %ò,tÉD£up5rsσüðÖ£uß×1›,1Ù¥¸1Ú.?ý-€@·k°Y]RæqÿP³G$L@C“ÜÿfPÕÙÈY˜´sA;¯HæÕE0‹ Ô4BŠ Ú`º9š–þ¤Ýv› “ºðz‹ÚÁ“¨¿wú“ŠýÍkÖ˜ÓÀæ‹~PèÏa¶œb·ièm@žfo†-@¡bÎaoXó×±¨t¦Á֛͉¦Û%!Îo ‡o¼AÈS¿›&,ð%ƒ Âô/G= KšNhSšÈ:( *d‚å$hkƒñ_üL¢>›p€SÌ 7ÈÁzƒÜ2¿Ít†5½ Žu4 =ô%2Tb"·ë, M%:‘aǶÜL0}À ž ÿ8•¼¯ È3Z.8¼Ž7ßCš ’æB^€É³38 €1=Ìú€è ír*¢çFˆCmæ2ƒÛLÒ œÅ8Ž©b‰& CC- Ÿh@`@jà‚æ d§8½“¨­gQ#–Øx¾™çÌ0  ˜G ˜@@ ¸ðÙÈ<‚¡.0úΡœÀxX¡ î•¡ÔÍ'DÌI`<Œ›Éä‚ÊôRˆÁ”Éݨuc"s"GäV%ÍlMóaÕ´Ö5–Íim3aÝ„VØž¹FrÊÌ!ñ2g8›õM‚­SYíü×;O~Í“XõÌ×=ƒ•ÿO{íÓWýœ×?wPw tVã$çAWõÈg.TT]×CUPÁdFH ÁcÛ0 *sÊæ˜áŠ|g#@4Dê¨GC43o ¤MšÙ6,` Ð(ALTÚ‘”4½“ÜBtSìèÑa ŠÈS€ Ü0u°Äé†yš ¶Inç¹âQñ¹¥âŒ¢±¤ázÊžXy´ uÈy¬³U‘ÖTªì)‘ÈJU R2dr»àtüÇ £¥§nýkŽèšÒÝUcˆsLè¢Ëø&‡í©ÑNFØŸNƪcŠhAÌÖº^ö°Ó,a‚dYêVG •˜hâ$ˆ´Ö¬+M«CSû°ÕåFdâ’fµd[ˆ8 Èm®h˰Þ>dh®p[³ QNÊ…­9 õÁêZ÷ºÖ€¢TjNã:ä¹h€F ]rz·!È€xÉ;ܳž—!X¯n‰›°÷.„ì¯{e‹ÌÝ^ɾÇò¯”L,‰ÀÁ20ì+LjÁ»r°† <+ ˆÂ«²°€0,* χÌò0|@|'{‡Äm:@ÎÊ œÕ!8@¦fLãÛøÆ8αŽiŒtîÅ ©¡†Lä"ùÈHN²’‰Ì€ÒùÉP޲”§Lå*[ùÊXβ€;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/Integrate1.gif0000644000000000000000000000411610520670125022431 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚x®C,+R¥9¥à]îJŸE«iE œz“¼Mµ™ íuÖ¬3¬`Cp¬ŸPæò-òN8Ýûcq 0ñ'µÛö²e3™åÙY]6²n@&íR°5ýËÒïlîTEÀ÷’©ŠJÇ‘? Vp1ZGà;Òp#ÂzÔÖæ¢À=p9TБ“Ám°8$Ð…Âð7%ôÏ y“Âý¬07-ÄÏ mÃúÌp65”Ï a“Ã÷ì°5=dÏÿUÄô ñ4E4ÏI“Äñ,14MÏ=ÅîLq3UÔÎ1“Åël±2]¤Î%ÆèŒñ1etΓÆå¬11mDÎ Çâ̱0uΓÇßìñ/}äÍýÈÜ r/…´Í!ñ’ÈÙ,ò.„Í#ù²½^UÈ’Â$E&IÁJj0äcQ$[ÃÉzò“)å[F©U攨¤V,}ËY&”)båi\©]:—&òehxiaz†˜e1æf©˜ZÚrx³T&f˜IiV†š?±¦d° gÚ2þÂ$8ŸÙàH§:×ÉÎvºóðŒ§<çIÏzÚóžò¼F3N…p€ ¨@JЂô M¨BÊІ:ô¡ eúIÑŠZô¢ͨF7ÊÑŽz41;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/Merge2Int1.gif0000644000000000000000000000440710520670125022306 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú,QÀÌÁ´]pÁÉ?'„/¹ÊœiÈ'5ö¯Óý® ø‹Ðf&½þéáž,î¿"xp²s$x€oÙh ÷˜¿$œÕi;‚ !pwL8ÿÄ@ZWç5D©PÀk¸`_ð[¸€îÆ«…ë›@ñ¯¿`o<„}ñxNH¸|ƒ?”_þZm&¸º}!Þ³q>رo@‚âþvyƒ£ãôÁŒ§§—ºC*‹Û€¿ @;Ø  ký ñE»@`fµÕò/Sc3–oþù觯þúìP€Ý-ßPjÑpë°³m=fµö¯Ú•{Ûæž¦ñ‰Î,!(ßh#8¦™„7a³¼ ýÜšôÏ÷?ŸkÀ‚ ÊžƒÖçxR¨µÀÍ|• | ehzŠ‘µï£ )HP#l¢Ê¤¹h‡ðh<}DYz¶—v'¦ì™M bÓêà4=8OII«Ÿv¨±2ê~z*¥â‡©Èqj} Z©¢©¯²ê ±ª*­V‘«§òªM*VðPU7eX[UÑgžõ6im YÛšËtÀ¤ àJb鯀 ¬`KØÂÖG˜öº À豬d'KÙÊZE ¸%c7ËÙÎzö³  ­hGKÚÒÞ& ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/IdentityInt1.gif0000644000000000000000000000416010520670125022752 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xîB8;TÊ“œzÐËZ¶b¯mÐå®1Ñê  Aé§$D«)A|¤0jûî4ÕfðÀ¿­«­tL0¦Ó’ L ¬´!Ð)¨:ò¥K¶,ÐÊ—ÅÕ &ÿ«qB£›@ƒ~ &š$|:ô˜À]À¤Ó6šêÐjž¹çÂ-¥ Nã\™Nó|ñÏ=úÁ˜Iº¤‰~Ðô²žy0¨MÓYgòÿ*›“vwÍUyP6b7”èáŒ7îøãG.ùäNp@Î'=ºj¦jÚY; iÝžfL‹+¦ƒS”Ç.ûì³àAbŽ3Úi€$ÎqÒ°ŽJ:Þ'Jëꙺ“×Àø\ÿ5@ØúñnШCC@t(Jl¡s&ÂÊ«€»Ìš~LÐ{¤AÙÔ?fxâcnR»e)8“ÈR—ê%þe` `Òâe£ü _I[¼˜”%y¹$~‰ÀÓªW˜  H{$ך1<€ƒžáH¢µ€ýƒR!r`¨ ‡†²¡ppH þ†‡ò!oÿ€è!憈û1¢mˆ%Ά‰õq"l ()¶†Šï±¢j°È-ž†‹éñ"iÀh1††Œã1£gÐ5n†Ýq#fà¨9V†Ž×±£dðH=>†Ññ#céA&†Ë1¤a‰E†‘Åq¤` )Iþ…’¿±¤_0ÉMî…“¹ñ$^@iQÞ…”³1%_JÈ/†¨r.¨„Í+áËÖÌò-µTÍ-ÃÊVF0Êåiv©a’†˜f1fhYe¦˜.ræf˜IB_N„šT‘&f°ùÂ^Z³MÐd‘6+ÃMÈxó›Cç8%SΞ¬ó1íäÉ;O}¡"°W+óyUχ„€Ø€@JЂô M¨BÊІ:ô¡]耱~2„ P€F7ÊÑŽzô£ ©HGJÒ’šô¤()8`Ñ–ºô¥0©LgJÓšÚô¦Ñ ;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/NumbersInt2.gif0000644000000000000000000001271210520670125022577 0ustar GIF89aD<÷  $$$(((000444888<<<@@@HHHPPPYYY]]]aaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,D<ÿUH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“*]Ê´©Ó§P£J*0„…«X³jÝʵ«×¯`ÊK¶¬Ù³hÓª]˶­Û·pãÊKWîš ÔÝË·¯ß¿€ L¸°aº$È ¡€ªãÇ#KFHÀDÌ«“3kÞÌy(—-tMº´i•ŸCŸ^ͺµëˆ©ab~M»¶íÓ±_ξͻ·ï©¹]îþM¼¸q¡Á[?μ¹ó˜ÉY.N½ºuÑWN¿Î½»÷‡ÙUnÿÿN¾<ùð)Ç›_ÏÞ9z”êÛËŸÏûýÉøôóëÇ Z¶èýÈŸjh`fö™„ß 6ˆT‚%-èà„ú!IV¨á†4]8R††("jýéö߈(¦Ø’‡"¨â‹0^ÄbH.Æhã ÍR8öèã@:~ÄãDÚ¤GC©dŠGv”ä’PrØ$GOFiå„SnTå•\˜¥F[v)æ~_fæ˜hÊW&Fg¦éfyk^Ôæ›tr§EsÖ©çswV”瞀×'EjhoƒNTèA%TÀÀ£F*餔Vj饘fªé¦œvŠi'Lxž–jꩨ¦ª*¥XFR¢-ÿZ\­¸æªë®¼öêë¯À+ì°Ä ¬8˜Âëì³ÐF+í´¼Vp@¨#Á‘¬M€Aƒ |Ð`Š1(A¯–(܉!ik\4È­qó äîCõªp/qðÊËnùîÛPÀêØ/ƒùþF0" ìÛÁ&ìÛÂþ¥Û ÄJÜÅ&ZÌ Æÿ+ Çëz| È#‹ Éʩܑý¡¼²Ëû±,ÍÁÌ›ÌjÌ›ÍÚᬑηñ\³Ðô-Òm›Ñúù|›Òé1-cÁBŸÔ¶Q ŸÕ9]›ÖIƒÍž×÷™M‘Ø´‘=×µ¡­ Ú±ýšÛòÁM›ÜÒÿ-‘Ý®áÝžÞ¯ñ¡ß°a àg#þá:žâ2¾á®AÞ¢äÞšåæaÞšæ4rž#åû^žè¬‘.Pi:Cž³¦:y¬¯æ: \ »ÉÞþøìÖÙL‚ D PÊ«à@`º`¯Pí« ï]î§±l‚\°À*Œ/\€¨Çj}BØŸ¦}wÜ›Æò¼€æ«€¾½û]¶Ú—Ÿùq§~¥¹_þT@þ‘Ï ï´ô>„ÄÏ4¼IÃ2]Èß €‚ ôŽw@g°x!¬‚αþ `€Øy€†!ô 'h&ä‚¥É`ñÿ|È× ‰ˆ"i„X ŽÆˆHB"H&Rlj¢“¤h/*†$È€DÐ0’ÀVAÁTè ¨ðŒ$[bÅç Œ¶"ãAÔÈF6äŒzÌõz¢E6Ì‹ Y€ô €&Ä„ ú ÒÀƒl`¹¤ <ÐHÄ.|/©£o@Pƒ P‘4läA* JƒP “Êë_AH°=Τᡸ¨/D~d„rÜ †GÆ0E`è‘cܨÇÚ²|(ù§MºD”½ "PÊœr 5ÒÀt¦PÐÔ£²™Lm2ÐÈ+7Pÿ\äp!DüY`ªÀ„ü£¡H@CDÒƒà÷"ÀP 4€ã[#*ï‘q’ø;Ÿ/?ÎÞã,ç9b¾€| t€ô.ðJE:€ !´çKê?é]³bäHPÐòÒnŠÌ(ùFˆpÓƒg\à$ÓùRîO‚*È©A_'Uß…‚ßh~€R”’s¥aHˆ‚é]4€ˆ]N’Nß™|ÝÜŸú~ ÔCrde@QvÔ‘vd„é£^ÿê€é}u’å?ßJÆnUõê0G•(2°  ­hGKÚÒšö´¨M­jWËZ”.€—Ùêødê€Æÿ:à­¾ó€KÑ9δ’o’ ÜkM ÐÚâ—µ(§BJ‘ËÚó¹•íª XôªÒ é+o*ÞÅQ}Šœ øIG±ÒçDuá)9ÂàÓ¡Ñó@%i¸VÎÒ°§<½k|÷çÁS&õUÁÊš_‡Ä8"`,ˆ 3™>Ë€`‚¶ú±eÀÈG>N×wgœã„éê™7”–Ï}+;¦ï>2 Æ[…ñŒj¼²ïv¼å5bÖÌ·,,G&Òm©yÿ2`pA(ðÞïF¹=ˆ29ã (רû}Œü8¸ªÂþJtPûÚ.Ú¼ô‚íÄÞܱEŸìÎ=“ôÆ(]2KÓGS´_G—ÒÅÙófn¼Ë@WÔQÓôÏ8Ý2W§Ö[“õÔh}3[ëÕÄQµfX­(^/×eu£¶ì!ûmºîš±—æë>;oÑŽÛ´«Ví*^{pÙÞÛ¶¿Öíù[aá.ܸÓVnùœ{ÒÊ.5³åíìx§¬Ý‘Ã7{Þ½i{{{Äf¿gíï—™:Šú^ÏÀw]pŽ|ÝÞnx¬¾#ˆ›ûÛ“øÐ¾EŠŸã—Kwæ,~8“gáÒÿÖxFnòï \Û*oÇ ÙìKÇÛ-§9½mþ›‡mæ+ôt }žq¡÷ÚèÇ&zÈsôQóá€ø¸¤Æ}ø(€Øj¼á&8!è~)XlÓׂˆ‚Ø,HƒPñ‚ãwƒ¬‘ƒ:è<øˆƒ%„.hƒ#ØHCèEøƒGØ„;¨„•¶zSH…Bh…†…ZHOØQ¸@ø…G†¬1†§Q†fXh¸jhl؆Cñ†²„H‡U˜€>H†Y¨‡gÈ…µ¶‚ˆn(ˆGç…†ÈvhqÿXs¸ˆ=ш¥ñˆ¤‰’¸”H–8˜˜‰9±‰£Ñ‰ñ‰ x¢Ø¤È¦xŠ5‘Šœ±Š›ÑŠ®8°¸²¨´X‹1q‹š‘‹™±‹¼ø¾ˆ 1è>38ŒuˆˆA“ŒÊÅ8À8ÂøŒ+’1’QÖ˜ØÚÜØ'ñŽ1ŽäXæøèø긎#ÑŽŽñŽŽòôHöHø˜±ÀqŒn按)ý8ÿx‘Q±RÑ© Y‘q‘O‘‘P±‘ié ù"9’Q’Mq’N‘’*),É.Ù0“ÿ1“KQ“Lq“8é:©<¹>ù“ ”I1”JQ”F©Hù  h„Ø”0ñ”G¡”IÁ”TyViX‰Z¹•Ñ•Eñ•G–b9dIfih™–*°–ž•øÂ=ñ–i)—ÈA—6f—<—b©—AÑ–E˜[)˜@A˜Da˜T‰˜?¡˜CÁ˜M阗ú5•p©”Ù)’i”›ÉŸù“¡¹£y~…˜™ qš:‘š ¸š¬é®™°Ù²9›ɌԆ™IqpÂ9œ^¡ƒ§µ‰·y—¹ÙË"ÄÒ pœH‘œ7±œÙœ<w âvI6ÿ¡;QšQv#‡œ¼Ém¾yè)uêɇxh„Jñž­ã—$¹žäÖžFaŸºƒŸ!ž5Až:ažáŸÝ +©ŸìÆŸE ö£ ! b™ !l5a ¡ $¡2É scý rXŸ8ŸRXŸ$º::šJÊA-š“ Ú7"ú +Š;7ú/*1Š3:5úD? ”9ZrJGšEIÚA ºJE*OÊgQz”KJuŠˆ[ºj]ºS CzYc:leê”_ªuM:mšWª¤òy…µÇ;Q§“q§R§¥³£NÚ£Ãc¢؇kȧ:ÿá§’¨^š§]¸§*zv6q¦/‘¦6±¦ᨑ©f*¨G¨tj¨Ûó¦ ©.¡©ʨ9ᩪp*©ƒ¦îiªôƒª¡ª+R¥Ë¥«,Á©«!«©*ªGDªBA¬Ža¬»Š¬7§ËŠ«¬Á«,ÁªXêª8Á¬Tá¬\ ­'­Aá­S®×*®:G‚•š?v/æh”fˆ*‚zš|Üú €-8E­lÚHŒ;/á]AK¦H«‰H©AÁ`üšUþ ó¤(°75LìÄFcth;"ðbñ4# ²¶$ÎÔVñ…Oz´O½yêÚt )€Rÿ‹- 7Bl´XvÕP ±[ ÀP8„YK>V] õ@ µV:´[(v°ƒž1+v½! f³»pÇÃHKæ³éM6¶Y•O´¤LcT>lKFk±å? 6Ix•N" \ìy g‰Š¢¬ñ ¦W¸Z°ûÅÀä³_%GÙÅXÓsIÒ£<–;·¥bç£C+–·ó…U¸¤+)€f¯“Ê!°xŠÇHeP@Ô£Uäó=ad–A‚¤»*À»ý³L& ¯Ô±Ä»?sK·`VÀ¥W¡{®;½¸"µDè« ®½q¸‚åB9Ëaÿ–U&S­òRÑS¾ÉÓ;ÿ`u!díû¾êe·ŸÛbñª£n¢­Í!NT&±*=eé“· !`XÖQéCaÐcGÅ$ÁáéSLóŠFe¦BéChü›&þËeæ*Ú{!Lv‹{EÖÊ)l%',(Ø‹3\1 7L/\9ü;ü=L?ìA\µ½ç&EÜG¬°Í¨Ä+lG-ŒÂ5|M¼3QCSLʺ$KÌWü·÷*&_¼a¬ºµŠ&e¬g ƒ]¬$kœm܃€ %qŒs|½o\$w|y …UlJ[ŒÃYÜ,†\‡ÿl;…\DƒÌÉL‹œ=|“|‡cÜ%}l—숑lNü›\\‰Ÿ\e¡ü0•io2ÄÏ1ÊDQÊœxÊ* Ë£ËCa˪H˺̸,½Œ‹¼œÊ1³Ê©FÌ'šÉ\òËAÌ¿8ÌoÂÌ@áÌÆ¸ÇD"Í?AÍÒÍPl©FÂÍi‚Í>¡ÍÙÎjlÌÁ†Ìb¼ºdŒÎèÖÊæ<&s'wt×%®ì"pÖ;!PÆ'&÷ì€ÇUÐ}ÐС¥´›åH!KQIÑXð£ÒPM$ê¾æÃ<ñ<dz ¿ ÀOã M›4>±CKàblÍYV²i × µ>ÄÕ]í#øB´´TLAësC¦Õ¦>¶¢¾Å»5”‘ôViMCmE°Iä×#øs±ÈCØ;bH+B4>É4Fm @ I;{׬}]n»ÕOÝÙ"Rœ¤J>KÚ²Ý?³…>‰…ÕÐX’e]–•]!Ô¶_%SKEB&dØUÚn Ùó´VÌä"&M†¸¯kÜùÓX«ÜË-_õ=7…Ø9´ÔÊRÕac­P ¤LðäR 0¼lKß!µVÈ=Eµ]ÞtHÞ^!>àXÂÙž‰žà ²à î%þà€èà ^ádán†ØÃ°á®ˆûl)P+Ô{â(žâ*¾â,Þâ.þâ0ã}W!Rº8žã:¾ã<Þã>þã@äB¾ã± ~äHžäJ¾äLÞäNþäPþ&;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/PairsInt1.gif0000644000000000000000000000405510520670125022242 0ustar GIF89a=÷ $$$000444888<<<@@@PPPYYY]]]aaaqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææòòòöööÿÿÿ,=ÿIH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O‘$J´¨Ñ£H“*]Ê´©Ó§P—^øIõä ¢jÝʵ«×¯GQµlÈ ̪uè ÂÚ·ÛÂkP(Ý»åâ¥kw¯_…zÿ®í+¸ðÀÀ†«N,1cŸ‹ïu,ygäÊt)cÆyyó[Ížkvm4i™£OS5­úeêÖ=YÃfùz¶NÙ¶SÖÎ}7o“»Óô-|dðâ1‰#y|¹KåÎ;6¾:uÓ¯£´®ýböî%¹ƒÿ§ø}¼Hñæ#–Oÿ={‡ëßst/aüúqÝâ—.a?KúþÕÕ_€)Hà@÷(‘ &¨ D èàƒléG!y^xž…ª—a‡íq"|Ž8Ÿˆ&ÚWbŠù±H¢‹'ÂÈЄ2’!4Êxc€9¸£=ºøã~A²8$~Eâ× Y_’õ0A“(ÖHÐzLù`!PieBåu€– JIBPÀ9)_g¨™@$,Àæ™,€™eNY@!@¹ùÞeAi’@Ii¢Lö‰' bJ¡ì]6Aeúh¤ˆIæfš™©Aœ¦ç)¨$$ÿÚÁ¨xšJaªS®Zh•_’pYhf0êdàÀ˜À.°Áƒ PP§³$ð«¼~ÙÙ.Ðe´ PÐlÝ~ÙªyPŽ8îxå‚xnDYZÐÁ´M°¬B8«ØŠ½"´A—»ÞTÀžÿBpŸ ÑZP´šŠ†ïNSm¦Að+кý)±}С\b*Â’˜¾+ШKj, p¶°N P­`1¿?d±  šl¦ª¦·*ê(¤ª ê¿$±î*M`ï@XÿÁ"ÈK‚÷$„%÷$Ôûý²Ý3™e¥ —Ï´ VŠžG÷ºGÄ¿YýÎÝO!ÿËñ߃ˆ*ˆ€Å1à(ˆ¿q`€ È ú‡‚¹±à~0h ⇃³ñ`}@ʇ„­1á{P¨²‡…§qaz`Hš‡†¡±áxp肇‡›ñawÿ€ˆ!j‡ˆ•1âu(%R‡‰qbt È):‡Š‰±âr°h-"‡‹…ñbqÀ(1 ‡Œ1ãoÐè5ò†{qcnàˆ9Ú†Žw±ãlðÈ—ååk!|œ‹aH¸ ²5…|Ë!U“ÈÁøñ i¤ZyIš…’¤±dY0MÞ ’ñ$U8éQþ„”û£‹P‰SBæ‘ ¤V,ÂÊʸ²'µ”Ì-y’ËÇìÒ2°œåaT™¢^2&§‚$2…ùàˆ¦4§IÍjZóšØÌ¦6·ÉÍnzó›Ú¼$ÆL†p€ H§:×ÉÎvºóðŒ§<çIÏzÚóžòdÊÉÏ~úóŸ ¨@JЂ4:;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/TimesInt1.gif0000644000000000000000000000430110520670125022237 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áì²]° ¡ÎÕK/á³* ä€@`ƒƒ×5,Ùjƒ&.C@€Ù€ŽÓ­ —2鞘h<€ $@x~\0ò鳦oëL½Zµ έwÞâ»UóþÜÄpÈ£‘ÿÌ-½&ïåÀ…‡†^}úñî5ùšÿÏ\8`âàyROÏÖ6{œëß›u/¿füú?éã—y?Íèù7SÆä@Ô]0È K‚é÷àJ^¸ÒJH¡…¢”!a$`â‰(¦¨âŠ,¶èâ‹&С‡,¢J#êU<öèã@)äDÉ£Œ@6Þ(âwN¾$B’Tb”#別H dU]¹%HZŽùQU*hæIe®I’˜nnÔfœ!ÁI'FsÞé‘zV”gŸñ ¨D*W“†^Th¢ ÊhC‹>*‘£’*i¥QŠéA—nʦžÔi¨ JjfPžÊ‘©¤Žªªš¯>ÿäj¬a"J+§©Þj«¡ÎJ+¯žú+°› û*±˜«*²•*{*³’þ9AsºÖZíByzFmµÐ>߀@`äZv×vËèzBàAô&p ך n¢ëM¯sŽa7¶ùêkkÁýþ¡œï¾†®÷Wð¶€4À-`ºçc, ‚ ¤VÁŠ-€€b Œ³¤B<(Í¡Ú\Ñ´"gs¼CÚ–GB²8}C€¼7©ÁŠy¤nܰµ§‘zÔäm89œ® ÒZ˜Ì¤äNEJÇhÌoo¼$&Ey–G1)ËRƒ€Xø¡å…€Ya>ˆ˜ò1&ƒùe²‡Mb&{œ™žÃ5`AÒL5Á; ]•©ÜfwJp¼kf<â”H„žÇÎvº³¨Q*U9σ³Cx€ÎÙ¦tJ§›ù4?«ãOäL  ¿Œ#­ Zœ ˜-¡õdè +‰‚0¢«¬g…(ú*‹‚g Òñ¨ô8ª*‘ª£mH‘cR鬴8-EÎKuÓâÌô65ÕÍMO“ÓÛì”4==Í:POd-¥ ±ÀŒÄÔ¦:õ©PªT§ê# LHUH`ÄÕ®zõ«` «XÇŠ"œ2«hM«Z×ÊÖ¶ºõ­p«\×;jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/doc-files/ParaplexInt1.gif0000644000000000000000000000465410520670125022745 0ustar GIF89a<÷ $$$888<<<@@@HHHPPPYYYaaaiiiqqquuuyyy}}}………•••¡¡¡¥¥¥®®®²²²¶¶¶¾¾¾ÆÆÆÎÎÎÖÖÖÚÚÚÞÞÞæææîîîòòòöööÿÿÿ,<ÿMH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§O!&HJ´¨Ñ£H“*]Ê´©Ó§P£2µPâ§Õ’ Dʵ«×¯`Ã"mpàªÙ 2œ]ëPÁ¶p1·®Áìú40áà This provides an assortment of plug-and-play CSP components to wire together (with int-carrying wires) and reuse. Primarilly they are for education/demonstration purposes, but some have value for general applications (e.g. {@link org.jcsp.plugNplay.ints.DeltaInt}, {@link org.jcsp.plugNplay.ints.DynamicDeltaInt}, {@link org.jcsp.plugNplay.ints.PlexInt}, {@link org.jcsp.plugNplay.ints.MultiplexInt}, {@link org.jcsp.plugNplay.ints.DemultiplexInt}, {@link org.jcsp.plugNplay.ints.ProcessReadInt}, {@link org.jcsp.plugNplay.ints.ProcessWriteInt}, ...).

The educational purpose is to demonstrate how simple it is to build layered networks of communicating processes. Each component works to a clean channel interface. Component instances can just be wired together. A network of such components is itself another (CSP) component. Network design and analysis takes place independently at each level - we do not have to think about the whole network hierarchy to reason about each level. This enables us to construct components with arbitrarilly rich behaviour without running into combinatorial explosions of complexity.

Examples are given of networks with 20-30 processes (threads). Because of the component layering, we never need to consider more than about 5 at a time and it is easy to see what they do and that they are without deadlock, livelock, starvation or race-hazard problems. jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/ProcessWriteInt.java0000644000000000000000000001135011105701167022040 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Writes one int to its output channel. *

Process Diagram

*

*

Description

* ProcessWriteInt is a process that performs a single write * to its out channel and then terminates. The int * that is written must first be placed in the public value field * of this process (which is safe to set before and in between * process runs). *

* ProcessWriteInt declaration, construction and use should normally * be localised within a single method -- so we feel no embarassment about * its public field. Its only (envisaged) purpose is as described in * the example below. *

Channel Protocols

* * * * * * * * * *
Output Channels
outint * All channels in this package carry integers. *
*

Example

* ProcessWriteInt is designed to simplify writing in parallel * to channels. Make as many instances as there * are channels, binding each instance to a different channel, * together with a {@link org.jcsp.lang.Parallel} object in which to run them: *
 *   ChannelOutputInt out0, out1;
 *   .
 *   .
 *   .
 *   ProcessWriteInt write0 = new ProcessWriteInt (out0);
 *   ProcessWriteInt write1 = new ProcessWriteInt (out1);
 *   CSProcess parWrite01 = new Parallel (new CSProcess[] {out0, out1});
 * 
* The above is best done once, before any looping over the * parallel read commences. A parallel write can now be performed * at any time (and any number of times) by executing: *
 *     write0.value = ...;   // whatever we want sent down out0
 *     write1.value = ...;   // whatever we want sent down out1
 *     parWrite01.run ();
 * 
* This terminates when, and only when, both writes have completed -- * the events may occur in any order. * * @see org.jcsp.lang.Parallel * @see org.jcsp.plugNplay.ProcessRead * @see org.jcsp.plugNplay.ProcessWrite * @see org.jcsp.plugNplay.ints.ProcessReadInt * * @author P.H. Welch and P.D. Austin */ public class ProcessWriteInt implements CSProcess { /** The int to be written to the channel */ public int value; /** The channel to which to write */ private ChannelOutputInt out; /** * Construct a new ProcessWriteInt. * * @param out the channel to which to write */ public ProcessWriteInt(ChannelOutputInt out) { this.out = out; } /** * The main body of this process. */ public void run() { out.write(value); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/PlusInt.java0000644000000000000000000001205011105701167020330 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Sums two integer streams to one stream. * *

Process Diagram

* *
 *    in0  _________
 *   -->--|         | out
 *    in1 | PlusInt |-->--
 *   -->--|_________|
 * 
*

Description

* PlusInt is a process whose output stream is the sum * of the integers on its input streams. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1int * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows how the use of this process in a small program. * The program also uses some of the other building block processes. * It generates two sequences of numbers, adds them together and * prints them to the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class PlusIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new NumbersInt (b.out ()),
 *         new PlusInt (a.in (), b.in (), c.out ()),
 *         new PrinterInt (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class PlusInt implements CSProcess { /** The first input Channel */ private final ChannelInputInt in0; /** The second input Channel */ private final ChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new PlusInt process with the input Channels in0 and in1 and the * output Channel out. The ordering of the Channels in0 and in1 make * no difference to the functionality of this process. * * @param in0 the first input Channel * @param in1 the second input Channel * @param out the output Channel */ public PlusInt(final ChannelInputInt in0, final ChannelInputInt in1, final ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessReadInt[] procs = {new ProcessReadInt(in0), new ProcessReadInt(in1)}; final Parallel par = new Parallel(procs); while (true) { par.run(); final int i0 = procs[0].value; final int i1 = procs[1].value; out.write(i0 + i1); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/OrInt.java0000644000000000000000000001213011105701167017764 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Bitwise ors two integer streams to one stream. * *

Process Diagram

* *
 *    in0  _______
 *   -->--|       | out
 *    in1 | OrInt |-->--
 *   -->--|_______|
 * 
*

Description

* OrInt is a process whose output strean is the bitwise or * of the integers on its input streams. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1int * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows how to use the OrInt process in a small program. * The program also uses some of the other building block processes. The * program generates a sequence of numbers and rounds each even number up to * the nearest odd number and prints this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class OrIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new GenerateInt (b.out (), 1),
 *         new OrInt (a.in (), b.in (), c.out ()),
 *         new PrinterInt (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class OrInt implements CSProcess { /** The first input Channel */ private final ChannelInputInt in0; /** The second input Channel */ private final ChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new OrInt process with the input Channels in0 and in1 and the * output Channel out. The ordering of the Channels in0 and in1 make * no difference to the functionality of this process. * * @param in0 the first input Channel * @param in1 the second input Channel * @param out the output Channel */ public OrInt(final ChannelInputInt in0, final ChannelInputInt in1, final ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessReadInt[] procs = {new ProcessReadInt(in0), new ProcessReadInt(in1)}; final Parallel par = new Parallel(procs); while (true) { par.run(); final int i0 = procs[0].value; final int i1 = procs[1].value; out.write(i0 | i1); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/TailInt.java0000644000000000000000000000771711105701167020314 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * The output stream is the tail of its input stream. *

Process Diagram

*

* The output stream is the tail of its input stream. *

Description

* The first integer (i.e. head) of its input stream is not forwarded. * The rest (i.e. tail) is copied through unchanged. *

* Two inputs are needed before any output * is produced but, thereafter, one output is produced for each input. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Implementation Note

* The implementation uses an {@link IdentityInt} process for the copy loop: *
 *   public void run () {
 *     in.read ();                           // accept, but discard, the first item
 *     new IdentityInt (in, out).run ();     // copy the rest of the stream
 *   }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class TailInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new TailInt process with the input Channel in and the * output Channel out. * * @param in the input Channel * @param out the output Channel */ public TailInt(final ChannelInputInt in, final ChannelOutputInt out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { in.read(); new IdentityInt(in, out).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/PairsInt.java0000644000000000000000000001001711105701167020464 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Generates sums of successive pairs of input values. *

Process Diagram

*

External View

*

*

Internal View

*

*

*

Description

* PairsInt is a process whose output is always the sum of its previous * two inputs. *

* Two inputs are needed before any * output is produced but that, thereafter, one output is produced for each * input. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public final class PairsInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new PairsInt process with the input Channel in and the * output Channel out. * * @param in The input Channel * @param out The output Channel */ public PairsInt(final ChannelInputInt in, final ChannelOutputInt out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannelInt a = Channel.one2oneInt(); final One2OneChannelInt b = Channel.one2oneInt(); final One2OneChannelInt c = Channel.one2oneInt(); new Parallel(new CSProcess[] { new Delta2Int(in, a.out(), b.out()), new PlusInt(a.in(), c.in(), out), new TailInt(b.in(), c.out()) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/MultiplexInt.java0000644000000000000000000001325111105701167021374 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Fair multiplexes its input integer stream array into one output stream * (carrying source channel and data pairs). *

Process Diagram

*

*

Description

* MultiplexInt is a process to convert multiple streams of * ints to a single stream in such a way that it can be * {@link DemultiplexInt de-multiplexed} later. * The protocol on the outgoing multiplexed stream consists of * an int, that represents the channel identity of the * multiplexed data, followed by the multiplexed data. *

* The ordering of the channels in the in array makes * no difference to the functionality of this process -- the multiplexing * services all channels fairly. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in[]int * All channels in this package carry integers. *
Output Channels
outint, int * An out message is an index followed by the multiplexed data. *
*

Example

* The following example shows how to use MultiplexInt in a small program. *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class MultiplexIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt[] a = Channel.one2oneIntArray (3);
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a[0].out ()),
 *         new FibonacciInt (a[1].out ()),
 *         new SquaresInt (a[2].out ()),
 *         new MultiplexInt (Channel.getInputArray (a), b.out ()),
 *         new CSProcess () {
 *           public void run () {
 *             String[] key = {"Numbers ",
 *                             "            Fibonacci ",
 *                             "                          Squares "};
 *             while (true) {
 *               System.out.print (key[b.in ().read ()]);   // print channel source
 *               System.out.println (b.in ().read ());      // print multiplexed data
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.ints.DemultiplexInt * @see org.jcsp.plugNplay.ints.ParaplexInt * @see org.jcsp.plugNplay.ints.DeparaplexInt * @see org.jcsp.plugNplay.ints.PlexInt * * @author P.H. Welch and P.D. Austin */ public final class MultiplexInt implements CSProcess { /** The input channels */ private final AltingChannelInputInt[] in; /** The output channel */ private final ChannelOutputInt out; /** * Construct a new MultiplexInt process with the input Channel in and the output * Channels out. The ordering of the Channels in the in array make * no difference to the functionality of this process -- the multiplexing * services all channels fairly. * * @param in the input channels * @param out the output channel */ public MultiplexInt(final AltingChannelInputInt[] in, final ChannelOutputInt out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final Alternative alt = new Alternative(in); while (true) { int index = alt.fairSelect(); out.write(index); out.write(in[index].read()); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/SuccessorInt.java0000644000000000000000000001034711105701167021365 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Adds one to each integer in the stream flowing through. *

Process Diagram

*

*

Description

* SuccessorInt increments each integer that flows through it. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows how to use the SuccessorInt process in a small program. * The program also uses some of the other plugNplay processes. The * program generates a sequence of numbers, adds one to them and prints * this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class SuccessorIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new SuccessorInt (a.in (), b.out ()),
 *         new PrinterInt (b.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class SuccessorInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new SuccessorInt process with the input Channel in and the * output Channel out. * * @param in the input Channel * @param out the output Channel */ public SuccessorInt(ChannelInputInt in, ChannelOutputInt out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) out.write(in.read() + 1); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/PrefixInt.java0000644000000000000000000001013211105701167020641 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Prefixes a user-supplied integer to the int stream * flowing through. *

Process Diagram

*

*

Description

* This is a process which first outputs a given integer and then * copies its input stream of integers to its output stream. *

* One output is gererated before any input but, * thereafter, one output is produced for each input. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Implementation Note

* The implementation uses an {@link IdentityInt} process for the copy loop: *
 *   public void run () {
 *     out.write (n);                        // prefix the given integer to the stream
 *     new IdentityInt (in, out).run ();     // copy the stream
 *   }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class PrefixInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** The initial int to be sent down the Channel. */ private final int n; /** * Construct a new PrefixInt process with the input Channel in and the * output Channel out. * * @param n the initial int to be sent down the Channel. * @param in the input Channel * @param out the output Channel */ public PrefixInt(final int n, final ChannelInputInt in, final ChannelOutputInt out) { this.in = in; this.out = out; this.n = n; } /** * The main body of this process. */ public void run() { out.write(n); new IdentityInt(in, out).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/SubstituteInt.java0000644000000000000000000000744211105701167021571 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Substitutes a user-configured constant for each integer in the stream * flowing through. *

Process Diagram

*

*

Description

* SubstituteInt is a process that substitutes the (constant) n * with which it is configured for everything recieved on its in channel. * So, its output stream has constant values but its rate of flow is triggered by * its input. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public final class SubstituteInt implements CSProcess { /** The int to be sent down the out Channel. */ private final int n; /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new SubstituteInt process. * * @param n the integer to be sent down the out Channel. * @param in the input Channel * @param out the output Channel */ public SubstituteInt(final ChannelInputInt in, final ChannelOutputInt out, final int n) { this.in = in; this.out = out; this.n = n; } /** * The main body of this process. */ public void run() { while (true) { in.read(); out.write(n); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/RegulateInt.java0000644000000000000000000001336711105701167021171 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This process controls the rate of flow of traffic from its input to output channels. *

Process Diagram

*
 *     in    _______________________________
 *   --->---|                               | out
 *    reset | RegulateInt (initialInterval) |-->--
 *   --->---|_______________________________|
 * 
*

Description

* RegulateInt produces a constant rate of output flow, regardless of * the rate of its input. * At the end of each time period, it outputs the last object input during that period. * If nothing comes in, the previous output will be repeated * (note: this is defined to be zero if nothing has ever arrived). * If the input flow is greater than the required output flow, data will be discarded. *

* The interval (in msecs) defining the output flow rate is given by a constructor argument. * This can be changed at any time by sending a new interval (as a Long) * down its reset channel. *

Channel Protocols

* * * * * * * * * * * * * * * * * * * * * * *
Input Channels
inint * The input stream. *
resetjava.lang.Long * This resets the time interval between outputs (milliseconds). *
Output Channels
outint * This carries samples from the input data, sampled at the * defined rate. *
*

Implementation

* See here (for the implementation * of {@link org.jcsp.plugNplay.Regulate} – which is the same apart from regulating Object, * rather than int, traffic). * * @see org.jcsp.plugNplay.ints.FixedDelayInt * @see org.jcsp.plugNplay.ints.RegularInt * * @author P.H. Welch */ public class RegulateInt implements CSProcess { private final AltingChannelInputInt in; private final AltingChannelInput reset; private final ChannelOutputInt out; private final long initialInterval; /** * Construct the process. * * @param in the input channel * @param out the output channel * @param initialInterval the initial interval between outputs (in milliseconds) * @param reset send a Long down this to change the interval between outputs (in milliseconds) */ public RegulateInt (final AltingChannelInputInt in, final AltingChannelInput reset, final ChannelOutputInt out, final long initialInterval) { this.in = in; this.reset = reset; this.out = out; this.initialInterval = initialInterval; } /** * The main body of this process. */ public void run () { final CSTimer tim = new CSTimer (); final Guard[] guards = {reset, tim, in}; // prioritised order final int RESET = 0; // index into guards final int TIM = 1; // index into guards final int IN = 2; // index into guards final Alternative alt = new Alternative (guards); int x = 0; // holding object long interval = initialInterval; long timeout = tim.read () + interval; tim.setAlarm (timeout); while (true) { switch (alt.priSelect ()) { case RESET: interval = ((Long) reset.read ()).longValue (); timeout = tim.read (); // fall through case TIM: out.write (x); timeout += interval; tim.setAlarm (timeout); break; case IN: x = in.read (); break; } } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/DynamicDeltaInt.java0000644000000000000000000001631011105701167021746 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import java.util.*; import org.jcsp.lang.*; /** * This process broadcasts integers arriving on its input channel in parallel * to its output channel array -- those output channels can be changed dynamically. * *

Process Diagram

*

*

Description

* A DynamicDeltaInt process is a broadcasting node whose array of broadcasting * channels can be changed dynamically. Any process can become one of the recipients * of the broadcast by sending the DynamicDeltaInt a channel on which it will be * listening. A process may leave the broadcast be re-sending that same channel. *

* In each cycle, DynamicDeltaInt waits for either its in or configure * channel to become ready, giving priority to configure. *

* Anything arriving from in is broadcast in parallel down each element * of its array of out channels. *

* The configure channel delivers ChannelOutputInt channels -- anything * else is discarded. If the delivered ChannelOutputInt channel is not * one of the channels already in the output array, it is added -- otherwise it is removed. *

*

*

Channel Protocols

* * * * * * * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
configjava.lang.ChannelOutputInt * All channels in this package carry integers -- except for this one, * which accepts only {@link org.jcsp.lang.ChannelOutputInt} objects * (discarding all others). *
Output Channels
out[]int * The output Channels will carry a broadcast of whatever * integers are sent down the in Channel. *
* * @author P.H. Welch and P.D. Austin */ public final class DynamicDeltaInt implements CSProcess { private AltingChannelInputInt in; private AltingChannelInput config; private Hashtable hash; private Parallel par; /** * Construct a new DynamicDeltaInt process with the input channel in and * the configuration channel configure. * * @param in the input Channel * @param config the configuration channel */ public DynamicDeltaInt(AltingChannelInputInt in, AltingChannelInput config) { this(in, config, null); } /** * Construct a new DynamicDeltaInt process with the input channel in, * the configuration channel configure and the initial output * channels out. The ordering of the channels in the out array make * no difference to the functionality of this process. * * @param in the input channel * @param config the configuration channel * @param out the output channels */ public DynamicDeltaInt(AltingChannelInputInt in, AltingChannelInput config, ChannelOutputInt[] out) { this.in = in; par = new Parallel(); if (out != null) { hash = new Hashtable(out.length); for (int i = 0; i < out.length; i++) addOutputChannel(out[i]); } else hash = new Hashtable(); this.config = config; } /** * The main body of this process. */ public void run() { Guard[] chans = {config, in}; Alternative alt = new Alternative(chans); while (true) { switch (alt.priSelect()) { case 0: Object object = config.read(); if (object instanceof ChannelOutputInt) { if (hash.containsKey(object)) removeOutputChannel((ChannelOutputInt) object); else addOutputChannel((ChannelOutputInt) object); } break; case 1: int message = in.read(); Enumeration hashChans = hash.elements(); while (hashChans.hasMoreElements()) ((ProcessWriteInt) hashChans.nextElement()).value = message; par.run(); break; } } } /** * Adds a Channel to the list of output Channels. This method is * private as the only way clients can add Channels is via the * configure Channel. */ private void addOutputChannel(ChannelOutputInt c) { ProcessWriteInt p = new ProcessWriteInt(c); par.addProcess(p); hash.put(c, p); } /** * Removes a Channel from the list of output Channels. This method is * private as the only way clients can remove Channels is via the * configure Channel. */ private void removeOutputChannel(ChannelOutputInt c) { ProcessWriteInt p = (ProcessWriteInt) hash.get(c); par.removeProcess(p); hash.remove(c); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/TimesInt.java0000644000000000000000000001207411105701167020474 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Multiplies two integer streams to one stream. * *

Process Diagram

* *
 *    in0  __________
 *   -->--|          | out
 *    in1 | TimesInt |-->--
 *   -->--|__________|
 * 
*

Description

* TimesInt is a process whose output stream is the product * of the integers on its input streams. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1int * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows how the use of this process in a small program. * The program also uses some of the other building block processes. * It generates two sequences of numbers, multiplies them together and * prints them to the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class TimesIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new NumbersInt (b.out ()),
 *         new TimesInt (a.in (), b.in (), c.out ()),
 *         new PrinterInt (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class TimesInt implements CSProcess { /** The first input Channel */ private final ChannelInputInt in0; /** The second input Channel */ private final ChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new TimesInt process with the input Channels in0 and in1 and the * output Channel out. The ordering of the Channels in0 and in1 make * no difference to the functionality of this process. * * @param in0 the first input Channel * @param in1 the second input Channel * @param out the output Channel */ public TimesInt(final ChannelInputInt in0, final ChannelInputInt in1, final ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessReadInt[] procs = {new ProcessReadInt(in0), new ProcessReadInt(in1)}; final Parallel par = new Parallel(procs); while (true) { par.run(); final int i0 = procs[0].value; final int i1 = procs[1].value; out.write(i0 * i1); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/SquaresInt.java0000644000000000000000000000675011105701167021042 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Generates the integer stream 1*1, 2*2, 3*3, etc by a somewhat unusual route. * *

Process Diagram

*

External View

*

*

Internal View

*

*

Description

* SquaresInt generates the sequence of squares of the * Natural numbers (starting from 1). *

*

Channel Protocols

* * * * * * * * * *
Output Channels
outint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public final class SquaresInt implements CSProcess { /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new SquaresInt process with the output Channel out. * * @param out the output channel */ public SquaresInt(final ChannelOutputInt out) { this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannelInt a = Channel.one2oneInt(); final One2OneChannelInt b = Channel.one2oneInt(); new Parallel(new CSProcess[] { new NumbersInt(a.out()), new IntegrateInt(a.in(), b.out()), new PairsInt(b.in(), out) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/NorInt.java0000644000000000000000000001226111105701167020147 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Bitwise nors two integer streams to one stream. * *

Process Diagram

* *
 *    in0  ________
 *   -->--|        | out
 *    in1 | NorInt |-->--
 *   -->--|________|
 * 
*

Description

* NorInt is a process whose output strean is the bitwise nor * of the integers on its input streams. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1int * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows the use of this process in a small program. * The program also uses some of the other building block processes. * It generates a sequence of numbers and calculates the negative values * and prints them on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class NorIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 *     final One2OneChannelInt d = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new GenerateInt (b.out (), 0),
 *         new NorInt (a.in (), b.in (), c.out ()),
 *         new SuccessorInt (c.in (), d.out ()),
 *         new PrinterInt (d.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class NorInt implements CSProcess { /** The first input Channel */ private final ChannelInputInt in0; /** The second input Channel */ private final ChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new NorInt process with the input Channels in0 and in1 and the * output Channel out. The ordering of the Channels in0 and in1 make * no difference to the functionality of this process. * * @param in0 the first input Channel * @param in1 the second input Channel * @param out the output Channel */ public NorInt(final ChannelInputInt in0, final ChannelInputInt in1, final ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessReadInt[] procs = {new ProcessReadInt(in0), new ProcessReadInt(in1)}; final Parallel par = new Parallel(procs); while (true) { par.run(); final int i0 = procs[0].value; final int i1 = procs[1].value; out.write(~(i0 | i1)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/NumbersInt.java0000644000000000000000000001076411105701167021032 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Plugs together a network of low-level stateless components * to generate the sequence of natural numbers. * *

Process Diagram

*

External View

* *
 *         ______________  
 *        |              | out
 *        |  NumbersInt  |-->----
 *        |______________|
 * 
*

Internal View

* *
 *         ___________________________________________
 *        |  _______________             ___________  |
 *        | |               |           |           | | out
 *        | | {@link PrefixInt PrefixInt (0)} |----->-----| {@link Delta2Int Delta2Int} |-->-- 
 *        | |_______________|           |___________| |
 *        |     |                              |      |
 *        |     |          ______________      |      |
 *        |     |         |              |     |      |
 *        |     +----<----| {@link SuccessorInt SuccessorInt} |--<--+      |
 *        |               |______________|            |
 *        |                                NumbersInt |
 *        |___________________________________________|
 * 
*

*

Description

* The NumbersInt process generates the sequence of Natural numbers. *

*

Channel Protocols

* * * * * * * * * *
Output Channels
outint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public class NumbersInt implements CSProcess { /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new NumbersInt process with the output Channel out. * * @param out the output channel */ public NumbersInt(final ChannelOutputInt out) { this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannelInt a = Channel.one2oneInt(); final One2OneChannelInt b = Channel.one2oneInt(); final One2OneChannelInt c = Channel.one2oneInt(); new Parallel(new CSProcess[] { new Delta2Int(a.in(), b.out(), out), new SuccessorInt(b.in(), c.out()), new PrefixInt(0, c.in(), a.out()) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/SignInt.java0000644000000000000000000001145211105701167020312 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Converts each input int to a String, prefixing it * with a user-defined sign. *

Process Diagram

*

*

*

Description

* Sign converts each input int to a String, * prefixing it with a user-defined sign. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * Almost all channels in this package carry integers. *
Output Channels
outjava.lang.String * The output will be of type String. *
*

Example

* The following example shows how to use SignInt in a small program. *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class SignIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt[] a = Channel.one2oneIntArray (3);
 *     final One2OneChannel[] b = Channel.one2oneArray (3);
 *     final One2OneChannel c = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a[0].out ()),
 *         new FibonacciInt (a[1].out ()),
 *         new SquaresInt (a[2].out ()),
 *         new SignInt ("Numbers ", a[0].in (), b[0].out ()),
 *         new SignInt ("            Fibonacci ", a[1].in (), b[1].out ()),
 *         new SignInt ("                          Squares ", a[2].in (), b[2].out ()),
 *         new Plex (Channel.getInputArray (b), c.out ()),
 *         new Printer (c.in (), "", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.Sign * * @author P.H. Welch and P.D. Austin */ public final class SignInt implements CSProcess { /** The user-defined sign to attach to each item */ private final String sign; /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutput out; /** * Construct a new Sign process with the input Channel in and the * output Channel out. * * @param sign the user-defined signature to attach to each item. * @param in the input Channel. * @param out the output Channel. */ public SignInt(final String sign, final ChannelInputInt in, final ChannelOutput out) { this.sign = sign; this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) out.write(sign + in.read()); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/DeltaInt.java0000644000000000000000000001006711105701167020444 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This process broadcasts integers arriving on its input channel in parallel * to its array of output channels. * *

Process Diagram

*

*

Description

* Delta2Int is a process that broadcasts (in parallel) on its * array of output channels everything that arrives on its input channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
out[]int * The output Channels will carry a broadcast of whatever * integers are sent down the in Channel. *
* * @author P.H. Welch and P.D. Austin */ public final class DeltaInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channels */ private final ChannelOutputInt[] out; /** * Construct a new DeltaInt process with the input Channel in and the output * Channels out. The ordering of the Channels in the out array make * no difference to the functionality of this process. * * @param in the input channel * @param out the output Channels */ public DeltaInt(final ChannelInputInt in, final ChannelOutputInt[] out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessWriteInt[] procs = new ProcessWriteInt[out.length]; for (int i = 0; i < out.length; i++) procs[i] = new ProcessWriteInt(out[i]); Parallel par = new Parallel(procs); while (true) { final int value = in.read(); for (int i = 0; i < out.length; i++) procs[i].value = value; par.run(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/Merge2Int.java0000644000000000000000000001420711105701167020534 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Merges two strictly increasing int input streams into one * strictly increasing output stream. *

Process Diagram

* *
 *    in0  ___________
 *   -->--|           | out
 *    in1 | Merge2Int |-->--
 *   -->--|___________|
 * 
*

Description

* Merge2Int is a process whose output stream is the ordered merging * of the integers on its input streams. It assumes that each input stream is * strictly increasing (i.e. with no repeats) sequence of integers. * It generates a strictly increasing output stream containing all -- and only * -- the numbers from its input streams (eliminating any duplicates). *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1int * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

Example

* The following example shows how to use Merge2Int in a small program. * The program also uses some of the other plugNplay processes. The * program prints, in ascending order (up to Integer.MAX_VALUE), all integers * whose prime factors consist only of 2, 3 and 5. Curious readers may like * to reason why the infinitely buffered channels are needed. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.ints.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class Merge2IntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt[] a = Channel.one2oneIntArray (4);
 *     final One2OneChannelInt[] b = Channel.one2oneIntArray (3, new InfiniteBufferInt ());
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 *     final One2OneChannelInt d = Channel.one2oneInt ();
 *     final One2OneChannelInt e = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new MultInt (2, a[0].in (), b[0].out ()),
 *         new MultInt (3, a[1].in (), b[1].out ()),
 *         new MultInt (5, a[2].in (), b[2].out ()),
 *         new Merge2Int (b[0].in (), b[1].in (), c.out ()),
 *         new Merge2Int (c.in (), b[2].in (), d.out ()),
 *         new PrefixInt (1, d.in (), e.out ()),
 *         new DeltaInt (e.in (), Channel.getOutputArray (a)),
 *         new PrinterInt (a[3].in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.ints.MergeInt * * @author P.H. Welch */ public final class Merge2Int implements CSProcess { /** The first input Channel */ private final ChannelInputInt in0; /** The second input Channel */ private final ChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new Merge2Int process with the input channels * in0 and in1 and the output channel out. * The ordering of the input channels makes no difference * to the behaviour of this process. * * @param in0 an input channel * @param in1 an input channel * @param out the output channel */ public Merge2Int(ChannelInputInt in0, ChannelInputInt in1, ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { int x0, x1; x0 = in0.read(); x1 = in1.read(); while (true) { if (x0 < x1) { out.write(x0); x0 = in0.read(); } else if (x0 > x1) { out.write(x1); x1 = in1.read(); } else { out.write(x0); x0 = in0.read(); x1 = in1.read(); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/Delta2Int.java0000644000000000000000000001050011105701167020516 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This process broadcasts integers arriving on its input channel in parallel * to its two output channels. * *

Process Diagram

* *
 *         ___________  out0 
 *    in  |           |--->---
 *   -->--| Delta2Int | out1
 *        |___________|--->---
 * 
*

Description

* Delta2Int is a process that broadcasts (in parallel) on its two output channels * everything that arrives on its input channel. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
out0, out1int * The output Channels will carry a broadcast of whatever * integers are sent down the in Channel. *
* * @author P.H. Welch and P.D. Austin */ public final class Delta2Int implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The first output Channel */ private final ChannelOutputInt out0; /** The second output Channel */ private final ChannelOutputInt out1; /** * Construct a new Delta2Int process with the input Channel in and the output * Channels out0 and out1. The ordering of the Channels out0 and out1 make * no difference to the functionality of this process. * * @param in the input channel * @param out0 an output Channel * @param out1 an output Channel */ public Delta2Int(final ChannelInputInt in, final ChannelOutputInt out0, final ChannelOutputInt out1) { this.in = in; this.out0 = out0; this.out1 = out1; } /** * The main body of this process. */ public void run() { ProcessWriteInt[] parWrite = {new ProcessWriteInt(out0), new ProcessWriteInt(out1)}; Parallel par = new Parallel(parWrite); while (true) { int value = in.read(); parWrite[0].value = value; parWrite[1].value = value; par.run(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/ParaplexInt.java0000644000000000000000000001762211105701167021173 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Parallel multiplexes its input integer stream array on to one output stream. *

Process Diagram

*

*

Description

* ParaplexInt is a process to convert multiple streams of * ints to a single stream. It assumes data will always be available * on all its input streams. In each cycle, it inputs in parallel one * int from each of its inputs, packs them into an array and outputs * that array as a single communication. *

* The parallel input means that the process will wait until something arrives * from every input channel, accepting items in whatever order they turn up. * The ordering of the channels in the in array, therefore, makes * no difference to the functionality of this process. *

* Caution: the process receiving packets from ParaplexInt * must agree to the following contract: *

* Input of an array * packet means that previously input arrays must not be looked at any more (neither * by itself nor any other processes to which they may have been passed). *
* Supporting the above, there is one more rule: *
* There must be only one process receiving array packets * from ParaplexInt (i.e. its output channel must not be connected * to a {@link org.jcsp.lang.One2AnyChannelImpl} or {@link org.jcsp.lang.Any2AnyChannelImpl}). *
* The reason for these obligations is to remove the need for ParaplexInt * to generate a new array packet for each paraplexed communication * -- an array that will normally be discarded by the receiving process after * dealing with its contents. * Instead of that, ParaplexInt operates a double-buffered protocol, * constructing and reusing just two array packets. It switches between them * after every cycle. In this way, it fills one packet while the process * receiving its output consumes the other one. This is safe so long as that * receiving process agrees to the above rules. * See the Low Level example in {@link org.jcsp.lang.Parallel} for the details * of this implementation. *

* Note: the above two constraints should work naturally with most applications. * However, by converting the first rule into a protocol where the receiving process * explicitly returns the packet (through an acknowledgment channel) * when it has finished using it and before inputting the next one, the second * rule could be dropped. This is trivial to do by piping the output from * ParaplexInt through a simple cyclic process that inputs a packet, * forwards it (down a {@link org.jcsp.lang.One2AnyChannelImpl} or * {@link org.jcsp.lang.Any2AnyChannelImpl}) and waits for the acknowledgment * (for which only a {@link org.jcsp.lang.One2OneChannelImpl} is needed). * *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in[]int * Most channels in this package carry integers. *
Output Channels
outint[] * A packet carrying the paraplexed data. *
* *

Example

*
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * class ParaplexIntExample {
 * 
 *   public static void main (String[] args) {
 * 
 *     final One2OneChannelInt[] a = Channel.one2oneIntArray (3);
 *     final One2OneChannel b = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a[0].out ()),
 *         new SquaresInt (a[1].out ()),
 *         new FibonacciInt (a[2].out ()),
 *         new ParaplexInt (Channel.getInputArray (a), b.out ()),
 *         new CSProcess () {
 *           public void run () {
 *             System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n");
 *             while (true) {
 *               int[] data = (int[]) b.in ().read ();
 *               for (int i = 0; i < data.length; i++) {
 *                 System.out.print ("\t\t" + data[i]);
 *               }
 *               System.out.println ();
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.ints.DeparaplexInt * @see org.jcsp.plugNplay.ints.MultiplexInt * @see org.jcsp.plugNplay.ints.DemultiplexInt * * @author P.H. Welch */ public final class ParaplexInt implements CSProcess { /** The input channels */ private final ChannelInputInt[] in; /** The output channel */ private final ChannelOutput out; /** * Construct a new ParaplexInt process with the input Channel in and the output * Channels out. The ordering of the Channels in the in array make * no difference to the functionality of this process. * * @param in the input channels * @param out the output channel */ public ParaplexInt(final ChannelInputInt[] in, final ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessReadInt[] inputProcess = new ProcessReadInt[in.length]; for (int i = 0; i < in.length; i++) inputProcess[i] = new ProcessReadInt(in[i]); Parallel parInput = new Parallel(inputProcess); int[][] data = new int[2][in.length]; int index = 0; while (true) { parInput.run(); int[] buffer = data[index]; for (int i = 0; i < in.length; i++) buffer[i] = inputProcess[i].value; out.write(buffer); index = 1 - index; } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/AndInt.java0000644000000000000000000001174111105701167020115 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Bitwise ands two integer streams to one stream. *

Process Diagram

*

*

Description

* AndInt is a process whose output stream is the bitwise and * of the integers on its input streams. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1int * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows how to use the And process in a small program. * The program also uses some of the other building block processes. The * program generates a sequence of numbers and rounds each odd number down to * the nearest even number and prints this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class AndIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new GenerateInt (b.out (), Integer.MAX_VALUE - 1),
 *         new AndInt (a.in (), b.in (), c.out ()),
 *         new PrinterInt (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class AndInt implements CSProcess { /** The first input Channel */ private final ChannelInputInt in0; /** The second input Channel */ private final ChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new AndInt process with the input Channels in0 and in1 and the * output Channel out. The ordering of the Channels in0 and in1 make * no difference to the functionality of this process. * * @param in0 an input Channel * @param in1 an input Channel * @param out the output Channel */ public AndInt(final ChannelInputInt in0, final ChannelInputInt in1, final ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessReadInt[] procs = {new ProcessReadInt(in0), new ProcessReadInt(in1)}; final Parallel par = new Parallel(procs); while (true) { par.run(); final int i0 = procs[0].value; final int i1 = procs[1].value; out.write(i0 & i1); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/XorInt.java0000644000000000000000000001220411105701167020156 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Bitwise xors two integer streams to one stream. * *

Process Diagram

* *
 *    in0  ________
 *   -->--|        | out
 *    in1 | XorInt |-->--
 *   -->--|________|
 * 
*

Description

* XorInt is a process whose output strean is the bitwise xor * of the integers on its input streams. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in1,in2int * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

Example

* The following example shows how to use this process in a small program. * The program also uses some of the other building block processes. * It generates a sequence of numbers, XORs them with * Integer.MAX_VALUE to give a decending sequence of numbers * (from Integer.MAX_VALUE) and prints this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class XorIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     One2OneChannelInt a = Channel.one2oneInt ();
 *     One2OneChannelInt b = Channel.one2oneInt ();
 *     One2OneChannelInt c = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new GenerateInt (b.out (), Integer.MAX_VALUE),
 *         new XorInt (a.in (), b.in (), c.out ()),
 *         new PrinterInt (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class XorInt implements CSProcess { /** The first input Channel */ private final ChannelInputInt in0; /** The second input Channel */ private final ChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new XorInt process with the input Channels in0 and in1 and the * output Channel out. The ordering of the Channels in0 and in1 make * no difference to the functionality of this process. * * @param in0 The first input Channel * @param in1 The second input Channel * @param out The output Channel */ public XorInt(final ChannelInputInt in0, final ChannelInputInt in1, final ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessReadInt[] procs = {new ProcessReadInt(in0), new ProcessReadInt(in1)}; final Parallel par = new Parallel(procs); while (true) { par.run(); final int i0 = procs[0].value; final int i1 = procs[1].value; out.write(i0 ^ i1); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/BlackHoleInt.java0000644000000000000000000000634711105701167021245 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Black holes anything sent to it. *

Process Diagram

*

*

Description

* BlackHoleInt is a process that accepts everything sent to it. * This class can be used to ignore the output from a process while ensuring * that the data is always read from the channel. *

* Note: this functionality is (more efficiently) provided by * a {@link org.jcsp.lang.BlackHoleChannelInt}. *

Channel Protocols

* * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public final class BlackHoleInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** * Construct a new BlackHoleInt process with the input Channel in. * * @param in the input channel */ public BlackHoleInt(final ChannelInputInt in) { this.in = in; } /** * The main body of this process. */ public void run() { while (true) in.read(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/IntegrateInt.java0000644000000000000000000001165211105701167021336 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * This is a running-sum integrator of the ints on its input stream * to its output stream. *

Process Diagram

*

External View

* *
 *          ______________  
 *     in  |              | out
 *    -->--| IntegrateInt |-->---
 *         |______________|
 * 
*

Internal View

* *
 *         ____________________________________________
 *        |  __________                   ___________  |
 *     in | |          |                 |           | | out
 *    -->---| {@link PlusInt PlusInt}  |------->---------| {@link Delta2Int Delta2Int} |---->--- 
 *        | |__________|                 |___________| |
 *        |     |                              |       |
 *        |     |       _______________        |       |
 *        |     |      |               |       |       |
 *        |     +---<--| {@link PrefixInt PrefixInt (0)} |---<---+       |
 *        |            |_______________|               |
 *        |                               IntegrateInt |
 *        |____________________________________________|
 * 
*

Description

* The IntegrateInt class is a process which outputs running totals of * the Numbers sent down its input channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public final class IntegrateInt implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new IntegrateInt process with the input Channel in and the * output Channel out. * * @param in the input Channel * @param out the output Channel */ public IntegrateInt(final ChannelInputInt in, final ChannelOutputInt out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannelInt a = Channel.one2oneInt(); final One2OneChannelInt b = Channel.one2oneInt(); final One2OneChannelInt c = Channel.one2oneInt(); new Parallel(new CSProcess[] { new Delta2Int(a.in(), out, b.out()), new PrefixInt(0, b.in(), c.out()), new PlusInt(in, c.in(), a.out()) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/GenerateInt.java0000644000000000000000000000632711105701167021151 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Generates an infinite (constant) sequence of ints. *

Process Diagram

*

*

Description

* GenerateInt is a process that generates an infinite sequence * of the integer, n, with which it is configured. *

Channel Protocols

* * * * * * * * * *
Output Channels
outint * All channels in this package carry integers. *
* * @author P.H. Welch and P.D. Austin */ public final class GenerateInt implements CSProcess { /** The output Channel */ private final ChannelOutputInt out; /** The output number */ private final int n; /** * Construct a new GenerateInt process with the output channel out. * * @param out the output channel * @param n the number to generate */ public GenerateInt(final ChannelOutputInt out, final int n) { this.out = out; this.n = n; } /** * The main body of this process. */ public void run() { while (true) out.write(n); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/MultInt.java0000644000000000000000000001052611105701167020334 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Scales an integer stream. * *

Process Diagram

*

*

Description

* MultInt multiplies each integer that flows through it by the multiplier * with which it is configured. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows how to use the MultInt process in a small program. * The program also uses some of the other plugNplay processes. The * program generates a sequence of numbers, multiplies them by 42 and prints * this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class MultIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new MultInt (42, a.in (), b.out ()),
 *         new PrinterInt (b.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class MultInt implements CSProcess { /** The multiplier */ private final int n; /** The input Channel */ private final ChannelInputInt in; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new MultInt process with the input Channel in and the * output Channel out. * * @param n the multiplier * @param in the input channel * @param out the output channel */ public MultInt(int n, final ChannelInputInt in, final ChannelOutputInt out) { this.n = n; this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) out.write(n*(in.read())); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ints/NandInt.java0000644000000000000000000001235311105701167020273 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay.ints; import org.jcsp.lang.*; /** * Bitwise nands two integer streams to one stream. * *

Process Diagram

* *
 *    in0  _________
 *   -->--|         | out
 *    in1 | NandInt |-->--
 *   -->--|_________|
 * 
*

Description

* NandInt is a process whose output strean is the bitwise nand * of the integers on its input streams. *

*

Channel Protocols

* * * * * * * * All channels in this package carry integers. * * * * * * * * * * *
Input Channels
in0, in1int
Output Channels
outint * All channels in this package carry integers. *
*

*

Example

* The following example shows how the use of this process in a small program. * The program also uses some of the other building block processes. * It generates a sequence of numbers, rounds each odd number down to * the nearest even number, negates them and prints them to the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.ints.*;
 * 
 * public class NandIntExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannelInt a = Channel.one2oneInt ();
 *     final One2OneChannelInt b = Channel.one2oneInt ();
 *     final One2OneChannelInt c = Channel.one2oneInt ();
 *     final One2OneChannelInt d = Channel.one2oneInt ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new NumbersInt (a.out ()),
 *         new GenerateInt (b.out (), Integer.MAX_VALUE - 1),
 *         new NandInt (a.in (), b.in (), c.out ()),
 *         new SuccessorInt (c.in (), d.out ()),
 *         new PrinterInt (d.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class NandInt implements CSProcess { /** The first input Channel */ private final ChannelInputInt in0; /** The second input Channel */ private final ChannelInputInt in1; /** The output Channel */ private final ChannelOutputInt out; /** * Construct a new NandInt process with the input Channels in0 and in1 and the * output Channel out. The ordering of the Channels in0 and in1 make * no difference to the functionality of this process. * * @param in0 the first input Channel * @param in1 the second input Channel * @param out the output Channel */ public NandInt(final ChannelInputInt in0, final ChannelInputInt in1, final ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessReadInt[] procs = {new ProcessReadInt(in0), new ProcessReadInt(in1)}; final Parallel par = new Parallel(procs); while (true) { par.run(); final int i0 = procs[0].value; final int i1 = procs[1].value; out.write(~ (i0 & i1)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Nor.java0000644000000000000000000001264111105701167016521 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Bitwise nors two Integer streams to one stream. * *

Process Diagram

* *
 *    in0  _____
 *   -->--|     | out
 *    in1 | Nor |-->--
 *   -->--|_____|
 * 
*

Description

* This is a process with an infinite loop that waits for * a Object of type Number to be sent down each of its input channels. * The loop body then calculates the bitwise NOR on the values of the * two Numbers and writes the result as a new Integer to its output channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in1,in2java.lang.Number * Both Channels can accept data from any subclass of Number. It is * possible to send Floats down one channel and Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows the use of this process in a small program. * The program also uses some of the other building block processes. * It generates a sequence of numbers and calculates the negative value * and prints this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class NorExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     fonal One2OneChannel a = Channel.one2one ();
 *     fonal One2OneChannel b = Channel.one2one ();
 *     fonal One2OneChannel c = Channel.one2one ();
 *     fonal One2OneChannel d = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Generate (b.out (), 0),
 *         new Nor (a.in (), b.in (), c.out ()),
 *         new Successor (c.in (), d.out ()),
 *         new Printer (d.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Nor implements CSProcess { /** The first input Channel */ private ChannelInput in1; /** The second input Channel */ private ChannelInput in2; /** The output Channel */ private ChannelOutput out; /** * Construct a new Nor process with the input Channels in1 and in2 and the * output Channel out. The ordering of the Channels in1 and in2 make * no difference to the functionality of this process. * * @param in1 The first input Channel * @param in2 The second input Channel * @param out The output Channel */ public Nor(ChannelInput in1, ChannelInput in2, ChannelOutput out) { this.in1 = in1; this.in2 = in2; this.out = out; } /** * The main body of this process. */ public void run() { ProcessRead[] procs = {new ProcessRead(in1), new ProcessRead(in2)}; Parallel par = new Parallel(procs); while (true) { par.run(); int i1 = ((Number) procs[0].value).intValue(); int i2 = ((Number) procs[1].value).intValue(); out.write(new Integer(~ (i1 | i2))); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/FramedButtonGrid.java0000644000000000000000000002616711105701167021173 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.plugNplay; import java.awt.GridLayout; import org.jcsp.lang.*; import org.jcsp.awt.*; //{{{ javadoc /** * A free-standing grid of button processes in their own frame, * with configure and event channels. *

Process Diagram

* Please check out the process diagram for a framed single button * in {@link FramedButton}. * Imagine here a 2D grid of these, each with individual configure and * event channels. *

Description

* This process provides a free-standing grid of button processes in their * own frame. * They are just {@link org.jcsp.awt.ActiveButton}s wrapped in * an {@link org.jcsp.awt.ActiveClosingFrame}, * but save us the trouble of constructing them. *

* Wire them to application processes with configure * channels (for setting labels, enabling/disabling and all other * configuration options) and event channels (on which the * current label on any button is sent when that button is clicked). * Note that all the events may be streamed to the same * channel, provided an Any2*Channel is used (as in the example * below). *

*

* Initially, all button labels are empty java.lang.Strings. * To set a button label, send a java.lang.String down the appropriate * configure channel. *

*

* Initially, all buttons are enabled. * To disable a button, send java.lang.Boolean.FALSE * down the appropriate configure channel. * To enable, send java.lang.Boolean.TRUE. *

*

* For other configuration options, send objects implementing * the {@link org.jcsp.awt.ActiveButton.Configure} interface. *

*

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myButtonEvent =
 *     Channel.one2one (new OverWriteOldestBuffer (n));
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Example

* This runs a framed button grid in parallel with a simple application process * (in-lined in the {@link org.jcsp.lang.Parallel Parallel} below). * All event channels from the buttons are mulitplexed through * an {@link Any2OneChannel} to the application process. * The application configures the buttons with their labels, then reports * each time any of them is pressed. * The application ends when the button labelled `Goodbye World' is pressed. *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class FramedButtonGridExample {
 * 
 *   public static void main (String argv[]) {
 *   
 *     // labels for the grid of buttons
 * 
 *     final String[][] label = {
 *       new String[] {"Java", "occam-pi", "Handel-C"},
 *       new String[] {"C", "C++", "C#"},
 *       new String[] {"Haskell", "Modula", "Goodbye World"}
 *     };
 * 
 *     final int nDown = label.length;
 *     final int nAcross = label[0].length;
 * 
 *     // initial pixel sizes for the frame for the grid of buttons
 * 
 *     final int pixDown = 20 + (nDown*100);
 *     final int pixAcross = nAcross*120;
 *   
 *     // all button events are wired (for this example) to the same channel ...
 * 
 *     final Any2OneChannel allEvents =
 *       Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final Any2OneChannel[][] event = new Any2OneChannel[nDown][nAcross];
 *     
 *     for (int i = 0; i < nDown; i++) {
 *       for (int j = 0; j < nAcross; j++) {
 *         event[i][j] = allEvents;
 *       }
 *     }
 * 
 *     // make the grid of buttons (each one separately configured) ...
 * 
 *     final One2OneChannel[][] configure = new One2OneChannel[nDown][nAcross];
 *     
 *     for (int i = 0; i < nDown; i++) {
 *       configure[i] = Channel.one2oneArray (nAcross);
 *     }
 * 
 *     final ChannelInput[][] configureIn = new ChannelInput[nDown][nAcross];
 *     final ChannelOutput[][] eventOut = new ChannelOutput[nDown][nAcross];
 *     
 *     for (int i = 0; i < nDown; i++) {
 *       configureIn[i] = Channel.getInputArray (configure[i]);
 *       eventOut[i] = Channel.getOutputArray (event[i]);
 *     }
 * 
 *     final FramedButtonGrid grid =
 *       new FramedButtonGrid (
 *         "FramedButtonGrid Demo", nDown, nAcross,
 *         pixDown, pixAcross, configureIn, eventOut
 *       );
 * 
 *     // testrig ...
 * 
 *     new Parallel (
 *     
 *       new CSProcess[] {
 *       
 *         grid,
 *         
 *         new CSProcess () {
 *         
 *           public void run () {
 *     
 *             for (int i = 0; i < nDown; i++) {
 *               for (int j = 0; j < nAcross; j++) {
 *                 configure[i][j].out ().write (label[i][j]);
 *               }
 *             }
 *             
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) allEvents.in ().read ();
 *               System.out.println ("Button `" + s + "' pressed ...");
 *               running = (s != label[nDown - 1][nAcross - 1]);
 *             }
 *             
 *             System.exit (0);
 *             
 *           }
 *           
 *         }
 *         
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveButton * @see org.jcsp.plugNplay.FramedButton * @see org.jcsp.plugNplay.FramedButtonArray * @see org.jcsp.plugNplay.FramedScrollbar * * @author P.H. Welch * */ //}}} public final class FramedButtonGrid implements CSProcess { /** The frame for the buttons */ private final ActiveClosingFrame activeClosingFrame; /** The buttons */ private final ActiveButton[] button;; /** * Construct a framed button grid process. *

* * @param title the title for the frame (must not be null) * @param nDown the number of buttons down in the grid (must be at least 1) * @param nAcross the number of buttons across in the grid (must be at least 1) * @param pixDown the pixel hieght of the frame (must be at least 100) * @param pixAcross the pixel width of the frame (must be at least 100) * @param configure the matrix of configure channels for the buttons (must not be null) * @param event the matrix of event channels from the buttons (must not be null) * */ public FramedButtonGrid (String title, int nDown, int nAcross, int pixDown, int pixAcross, ChannelInput[][] configure, ChannelOutput[][] event) { // check everything ... if (title == null) { throw new IllegalArgumentException ( "From FramedButtonGrid (title == null)" ); } if ((nDown < 1) || (nAcross < 1) || (pixDown < 100) || (pixAcross < 100)) { throw new IllegalArgumentException ( "From FramedButtonGrid (nDown < 1) || (nAcross < 1) || (pixDown < 100) || (pixAcross < 100)" ); } if ((configure == null) || (event == null)) { throw new IllegalArgumentException ( "From FramedButtonGrid (configure == null) || (event == null)" ); } if ((nDown != configure.length) || (configure.length != event.length)) { throw new IllegalArgumentException ( "From FramedButtonGrid (nDown != configure.length) || (configure.length != event.length)" ); } for (int i = 0; i < configure.length; i++) { if ((configure[i] == null) || (event[i] == null)) { throw new IllegalArgumentException ( "From FramedButtonGrid (configure[i] == null) || (event[i] == null)" ); } if ((nAcross != configure[i].length) || (configure[i].length != event[i].length)) { throw new IllegalArgumentException ( "From FramedButtonGrid (nAcross != configure[i].length) || (configure[i].length != event[i].length)" ); } for (int j = 0; j < nAcross; j++) { if ((configure[i][j] == null) || (event[i][j] == null)) { throw new IllegalArgumentException ( "From FramedButtonGrid (configure[i][j] == null) || (event[i][j] == null)" ); } } } // OK - now build ... activeClosingFrame = new ActiveClosingFrame (title); final ActiveFrame activeFrame = activeClosingFrame.getActiveFrame (); button = new ActiveButton[nDown*nAcross]; for (int i = 0; i < nDown; i++) { for (int j = 0; j < nAcross; j++) { button[(i*nAcross) + j] = new ActiveButton (configure[i][j], event[i][j]); } } activeFrame.setSize (pixAcross, pixDown); activeFrame.setLayout (new GridLayout (nDown, nAcross)); for (int i = 0; i < button.length; i++) { activeFrame.add (button[i]); } activeFrame.setVisible (true); } public void run () { new Parallel ( new CSProcess[] { activeClosingFrame, new Parallel (button) } ).run (); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Delta.java0000644000000000000000000001074411113671251017015 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This process broadcasts objects arriving on its input channel in parallel * to its array of output channels. * *

Process Diagram

*

*

Description

* The Delta class is a process which has an infinite loop that waits * for Objects of any type to be sent down the in Channel. The process then * writes the reference to the Object in parallel down each of the Channels * in the out array. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
Output Channels
out[]java.lang.Object * The output Channels will carry a broadcast of whatever * is sent down the in Channel. *
* * @author P.H. Welch and P.D. Austin */ public final class Delta implements CSProcess { /** The input Channel */ private ChannelInput in; /** The output Channels */ private ChannelOutput[] out; /** * Construct a new Delta process with the input Channel in and the output * Channels out. The ordering of the Channels in the out array make * no difference to the functionality of this process. * * @param in the input channel * @param out the output Channels */ public Delta(ChannelInput in, ChannelOutput[] out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { try { ProcessWrite[] procs = new ProcessWrite[out.length]; for (int i = 0; i < out.length; i++) procs[i] = new ProcessWrite(out[i]); Parallel par = new Parallel(procs); while (true) { Object value = in.read(); for (int i = 0; i < out.length; i++) procs[i].value = value; par.run(); } } catch (PoisonException p) { // don't know which channel was posioned ... so, poison them all! int strength = p.getStrength (); // use same strength of poison in.poison (strength); for (int i = 0; i < out.length; i++) { out[i].poison (strength); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Substitute.java0000644000000000000000000000736411105701167020144 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Substitutes a user-configured Object for each Object in the stream * flowing through. *

Process Diagram

*

*

Description

* Substitute is a process that substitutes the (Object) o * with which it is configured for everything recieved on its in channel. * So, its output stream repeats the same Object but its rate of flow is triggered by * its input. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
Output Channels
outjava.lang.Object * The object to be sent down the Channel. *
* * @author P.H. Welch and P.D. Austin */ public class Substitute implements CSProcess { /** The Object to be sent down the out Channel. */ private Object o; /** The input Channel */ private ChannelInput in; /** The output Channel */ private ChannelOutput out; /** * Construct a new Substitute process. * * @param o the Object to be sent down the out Channel. * @param in the input Channel * @param out the output Channel */ public Substitute(ChannelInput in, ChannelOutput out, Object o) { this.in = in; this.out = out; this.o = o; } /** * The main body of this process. */ public void run() { while (true) { in.read(); out.write(o); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Regulate.java0000644000000000000000000001302011105701167017523 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This process controls the rate of flow of traffic from its input to output channels. *

Process Diagram

*
 *     in    ____________________________
 *   --->---|                            | out
 *    reset | Regulate (initialInterval) |-->--
 *   --->---|____________________________|
 * 
*

Description

* Regulate produces a constant rate of output flow, regardless of * the rate of its input. * At the end of each time period, it outputs the last object input during that period. * If nothing comes in, the previous output will be repeated * (note: this will be a null if nothing has ever arrived). * If the input flow is greater than the required output flow, data will be discarded. *

* The interval (in msecs) defining the output flow rate is given by a constructor argument. * This can be changed at any time by sending a new interval (as a Long) * down its reset channel. *

Channel Protocols

* * * * * * * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * This accepts data of any Class. *
resetjava.lang.Long * This resets the time interval between outputs (milliseconds). *
Output Channels
outjava.lang.Object * This carries samples from the input data, sampled at the * defined rate. *
*

Implementation

* See here. * * @see org.jcsp.plugNplay.FixedDelay * @see org.jcsp.plugNplay.Regular * * @author P.H. Welch */ public class Regulate implements CSProcess { private final AltingChannelInput in, reset; private final ChannelOutput out; private final long initialInterval; /** * Construct the process. * * @param in the input channel * @param out the output channel * @param initialInterval the initial interval between outputs (in milliseconds) * @param reset send a Long down this to change the interval between outputs (in milliseconds) */ public Regulate (final AltingChannelInput in, final AltingChannelInput reset, final ChannelOutput out, final long initialInterval) { this.in = in; this.reset = reset; this.out = out; this.initialInterval = initialInterval; } /** * The main body of this process. */ public void run () { final CSTimer tim = new CSTimer (); final Guard[] guards = {reset, tim, in}; // prioritised order final int RESET = 0; // index into guards final int TIM = 1; // index into guards final int IN = 2; // index into guards final Alternative alt = new Alternative (guards); Object x = null; // holding object long interval = initialInterval; long timeout = tim.read () + interval; tim.setAlarm (timeout); while (true) { switch (alt.priSelect ()) { case RESET: interval = ((Long) reset.read ()).longValue (); timeout = tim.read (); // fall through case TIM: out.write (x); timeout += interval; tim.setAlarm (timeout); break; case IN: x = in.read (); break; } } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Integrate.java0000644000000000000000000001161411105701167017704 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This is a running-sum integrator of the Integers on its input stream * to its output stream. *

Process Diagram

*

External View

* *
 *         ___________  
 *     in |           | out
 *    -->-| Integrate |-->---
 *        |___________|
 * 
*

Internal View

* *
 *         ___________________________________________ 
 *        |  _______                   ________       |
 *     in | |       |                 |        |      | out
 *    -->---| {@link Plus Plus}  |------->---------| {@link Delta2 Delta2} |--------->--- 
 *        | |_______|                 |________|      |
 *        |     |                        |            |
 *        |     |      ____________      |            |
 *        |     |     |            |     |            |
 *        |     +--<--| {@link Prefix Prefix (0)} |--<--+            |
 *        |           |____________|                  |
 *        |                                 Integrate |
 *        |___________________________________________|
 * 
*

Description

* The Integrate class is a process which outputs running totals of * the Numbers sent down the in Channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Number * The Channel can accept data from any subclass of Number. All values * will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
* * @author P.H. Welch and P.D. Austin */ public class Integrate implements CSProcess { /** The input Channel */ private ChannelInput in; /** The output Channel */ private ChannelOutput out; /** * Construct a new Integrate process with the input Channel in and the * output Channel out. * * @param in the input Channel * @param out the output Channel */ public Integrate(ChannelInput in, ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannel a = Channel.one2one(); final One2OneChannel b = Channel.one2one(); final One2OneChannel c = Channel.one2one(); new Parallel(new CSProcess[] { new Delta2(a.in(), out, b.out()), new Prefix(new Integer(0), b.in(), c.out()), new Plus(in, c.in(), a.out()) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Numbers.java0000644000000000000000000001100611105701167017370 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Plugs together a network of low-level stateless components * to generate the sequence of natural numbers. * *

Process Diagram

*

External View

* *
 *         ___________  
 *        |           | out
 *        |  Numbers  |-->----
 *        |___________|
 * 
*

Internal View

* *
 *         ___________________________________________
 *        |  ____________             ________        |
 *        | |            |           |        |       | out
 *        | | {@link Prefix Prefix (0)} |----->-----| {@link Delta2 Delta2} |---------->-- 
 *        | |____________|           |________|       |
 *        |     |                        |            |
 *        |     |       ___________      |            |
 *        |     |      |           |     |            |
 *        |     +---<--| {@link Successor Successor} |--<--+            |
 *        |            |___________|                  |
 *        |                                   Numbers |
 *        |___________________________________________|
 * 
*

Description

* The Numbers process generates the sequence of Natural Numbers. *

*

Channel Protocols

* * * * * * * * * * * * * * *
Input Channels
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
* * @author P.H. Welch and P.D. Austin */ public class Numbers implements CSProcess { /** The output Channel */ private ChannelOutput out; /** * Construct a new Numbers process with the output Channel out. * * @param out the output channel */ public Numbers(ChannelOutput out) { this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannel a = Channel.one2one(); final One2OneChannel b = Channel.one2one(); final One2OneChannel c = Channel.one2one(); new Parallel(new CSProcess[] { new Delta2(a.in(), b.out(), out), new Successor(b.in(), c.out()), new Prefix(new Integer(0), c.in(), a.out()) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Xor.java0000644000000000000000000001270711105701167016536 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Bitwise xors two Integer streams to one stream. * *

Process Diagram

* *
 *    in0  _____
 *   -->--|     | out
 *    in1 | Xor |-->--
 *   -->--|_____|
 * 
*

Description

* This is a process with an infinite loop that waits for * a Object of type Number to be sent down each of its input channels. * The loop body then calculates the bitwise XOR on the values of the * two Numbers and writes the result as a new Integer to its output channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in1,in2java.lang.Number * Both Channels can accept data from any subclass of Number. It is * possible to send Floats down one channel and Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

Example

* The following example shows how to use the Xor process in a small program. * The program also uses some of the other building block processes. * It generates a sequence of numbers, XORs them with * Integer.MAX_VALUE to give a decending sequence of numbers * (from Integer.MAX_VALUE) and prints this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class XorExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     One2OneChannel a = Channel.one2one ();
 *     One2OneChannel b = Channel.one2one ();
 *     One2OneChannel c = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Generate (b.out (), Integer.MAX_VALUE),
 *         new Xor (a.in (), b.in (), c.out ()),
 *         new Printer (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Xor implements CSProcess { /** The first input Channel */ private final ChannelInput in1; /** The second input Channel */ private final ChannelInput in2; /** The output Channel */ private final ChannelOutput out; /** * Construct a new Xor process with the input Channels in1 and in2 and the * output Channel out. The ordering of the Channels in1 and in2 make * no difference to the functionality of this process. * * @param in1 The first input Channel * @param in2 The second input Channel * @param out The output Channel */ public Xor(final ChannelInput in1, final ChannelInput in2, final ChannelOutput out) { this.in1 = in1; this.in2 = in2; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessRead[] procs = {new ProcessRead(in1), new ProcessRead(in2)}; final Parallel par = new Parallel(procs); while (true) { par.run(); final int i1 = ((Number) procs[0].value).intValue(); final int i2 = ((Number) procs[1].value).intValue(); out.write(new Integer(i1 ^ i2)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Mult.java0000644000000000000000000001070611105701167016704 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Scales an Integer stream. * *

Process Diagram

*

*

Description

* Mult multiplies each Integer that flows through it by the multiplier * with which it is configured. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Number * The Channel can accept data from any subclass of Number. All values * will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows how to use the Mult process in a small program. * The program also uses some of the other plugNplay processes. The * program generates a sequence of Integers, multiplies them by 42 and prints * this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class MultExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel a = Channel.one2one ();
 *     final One2OneChannel b = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Mult (42, a.in (), b.out ()),
 *         new Printer (b.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Mult implements CSProcess { /** The multiplier */ private final int n; /** The input Channel */ private final ChannelInput in; /** The output Channel */ private final ChannelOutput out; /** * Construct a new Mult process with the input Channel in and the * output Channel out. * * @param n the multiplier * @param in the input channel * @param out the output channel */ public Mult(int n, final ChannelInput in, final ChannelOutput out) { this.n = n; this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) { final int i = ((Integer) in.read()).intValue(); out.write(new Integer(n*i)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/ProcessWrite.java0000644000000000000000000001135311105701167020413 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Writes one Object to its output channel. *

Process Diagram

*

*

Description

* ProcessWrite is a process that performs a single write * to its out channel and then terminates. The Object * that is written must first be placed in the public value field * of this process (which is safe to set before and in between * process runs). *

* ProcessWrite declaration, construction and use should normally * be localised within a single method -- so we feel no embarassment about * its public field. Its only (envisaged) purpose is as described in * the example below. *

Channel Protocols

* * * * * * * * * *
Output Channels
outjava.lang.Object * The out Channel can accept data of any Class. *
*

Example

* ProcessWrite is designed to simplify writing in parallel * to channels. Make as many instances as there * are channels, binding each instance to a different channel, * together with a {@link org.jcsp.lang.Parallel} object in which to run them: *
 *   ChannelOutput out0, out1;
 *   .
 *   .
 *   .
 *   ProcessWrite write0 = new ProcessWrite (out0);
 *   ProcessWrite write1 = new ProcessWrite (out1);
 *   CSProcess parWrite01 = new Parallel (new CSProcess[] {out0, out1});
 * 
* The above is best done once, before any looping over the * parallel write commences. A parallel write can now be performed * at any time (and any number of times) by executing: *
 *     write0.value = ...;   // whatever we want sent down out0
 *     write1.value = ...;   // whatever we want sent down out1
 *     parWrite01.run ();
 * 
* The last line above terminates when, and only when, both writes have completed -- * the events may occur in any order. * * @see org.jcsp.lang.Parallel * @see org.jcsp.plugNplay.ProcessRead * @see org.jcsp.plugNplay.ints.ProcessReadInt * @see org.jcsp.plugNplay.ints.ProcessWriteInt * * @author P.H. Welch and P.D. Austin */ public class ProcessWrite implements CSProcess { /** The Object to be written to the channel */ public Object value; /** The channel to which to write */ private ChannelOutput out; /** * Construct a new ProcessWrite. * * @param out the channel to which to write */ public ProcessWrite(ChannelOutput out) { this.out = out; } /** * The main body of this process. */ public void run() { out.write(value); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Or.java0000644000000000000000000001267311105701167016350 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Bitwise ors two Integer streams to one stream. * *

Process Diagram

* *
 *    in0  ____
 *   -->--|    | out
 *    in1 | Or |-->--
 *   -->--|____|
 * 
*

Description

* The Or class is a process which has an infinite loop that waits * a Object of type Number to be sent down each of the in1 and in2 Channels. * The process then calculates the bitwise OR on the intValue() of the * two Numbers then write the result as a new Integer down the out Channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in1,in2java.lang.Number * Both Channels can accept data from any subclass of Number. It is * possible to send Floats down one channel and Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows how to use the Or process in a small program. * The program also uses some of the other building block processes. The * program generates a sequence of numbers and rounds each even number up to * the nearest odd number and prints this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class OrExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel a = Channel.one2one ();
 *     final One2OneChannel b = Channel.one2one ();
 *     final One2OneChannel c = Channel.one2one ();
 *     final One2OneChannel d = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Generate (b.out (), 1),
 *         new Or (a.in (), b.in (), c.out ()),
 *         new Successor (c.in (), d.out ()),
 *         new Printer (d.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Or implements CSProcess { /** The first input Channel */ private ChannelInput in1; /** The second input Channel */ private ChannelInput in2; /** The output Channel */ private ChannelOutput out; /** * Construct a new Or process with the input Channels in1 and in2 and the * output Channel out. The ordering of the Channels in1 and in2 make * no difference to the functionality of this process. * * @param in1 the first input Channel * @param in2 the second input Channel * @param out the output Channel */ public Or(ChannelInput in1, ChannelInput in2, ChannelOutput out) { this.in1 = in1; this.in2 = in2; this.out = out; } /** * The main body of this process. */ public void run() { ProcessRead[] procs = {new ProcessRead(in1), new ProcessRead(in2)}; Parallel par = new Parallel(procs); while (true) { par.run(); int i1 = ((Number) procs[0].value).intValue(); int i2 = ((Number) procs[1].value).intValue(); out.write(new Integer(i1 | i2)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Merge.java0000644000000000000000000002052211105701167017017 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Merges an array of strictly increasing Integer input streams into one * strictly increasing output stream. *

Process Diagram

*

*

Description

* Merge is a process whose output stream is the ordered merging * of the Integers on its input streams. It assumes that each input stream is * strictly increasing (i.e. with no repeats) sequence of Integers. * It generates a strictly increasing output stream containing all -- * and only -- the Integers from its input streams (eliminating any duplicates). *

* Warning: this process assumes that its input channel array has at least * two elements. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in[]java.lang.Number * Assume: in.length >= 2.
* All channels can accept data from any subclass of Number. It is * possible to send Floats down one channel and Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows how to use Merge in a small program. * The program also uses some of the other plugNplay processes. The * program prints, in ascending order (up to Integer.MAX_VALUE), all integers * whose prime factors consist only of 2, 3, 5 and 7. Curious readers may like * to reason why the infinitely buffered channels are needed. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class MergeExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel[] a = Channel.one2oneArray (5);
 *     final One2OneChannel[] b = Channel.one2oneArray (4, new InfiniteBuffer ());
 *     final One2OneChannel c = Channel.one2one ();
 *     final One2OneChannel d = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Mult (2, a[0].in (), b[0].out ()),
 *         new Mult (3, a[1].in (), b[1].out ()),
 *         new Mult (5, a[2].in (), b[2].out ()),
 *         new Mult (7, a[3].in (), b[3].out ()),
 *         new Merge (Channel.getInputArray (b), c.out ()),
 *         new Prefix (1, c.in (), d.out ()),
 *         new Delta (d.in (), Channel.getOutputArray (a)),
 *         new Printer (a[4].in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
*

*

Implementation Note

* The implementation sets up a balanced binary tree of parallel * Merge2 processes to fan-in the merge from * its external input channels to its external output. It's a nice * example of recursion and parallelism -- here's the run * method: *
 *   public void run () {
 *     final int n = in.length;  // deduce: n >= 2
 *     switch (n) {
 *       case 2:
 *         new Merge2 (in[0], in[1], out).run ();
 *       break;
 *       case 3:
 *         final One2OneChannel c = Channel.one2one();
 *         new Parallel (
 *           new CSProcess[] {
 *             new Merge2 (in[0], in[1], c.out ()),
 *             new Merge2 (c.in (), in[2], out)
 *           }
 *         ).run ();
 *       break;
 *       default:  // deduce: n >= 4
 *         final int n2 = n/2;
 *         ChannelInput[] bottom = new ChannelInput[n2];
 *         ChannelInput[] top = new ChannelInput[n - n2];
 *         for (int i = 0; i < n2; i++) {
 *           bottom[i] = in[i];
 *         }
 *         for (int i = n2; i < n; i++) {
 *           top[i - n2] = in[i];
 *         }
 *         final One2OneChannel[] d = Channel.one2oneArray(2);
 *         new Parallel (
 *           new CSProcess[] {
 *             new Merge (bottom, d[0].out ()),
 *             new Merge (top, d[1].out ()),
 *             new Merge2 (d[0].in (), d[1].in (), out)
 *           }
 *         ).run ();
 *       break;
 *     }
 *   }
 * 
* * @see org.jcsp.plugNplay.Merge2 * * @author P.H. Welch */ public final class Merge implements CSProcess { /** The input channels */ final private ChannelInput[] in; // assume: in.length >= 2 /** The output channel */ final private ChannelOutput out; /** * Construct a new Merge2 process with the input channels * inand the output channel out. * The ordering of the input channels makes no difference * to the behaviour of this process. * * @param in the input channels (there must be at least 2) * @param out the output channel */ public Merge(ChannelInput[] in, ChannelOutput out) { if (in.length < 2) { throw new IllegalArgumentException ("Merge must have at least 2 input channels"); } this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final int n = in.length; // deduce: n >= 2 switch (n) { case 2: new Merge2(in[0], in[1], out).run(); break; case 3: final One2OneChannel c = Channel.one2one(); new Parallel(new CSProcess[] { new Merge2(in[0], in[1], c.out()), new Merge2(c.in(), in[2], out) }).run(); break; default: // deduce: n >= 4 final int n2 = n/2; ChannelInput[] bottom = new ChannelInput[n2]; ChannelInput[] top = new ChannelInput[n - n2]; for (int i = 0; i < n2; i++) bottom[i] = in[i]; for (int i = n2; i < n; i++) top[i - n2] = in[i]; final One2OneChannel[] d = Channel.one2oneArray(2); new Parallel(new CSProcess[] { new Merge(bottom, d[0].out()), new Merge(top, d[1].out()), new Merge2(d[0].in(), d[1].in(), out) }).run(); break; } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Pairs.java0000644000000000000000000001002411105701167017032 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Generates sums of successive pairs of input Integers. *

Process Diagram

*

External View

*

*

Internal View

*

*

Description

* Pairs is a process whose output is always the sum of its previous * two inputs. *

* Two inputs are needed before any * output is produced but that, thereafter, one output is produced for each * input. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Number * The Channel can accept data from any subclass of Number. All values * will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
* * @author P.H. Welch and P.D. Austin */ public class Pairs implements CSProcess { /** The input Channel */ private ChannelInput in; /** The output Channel */ private ChannelOutput out; /** * Construct a new Pairs process with the input Channel in and the * output Channel out. * * @param in The input Channel * @param out The output Channel */ public Pairs(ChannelInput in, ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final One2OneChannel a = Channel.one2one(); final One2OneChannel b = Channel.one2one(); final One2OneChannel c = Channel.one2one(); new Parallel(new CSProcess[] { new Delta2(in, a.out(), b.out()), new Plus(a.in(), c.in(), out), new Tail(b.in(), c.out()) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Prefix.java0000644000000000000000000001014411105701167017214 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Prefixes a user-supplied object to the Object stream * flowing through. *

Process Diagram

*

*

Description

* This is a process which first outputs a given Object and then * copies its input stream of Objects to its output stream. *

* One output is gererated before any input but, * thereafter, one output is produced for each input. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
Output Channels
outjava.lang.Object * The out Channel sends the the same type of data (in * fact, the same data) as is input. *
*

*

Implementation Note

* The implementation uses an {@link Identity} process for the copy loop: *
 *   public void run () {
 *     out.write (o);                     // prefix the given object to the stream
 *     new Identity (in, out).run ();     // copy the stream
 *   }
 * 
* * @author P.H. Welch */ public final class Prefix implements CSProcess { /** The input Channel */ private ChannelInput in; /** The output Channel */ private ChannelOutput out; /** The initial Object to be sent down the Channel. */ private Object o; /** * Construct a new Prefix process with the input Channel in and the * output Channel out. * * @param o the initial Object to be sent down the Channel. * @param in the input Channel * @param out the output Channel */ public Prefix(Object o, ChannelInput in, ChannelOutput out) { this.in = in; this.out = out; this.o = o; } /** * The main body of this process. */ public void run() { out.write(o); new Identity(in, out).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Times.java0000644000000000000000000001223311105701167017041 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Multiplies two Integer streams to one stream. * *

Process Diagram

* *
 *    in0  _______
 *   -->--|       | out
 *    in1 | Times |-->--
 *   -->--|_______|
 * 
*

Description

* Times is a process whose output stream is the product * of the Integers on its input streams. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in1,in2java.lang.Number * Both Channels can accept data from any subclass of Number. It is * possible to send Floats down one channel and Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows how the use of this process in a small program. * The program also uses some of the other building block processes. * It generates two sequences of numbers, multiplies them together and * prints them to the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class TimesExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel a = Channel.one2one ();
 *     final One2OneChannel b = Channel.one2one ();
 *     final One2OneChannel c = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Numbers (b.out ()),
 *         new Times (a.in (), b.in (), c.out ()),
 *         new Printer (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class Times implements CSProcess { /** The first input Channel */ private ChannelInput in1; /** The second input Channel */ private ChannelInput in2; /** The output Channel */ private ChannelOutput out; /** * Construct a new Times process with the input Channels in1 and in2 and the * output Channel out. The ordering of the Channels in1 and in2 make * no difference to the functionality of this process. * * @param in1 the first input Channel * @param in2 the second input Channel * @param out the output Channel */ public Times(ChannelInput in1, ChannelInput in2, ChannelOutput out) { this.in1 = in1; this.in2 = in2; this.out = out; } /** * The main body of this process. */ public void run() { ProcessRead[] parRead = {new ProcessRead(in1), new ProcessRead(in2)}; Parallel par = new Parallel(parRead); while (true) { par.run(); int i1 = ((Number) parRead[0].value).intValue(); int i2 = ((Number) parRead[1].value).intValue(); out.write(new Integer(i1 * i2)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/FramedButtonArray.java0000644000000000000000000002416311105701167021356 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.plugNplay; import java.awt.GridLayout; import org.jcsp.lang.*; import org.jcsp.awt.*; //{{{ javadoc /** * A free-standing array of button processes in their own frame, * with configure and event channels. *

Process Diagram

* Please check out the process diagram for a framed single button * in {@link FramedButton}. * Imagine here an array of these, each with individual configure and * event channels. *

Description

* This process provides a free-standing array of button processes in their * own frame. * They are just {@link org.jcsp.awt.ActiveButton}s wrapped in * an {@link org.jcsp.awt.ActiveClosingFrame}, * but save us the trouble of constructing them. * They may be displayed in a row or column. *

* Wire them to application processes with configure * channels (for setting labels, enabling/disabling and all other * configuration options) and event channels (on which the * current label on any button is sent when that button is clicked). * Note that all the events may be streamed to the same * channel, provided an Any2*Channel is used (as in the example * below). *

*

* Initially, all button labels are empty java.lang.Strings. * To set a button label, send a java.lang.String down the appropriate * configure channel. *

*

* Initially, all buttons are enabled. * To disable a button, send java.lang.Boolean.FALSE * down the appropriate configure channel. * To enable, send java.lang.Boolean.TRUE. *

*

* For other configuration options, send objects implementing * the {@link org.jcsp.awt.ActiveButton.Configure} interface. *

*

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myButtonEvent =
 *     Channel.one2one (new OverWriteOldestBuffer (n));
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Example

* This runs a framed button array in parallel with a simple application process * (in-lined in the {@link org.jcsp.lang.Parallel Parallel} below). * All event channels from the buttons are mulitplexed through * an {@link Any2OneChannel} to the application process. * The application configures the buttons with their labels, then reports * each time any of them is pressed. * The application ends when the button labelled `Goodbye World' is pressed. *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class FramedButtonArrayExample {
 * 
 *   public static void main (String argv[]) {
 * 
 *     // labels for the array of buttons
 * 
 *     final String[] label = {"JCSP", "Rocket Science", "occam-pi", "Goodbye World"};
 * 
 *     final int nButtons = label.length;
 * 
 *     // row or column?
 * 
 *     final boolean horizontal = true;
 *   
 *     // initial pixel sizes for the frame for the button array
 *     
 *     final int pixDown = 20 + (horizontal ? 120 : nButtons*120);
 *     final int pixAcross = horizontal ? nButtons*120 : 120;
 *   
 *     // all button events are wired (for this example) to the same channel ...
 * 
 *     final Any2OneChannel allEvents =
 *       Channel.any2one (new OverWriteOldestBuffer (10));
 * 
 *     final Any2OneChannel[] event = new Any2OneChannel[nButtons];
 *     
 *     for (int i = 0; i < nButtons; i++) {
 *       event[i] = allEvents;
 *     }
 * 
 *     // each button is given its own configuration channel ...
 * 
 *     final One2OneChannel[] configure = Channel.one2oneArray (nButtons);
 * 
 *     // make the array of buttons ...
 * 
 *     final FramedButtonArray buttons =
 *       new FramedButtonArray (
 *         "FramedButtonArray Demo", nButtons,
 *         pixDown, pixAcross, horizontal,
 *         Channel.getInputArray (configure), Channel.getOutputArray (event)
 *       );
 * 
 *     // testrig ...
 * 
 *     new Parallel (
 *     
 *       new CSProcess[] {
 *       
 *         buttons,
 *         
 *         new CSProcess () {
 *         
 *           public void run () {
 *     
 *             for (int i = 0; i < nButtons; i++) {
 *               configure[i].out ().write (label[i]);
 *             }
 *             
 *             boolean running = true;
 *             while (running) {
 *               final String s = (String) allEvents.in ().read ();
 *               System.out.println ("Button `" + s + "' pressed ...");
 *               running = (s != label[nButtons - 1]);
 *             }
 *             
 *             System.exit (0);
 *             
 *           }
 *           
 *         }
 *         
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveButton * @see org.jcsp.plugNplay.FramedButton * @see org.jcsp.plugNplay.FramedButtonGrid * @see org.jcsp.plugNplay.FramedScrollbar * * @author P.H. Welch * */ //}}} public final class FramedButtonArray implements CSProcess { /** The frame for the buttons */ private final ActiveClosingFrame activeClosingFrame; /** The buttons */ private final ActiveButton[] button; /** * Construct a framed button array process. *

* * @param title the title for the frame (must not be null) * @param nButtons the number of buttons (must be at least 1) * @param pixDown the pixel hieght of the frame (must be at least 100) * @param pixAcross the pixel width of the frame (must be at least 100) * @param horizontal true for a horizontal array of buttons, false for a vertical one * @param configure the configure channels for the buttons (must not be null) * @param event the event channels from the buttons (must not be null) * */ public FramedButtonArray (String title, int nButtons, int pixDown, int pixAcross, boolean horizontal, ChannelInput[] configure, ChannelOutput[] event) { // check everything ... if (title == null) { throw new IllegalArgumentException ( "From FramedButtonArray (title == null)" ); } if ((nButtons < 1) || (pixDown < 100) || (pixAcross < 100)) { throw new IllegalArgumentException ( "From FramedButtonArray (nButtons < 1) || (pixDown < 100) || (pixAcross < 100)" ); } if ((configure == null) || (event == null)) { throw new IllegalArgumentException ( "From FramedButtonArray (configure == null)" ); } if ((nButtons != configure.length) || (configure.length != event.length)) { throw new IllegalArgumentException ( "From FramedButtonArray (nButtons != configure.length) || (configure.length != event.length)" ); } for (int i = 0; i < configure.length; i++) { if ((configure[i] == null) || (event[i] == null)) { throw new IllegalArgumentException ( "From FramedButtonArray (configure[i] == null) || (event[i] == null)" ); } } // OK - now build ... activeClosingFrame = new ActiveClosingFrame (title); final ActiveFrame activeFrame = activeClosingFrame.getActiveFrame (); button = new ActiveButton[nButtons]; for (int i = 0; i < nButtons; i++) { button[i] = new ActiveButton (configure[i], event[i]); } activeFrame.setSize (pixAcross, pixDown); if (horizontal) { activeFrame.setLayout (new GridLayout (1, nButtons)); } else { activeFrame.setLayout (new GridLayout (nButtons, 1)); } for (int i = 0; i < button.length; i++) { activeFrame.add (button[i]); } activeFrame.setVisible (true); } public void run () { new Parallel ( new CSProcess[] { activeClosingFrame, new Parallel (button) } ).run (); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/BlackHole.java0000644000000000000000000000631311105701167017606 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Black holes anything sent to it. *

Process Diagram

*

*

Description

* BlackHole is a process that accepts everything sent to it. * This class can be used to ignore the output from a process while ensuring * that the data is always read from the channel. *

* Note: this functionality is (more efficiently) provided by * a {@link org.jcsp.lang.BlackHoleChannel}. *

Channel Protocols

* * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
* * @author P.H. Welch and P.D. Austin */ public final class BlackHole implements CSProcess { /** The input Channel */ private ChannelInput in; /** * Construct a new BlackHole process with the input Channel in. * * @param in the input channel */ public BlackHole(ChannelInput in) { this.in = in; } /** * The main body of this process. */ public void run() { while (true) in.read(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/And.java0000644000000000000000000001242411105701167016464 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Bitwise ands two Integer streams to one stream. * *

Process Diagram

*

*

Description

* This is a process with an infinite loop that waits for a Object of * type Number to be sent down each of its input channels. * The loop body then calculates the bitwise AND on the values of the two * Numbers and writes the result as a new Integer to its * output channel. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1java.lang.Number * Both channels can accept data from any subclass of Number. It is * possible to send Floats down one channel and Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

*

Example

* The following example shows how to use the And process in a small program. * The program also uses some of the other building block processes. The * program generates a sequence of numbers and rounds each odd number down to * the nearest even number and prints this on the screen. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class AndExample {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel a = Channel.one2one ();
 *     final One2OneChannel b = Channel.one2one ();
 *     final One2OneChannel c = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a.out ()),
 *         new Generate (b.out (), Integer.MAX_VALUE - 1),
 *         new And (a.in (), b.in (), c.out ()),
 *         new Printer (c.in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @author P.H. Welch and P.D. Austin */ public final class And implements CSProcess { /** The first input Channel */ private ChannelInput in0; /** The second input Channel */ private ChannelInput in1; /** The output Channel */ private ChannelOutput out; /** * Construct a new And process with the input Channels in0 and in1 and the * output Channel out. The ordering of the Channels in0 and in1 make * no difference to the functionality of this process. * * @param in0 the first input Channel * @param in1 the second input Channel * @param out the output Channel */ public And(ChannelInput in0, ChannelInput in1, ChannelOutput out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { ProcessRead[] procs = {new ProcessRead(in0), new ProcessRead(in1)}; Parallel par = new Parallel(procs); while (true) { par.run(); int i0 = ((Number)procs[0].value).intValue(); int i1 = ((Number)procs[1].value).intValue(); out.write(new Integer(i0 & i1)); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Paraplex.java0000644000000000000000000002015311105701167017534 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Parallel multiplexes its input Object stream array on to one output stream. *

Process Diagram

*

*

Description

* Paraplex is a process to convert multiple streams of * Objects to a single stream. It assumes data will always be available * on all its input streams. In each cycle, it inputs in parallel one * Object from each of its inputs, packs them into an array and outputs * that array as a single communication. *

* The parallel input means that the process will wait until something arrives * from every input channel, accepting items in whatever order they turn up. * The ordering of the channels in the in array, therefore, makes * no difference to the functionality of this process. *

* Caution: the process receiving packets from Paraplex * must agree to the following contract: *

* Input of an array * packet means that previously input arrays must not be looked at any more (neither * by itself nor any other processes to which they may have been passed). *
* Supporting the above, there is one more rule: *
* There must be only one process receiving array packets * from Paraplex (i.e. its output channel must not be connected * to a {@link org.jcsp.lang.One2AnyChannel} or {@link org.jcsp.lang.Any2AnyChannel}). *
* The reason for these obligations is to remove the need for Paraplex * to generate a new array packet for each paraplexed communication * -- an array that will normally be discarded by the receiving process after * dealing with its contents. * Instead of that, Paraplex operates a double-buffered protocol, * constructing and reusing just two array packets. It switches between them * after every cycle. In this way, it fills one packet while the process * receiving its output consumes the other one. This is safe so long as that * receiving process agrees to the above rules. * See the Low Level example in {@link org.jcsp.lang.Parallel} for the details * of this implementation. *

* Note: the above two constraints should work naturally with most applications. * However, by converting the first rule into a protocol where the receiving process * explicitly returns the packet (through an acknowledgment channel) * when it has finished using it and before inputting the next one, the second * rule could be dropped. This is trivial to do by piping the output from * Paraplex through a simple cyclic process that inputs a packet, * forwards it (down a {@link org.jcsp.lang.One2AnyChannel} or * {@link org.jcsp.lang.Any2AnyChannel}) and waits for the acknowledgment * (for which only a {@link org.jcsp.lang.One2OneChannel} is needed). *

* Of course, avoiding uncontrolled sharing of the Object passing * through this process is something that must be done. But that is not * the responsibility of this process and must be arranged between the * originator and recipient (or recipients). * *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in[]Object * Most channels in this package carry integers. *
Output Channels
outObject[] * A packet carrying the paraplexed data. *
* *

Example

*
 * import org.jcsp.lang.*;
 * import org.jcsp.plugNplay.*;
 * 
 * class ParaplexExample {
 * 
 *   public static void main (String[] args) {
 * 
 *     final One2OneChannel[] a = Channel.one2oneArray (3);
 *     final One2OneChannel b = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Numbers (a[0].out ()),
 *         new Squares (a[1].out ()),
 *         new Fibonacci (a[2].out ()),
 *         new Paraplex (Channel.getInputArray (a), b.out ()),
 *         new CSProcess () {
 *           public void run () {
 *             ChannelInput in = b.in ();
 *             System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n");
 *             while (true) {
 *               Object[] data = (Object[]) in.read ();
 *               for (int i = 0; i < data.length; i++) {
 *                 System.out.print ("\t\t" + data[i]);
 *               }
 *               System.out.println ();
 *             }
 *           }
 *         }
 *       }
 *     ).run ();
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.Deparaplex * @see org.jcsp.plugNplay.Multiplex * @see org.jcsp.plugNplay.Demultiplex * * @author P.H. Welch */ public final class Paraplex implements CSProcess { /** The input channels */ private final ChannelInput[] in; /** The output channel */ private final ChannelOutput out; /** * Construct a new Paraplex process with the input Channel in and the output * Channels out. The ordering of the Channels in the in array make * no difference to the functionality of this process. * * @param in the input channels * @param out the output channel */ public Paraplex(final ChannelInput[] in, final ChannelOutput out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { final ProcessRead[] inputProcess = new ProcessRead[in.length]; for (int i = 0; i < in.length; i++) inputProcess[i] = new ProcessRead(in[i]); Parallel parInput = new Parallel(inputProcess); Object[][] data = new Object[2][in.length]; int index = 0; while (true) { parInput.run(); Object[] buffer = data[index]; for (int i = 0; i < in.length; i++) buffer[i] = inputProcess[i].value; out.write(buffer); index = 1 - index; } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Squares.java0000644000000000000000000000705011105701167017404 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Generates the Integer stream 1*1, 2*2, 3*3, etc by a somewhat unusual route. * *

Process Diagram

*

External View

*

*

Internal View

*

*

Description

* The Squares class is a process which generates a sequence of squares of * Natural numbers that are output down the out Channel. *

*

Channel Protocols

* * * * * * * * * * * * * * *
Input Channels
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
* * @author P.H. Welch and P.D. Austin */ public class Squares implements CSProcess { /** The output Channel */ private ChannelOutput out; /** * Construct a new Squares process with the output Channel out. * * @param out the output channel */ public Squares(ChannelOutput out) { this.out = out; } /** * The main body of this process. */ public void run() { One2OneChannel a = Channel.one2one(); One2OneChannel b = Channel.one2one(); new Parallel(new CSProcess[] { new Numbers(a.out()), new Integrate(a.in(), b.out()), new Pairs(b.in(), out) }).run(); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/FramedScrollbar.java0000644000000000000000000002621511105701167021027 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2001 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@kent.ac.uk * * * *************************************************************************/ package org.jcsp.plugNplay; import java.awt.Scrollbar; import org.jcsp.lang.*; import org.jcsp.awt.*; //{{{ javadoc /** * A free-standing scrollbar process in its own frame, with configure and * event channels. *

Process Diagram

*
 *                               ___________________
 *                              |                   |
 *                              |                   |
 *                              |                   |
 *                              |                   |
 *                    {@link #FramedScrollbar configure} |                   |  {@link #FramedScrollbar event}
 *                   ----->-----|  FramedScrollbar  |----->-----
 *          (java.lang.Integer) |                   | (int)
 *          (java.lang.Boolean) |                   |
 *  ({@link org.jcsp.awt.ActiveScrollbar.Configure ActiveScrollbar.Configure}) |                   |
 *                              |                   |
 *                              |___________________|  
 * 
*

Description

* This process provides a free-standing scrollbar in its own frame. It is just * an {@link org.jcsp.awt.ActiveScrollbar} wrapped in an {@link org.jcsp.awt.ActiveClosingFrame}, * but saves us the trouble of constructing it. *

* Wire it to application processes with a configure channel (for setting * its position, enabling/disabling and all other configuration options) * and an event channel (on which the current position is sent whenever * the button in the scrollbar is moved). *

*

* Initially, the button in the scrollbar is at its minimum position. * An application process may change this by sending a java.lang.Integer * (with value between the minimum and maximum defined for the scrollbar) * down the configure channel. *

*

* Initially, the button is enabled. * To disable the button, send java.lang.Boolean.FALSE * down the configure channel. * To enable, send java.lang.Boolean.TRUE. *

*

* For other configuration options, send objects implementing * the {@link org.jcsp.awt.ActiveScrollbar.Configure} interface. *

*

* IMPORTANT: it is essential that event channels from this process are * always serviced -- otherwise the Java Event Thread will be blocked and the GUI * will stop responding. A simple way to guarantee this is to use channels * configured with overwriting buffers. * For example: *

 *   final One2OneChannel myScrollbarEvent =
 *     Channel.one2one (new OverWriteOldestBuffer (n));
 * 
* This will ensure that the Java Event Thread will never be blocked. * Slow or inattentive readers may miss rapidly generated events, but * the n most recent events will always be available. *

*

Example

* This runs a framed scrollbar in parallel with two simple application processes * (in-lined in the {@link org.jcsp.lang.Parallel Parallel} below). * One application process reports all movements of the scrollbar. * The other disables the scrollbar for 5 seconds at 15 second intervals. *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.ints.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class FramedScrollbarExample {
 * 
 *   public static void main (String argv[]) {
 *   
 *     // initial pixel sizes for the scrollbar frame
 *     
 *     final boolean horizontal = true;
 *   
 *     final int pixDown = horizontal ? 300 : 400;
 *     final int pixAcross = horizontal ? 400 : 300;
 *   
 *     // the event channel is wired up to the scrollbar & reports all slider movements ...
 * 
 *     final One2OneChannelInt event =
 *       Channel.one2oneInt (new OverWriteOldestBufferInt (10));
 * 
 *     // the configure channel is wired up to the scrollbar  ...
 * 
 *     final One2OneChannel configure = Channel.one2one ();
 * 
 *     // make the framed scrollbar (connecting up its wires) ...
 * 
 *     final FramedScrollbar scrollbar =
 *       new FramedScrollbar (
 *         "FramedScrollbar Demo", pixDown, pixAcross,
 *         configure.in (), event.out (),
 *         horizontal, 0, 10, 0, 100
 *       );
 * 
 *     // testrig ...
 * 
 *     new Parallel (
 *     
 *       new CSProcess[] {
 *       
 *         scrollbar,
 *         
 *         new CSProcess () {        
 *           public void run () {            
 *             while (true) {
 *               final int n = event.in ().read ();
 *               System.out.println ("FramedScrollbar ==> " + n);
 *             }            
 *           }          
 *         },
 *         
 *         new CSProcess () {        
 *           public void run () {
 *             final int second = 1000;                // time is in millisecs
 *             final int enabledTime = 10*second;
 *             final int disabledCountdown = 5;
 *             final CSTimer tim = new CSTimer ();
 *             while (true) {
 *               tim.sleep (enabledTime);
 *               configure.out ().write (Boolean.FALSE);
 *               for (int i = disabledCountdown; i > 0; i--) {
 *                 System.out.println ("\t\t\t\tScrollbar disabled ... " + i);
 *                 tim.sleep (second);
 *               }
 *               configure.out ().write (Boolean.TRUE);
 *               System.out.println ("\t\t\t\tScrollbar enabled ...");
 *             }            
 *           }          
 *         }
 *         
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.awt.ActiveScrollbar * @see org.jcsp.plugNplay.FramedButton * @see org.jcsp.plugNplay.FramedButtonArray * @see org.jcsp.plugNplay.FramedButtonGrid * * @author P.H. Welch * */ //}}} public final class FramedScrollbar implements CSProcess { /** The frame for the scrollbar */ private final ActiveClosingFrame activeClosingFrame; /** The scrollbar */ private final ActiveScrollbar scrollbar; /** * Construct a framed scrollbar process. *

* * @param title the title for the frame (must not be null) * @param pixDown the pixel hieght of the frame (must be at least 10 if horizontal, otherwise at least 100) * @param pixAcross the pixel width of the frame ((must be at least 10 if vertical, otherwise at least 100) * @param configure the configure channel for the scrollbar (may be null) * @param event the event channel from the scrollbar (must not be null) * @param horizontal true for a horizontal scrollbar, false for a vertical one * @param value the initial position of the button in the scrollbar (must be between minimum and maximum inclusive) * @param visible the size of the button in the scrollbar (must be at least 10) * @param minimum the minimum position of the button in the scrollbar * @param maximum the maximum position of the button in the scrollbar * */ public FramedScrollbar (String title, int pixDown, int pixAcross, ChannelInput configure, ChannelOutputInt event, boolean horizontal, int value, int visible, int minimum, int maximum) { // check everything ... if (title == null) { throw new IllegalArgumentException ( "From FramedScrollbar (title == null)" ); } /* if ((orientation != Scrollbar.HORIZONTAL) && (orientation != Scrollbar.VERTICAL)) { throw new IllegalArgumentException ( "From FramedScrollbar (illegal orientation)" ); } */ if (horizontal) { if ((pixDown < 60) || (pixAcross < 100)) { throw new IllegalArgumentException ( "From FramedScrollbar (pixDown < 10) || (pixAcross < 100)" ); } } else { if ((pixDown < 100) || (pixAcross < 10)) { throw new IllegalArgumentException ( "From FramedScrollbar (pixDown < 100) || (pixAcross < 10)" ); } } int orientation = horizontal ? Scrollbar.HORIZONTAL : Scrollbar.VERTICAL; if (visible < 10) { throw new IllegalArgumentException ( "From FramedScrollbar (visible < 10)" ); } if (minimum >= maximum) { throw new IllegalArgumentException ( "From FramedScrollbar (minimum >= maximum)" ); } if ((value < minimum) || (maximum < value)) { throw new IllegalArgumentException ( "From FramedScrollbar (value < minimum) || (maximum < value)" ); } if (event == null) { throw new IllegalArgumentException ( "From FramedScrollbar (event == null)" ); } // OK - now build ... activeClosingFrame = new ActiveClosingFrame (title); final ActiveFrame activeFrame = activeClosingFrame.getActiveFrame (); scrollbar = new ActiveScrollbar ( configure, event, orientation, value, visible, minimum, visible + maximum ); activeFrame.setSize (pixAcross, pixDown); activeFrame.add (scrollbar); activeFrame.setVisible (true); } /** * The main body of this process. */ public void run () { new Parallel ( new CSProcess[] { activeClosingFrame, scrollbar } ).run (); } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Merge2.java0000644000000000000000000001444411105701167017107 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Merges two strictly increasing Integer input streams into one * strictly increasing output stream. *

Process Diagram

* *
 *    in0  ________
 *   -->--|        | out
 *    in1 | Merge2 |-->--
 *   -->--|________|
 * 
*

Description

* Merge2 is a process whose output stream is the ordered merging * of the Integers on its input streams. It assumes that each input stream is * strictly increasing (i.e. with no repeats) sequence of Integers. * It generates a strictly increasing output stream containing all * -- and only -- the Integers from its input streams (eliminating any duplicates). *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
in0, in1java.lang.Number * Both channels can accept data from any subclass of Number. It is * possible to send Floats down one channel and Integers down the * other. However all values will be converted to ints. *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
*

Example

* The following example shows how to use Merge2 in a small program. * The program also uses some of the other plugNplay processes. The * program prints, in ascending order (up to Integer.MAX_VALUE), all integers * whose prime factors consist only of 2, 3 and 5. Curious readers may like * to reason why the infinitely buffered channels are needed. * *
 * import org.jcsp.lang.*;
 * import org.jcsp.util.*;
 * import org.jcsp.plugNplay.*;
 * 
 * public class Merge2Example {
 * 
 *   public static void main (String[] argv) {
 * 
 *     final One2OneChannel[] a = Channel.one2oneArray (4);
 *     final One2OneChannel[] b = Channel.one2oneArray (3, new InfiniteBuffer ());
 *     final One2OneChannel c = Channel.one2one ();
 *     final One2OneChannel d = Channel.one2one ();
 *     final One2OneChannel e = Channel.one2one ();
 * 
 *     new Parallel (
 *       new CSProcess[] {
 *         new Mult (2, a[0].in (), b[0].out ()),
 *         new Mult (3, a[1].in (), b[1].out ()),
 *         new Mult (5, a[2].in (), b[2].out ()),
 *         new Merge2 (b[0].in (), b[1].in (), c.out ()),
 *         new Merge2 (c.in (), b[2].in (), d.out ()),
 *         new Prefix (1, d.in (), e.out ()),
 *         new Delta (e.in (), Channel.getOutputArray (a)),
 *         new Printer (a[3].in (), "--> ", "\n")
 *       }
 *     ).run ();
 * 
 *   }
 * 
 * }
 * 
* * @see org.jcsp.plugNplay.Merge * * @author P.H. Welch */ public final class Merge2 implements CSProcess { /** The first input Channel */ private final ChannelInput in0; /** The second input Channel */ private final ChannelInput in1; /** The output Channel */ private final ChannelOutput out; /** * Construct a new Merge2 process with the input channels * in0 and in1 and the output channel out. * The ordering of the input channels makes no difference * to the behaviour of this process. * * @param in0 an input channel * @param in1 an input channel * @param out the output channel */ public Merge2(ChannelInput in0, ChannelInput in1, ChannelOutput out) { this.in0 = in0; this.in1 = in1; this.out = out; } /** * The main body of this process. */ public void run() { Number X0, X1; X0 = (Number) in0.read(); X1 = (Number) in1.read(); while (true) { if (X0.intValue() < X1.intValue()) { out.write(X0); X0 = (Number) in0.read(); } else if (X0.intValue() > X1.intValue()) { out.write(X1); X1 = (Number) in1.read(); } else { out.write(X0); X0 = (Number) in0.read(); X1 = (Number) in1.read(); } } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Generate.java0000644000000000000000000000646311105701167017522 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * Generates an infinite (constant) sequence of Integers. *

Process Diagram

*

*

Description

* Generate is a process that generates an infinite sequence * of the integer, n, with which it is configured. *

Channel Protocols

* * * * * * * * * *
Output Channels
outjava.lang.Integer * The output will always be of type Integer. *
* * @author P.H. Welch and P.D. Austin and P.H. Welch */ public final class Generate implements CSProcess { /** The output Channel */ private final ChannelOutput out; /** The output number */ private final Integer N; /** * Construct a new Generate process with the output channel out. * * @param out the output channel * @param n the integer to generate */ public Generate(final ChannelOutput out, final int n) { this.out = out; N = new Integer(n); } /** * The main body of this process. */ public void run() { try { while (true) out.write(N); } catch (PoisonException p) { // nothing to do } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/FixedDelay.java0000644000000000000000000001045111105701167017776 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This process copies input to output, imposing a fixed time delay * between these events. *

Process Diagram

*

*

Description

* This process copies input to output, imposing a fixed time delay * between these events. * Note that this does not imply that the rate of output will be regular, * since that depends on the rate of input and the rate at which output * taken. * To impose a regular rate of output, see {@link Regulate}. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
Output Channels
outjava.lang.Object * The out Channel sends the the same type of data (in * fact, the same data) as is input. *
* * @see org.jcsp.plugNplay.Regulate * @see org.jcsp.plugNplay.Regular * * @author P.H. Welch and P.D. Austin */ public final class FixedDelay implements CSProcess { /** The input Channel */ private ChannelInput in; /** The output Channel */ private ChannelOutput out; /** * The time the process is to wait in milliseconds between receiving a * message and then sending it. */ private long delayTime; /** * This process copies input to output, imposing a fixed time delay * between these events. * * @param delayTime the time the process is to wait in milliseconds * between receiving a message and then sending it – * a zero or negative value implies no waiting. * @param in the input Channel * @param out the output Channel */ public FixedDelay(long delayTime, ChannelInput in, ChannelOutput out) { this.in = in; this.out = out; this.delayTime = delayTime; } /** * The main body of this process. */ public void run() { CSTimer tim = new CSTimer(); while (true) { Object o = in.read(); tim.sleep(delayTime); out.write(o); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Printer.java0000644000000000000000000001227411105701167017410 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; import java.io.*; /** * Prints each Object from its input channel to a PrintStream. *

Process Diagram

*

*

Description

* Printer is a process for printing each object from its * in channel to a PrintStream object (by default, * System.out). *

* For convenience, Printer may be configured with prefix and postfix * strings with which to decorate its output. * *

Channel Protocols

* * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
* *

Example

* See the example in {@link Merge}. * * @see org.jcsp.lang.Parallel * * @author P.H. Welch and P.D. Austin */ public class Printer implements CSProcess { /** The channel from which to read */ private ChannelInput in; /** The stream to which to write */ private PrintStream printStream; /** The string to write in front of each object */ private String prefix; /** The string to write after each object */ private String postfix; /** * Construct a new Printer with System.out as * its PrintStream and empty prefix and postfix strings. * * @param in the channel from which to read */ public Printer(final ChannelInput in) { this(in, System.out, "", ""); } /** * Construct a new Printer with System.out as * its PrintStream. * * @param in the channel from which to read * @param prefix the string to write in front of each object * @param postfix the string to write after each object */ public Printer(final ChannelInput in, final String prefix, final String postfix) { this(in, System.out, prefix, postfix); } /** * Construct a new Printer with empty prefix and postfix strings. * * @param in the channel from which to read * @param printStream the stream to which to write */ public Printer(final ChannelInput in, final PrintStream printStream) { this(in, printStream, "", ""); } /** * Construct a new Printer. * * @param in he channel from which to read * @param printStream the stream to which to write * @param prefix the string to write in front of each object * @param postfix the string to write after each object */ public Printer(final ChannelInput in, final PrintStream printStream, final String prefix, final String postfix) { this.in = in; this.printStream = printStream; this.prefix = prefix; this.postfix = postfix; } /** * The main body of this process. */ public synchronized void run() { try { while (true) { printStream.print(prefix); printStream.print(in.read()); printStream.print(postfix); } } catch (PoisonException p) { // nothing to do } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Delta2.java0000644000000000000000000001051311105701167017072 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This process broadcasts objects arriving on its input channel in parallel * to its two output channels. * *

Process Diagram

* *
 *         ________  out0 
 *    in  |        |--->---
 *   -->--| Delta2 | out1
 *        |________|--->---
 * 
*

Description

* The Delta2 class is a process which has an infinite loop that waits * for Objects of any type to be sent down the in Channel. The process then * writes the reference to the Object in parallel down the out0 and out1 * Channels. *

*

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Object * The in Channel can accept data of any Class. *
Output Channels
out0, out1java.lang.Object * The output Channels will carry a broadcast of whatever * is sent down the in Channel. *
* * @author P.H. Welch and P.D. Austin */ public final class Delta2 implements CSProcess { /** The input Channel */ private ChannelInput in; /** The first output Channel */ private ChannelOutput out0; /** The second output Channel */ private ChannelOutput out1; /** * Construct a new Delta2 process with the input Channel in and the output * Channels out0 and out1. The ordering of the Channels out0 and out1 make * no difference to the functionality of this process. * * @param in the input channel * @param out0 an output Channel * @param out1 an output Channel */ public Delta2(ChannelInput in, ChannelOutput out0, ChannelOutput out1) { this.in = in; this.out0 = out0; this.out1 = out1; } /** * The main body of this process. */ public void run() { ProcessWrite[] parWrite = {new ProcessWrite(out0), new ProcessWrite(out1)}; Parallel par = new Parallel(parWrite); while (true) { Object value = in.read(); parWrite[0].value = value; parWrite[1].value = value; par.run(); } } } jcsp-1.1-rc4.orig/src/org/jcsp/plugNplay/Demultiplex.java0000644000000000000000000001036511105701167020260 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// package org.jcsp.plugNplay; import org.jcsp.lang.*; /** * This demultiplexes data from its input channel to its output channel array. * *

Process Diagram

*

*

Description

* Demultiplex is a process to convert the single stream of * (Integer, Object) messages sent from a {@link Multiplex} process on the other * end of its in channel back into separate streams (its out * channels). It assumes that {@link Multiplex} operates on the same * size array of channels as its out array. *

* The protocol on the incoming multiplexed stream consists of * an Integer, that represents the channel identity of the * multiplexed data, followed by the multiplexed data. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
injava.lang.Integer, java.lang.Object * A channel index followed by the multiplexed data. *
Output Channels
out[]java.lang.Object * All channels in this package carry integers. *
* * @see org.jcsp.plugNplay.Multiplex * @see org.jcsp.plugNplay.Paraplex * @see org.jcsp.plugNplay.Deparaplex * * @author P.H. Welch and P.D. Austin */ public final class Demultiplex implements CSProcess { /** The input Channel */ private final ChannelInput in; /** The output Channels */ private final ChannelOutput[] out; /** * Construct a new Demultiplex process with the input Channel in and the output * Channels out. The ordering of the Channels in the out array make * no difference to the functionality of this process. * * @param in the input channel * @param out the output channels */ public Demultiplex(final ChannelInput in, final ChannelOutput[] out) { this.in = in; this.out = out; } /** * The main body of this process. */ public void run() { while (true) { int index = ((Integer) in.read()).intValue(); out[index].write(in.read()); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/0000755000000000000000000000000011410045043013450 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/call/0000755000000000000000000000000011410045042014362 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/call/B2.java0000644000000000000000000000442311111352066015500 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class B2 implements CSProcess { // no Foo interface final private B1 b; public B2 (final FooChannel in) { b = new B1 (in); } public void run () { b.run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/One2OneFooChannel.java0000644000000000000000000000564611111352066020447 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class One2OneFooChannel extends One2OneCallChannel implements FooChannel { public int calculate (int a, double b, long c) { join (); // ready to make the CALL int t = ((Foo) server).calculate (a, b, c); fork (); // call finished return t; } public void processQuery (int a, double b, long c) { join (); // ready to make the CALL ((Foo) server).processQuery (a, b, c); fork (); // call finished } public double closeValve (int a, double b, long c) { join (); // ready to make the CALL double t = ((Foo) server).closeValve (a, b, c); fork (); // call finished return t; } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/Any2AnyMain.java0000644000000000000000000000524311111352066017324 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class Any2AnyMain { public static final String TITLE = "Any-Any Call Channel"; public static final String DESCR = "Shows an Any-Any call channel in use. The channel has three methods: " + "'processQuery', 'calculate' and 'closeValve'."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); Any2AnyFooChannel c = new Any2AnyFooChannel (); new Parallel ( new CSProcess[] { new A (c), new B2 (c) } ).run (); System.exit (0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/Any2OneFooChannel.java0000644000000000000000000000564611111352066020455 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Any2OneFooChannel extends Any2OneCallChannel implements FooChannel { public int calculate (int a, double b, long c) { join (); // ready to make the CALL int t = ((Foo) server).calculate (a, b, c); fork (); // call finished return t; } public void processQuery (int a, double b, long c) { join (); // ready to make the CALL ((Foo) server).processQuery (a, b, c); fork (); // call finished } public double closeValve (int a, double b, long c) { join (); // ready to make the CALL double t = ((Foo) server).closeValve (a, b, c); fork (); // call finished return t; } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/A.java0000644000000000000000000000521211111352066015412 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class A implements CSProcess { private final Foo out; public A (final Foo out) { this.out = out; } public void run () { System.out.println ("A: out.calculate (3, 4.0, 5)"); int t = out.calculate (3, 4.0, 5); System.out.println ("A: ==> " + t); System.out.println ("A: out.closeValve (6, 7.0, 8)"); double s = out.closeValve (6, 7.0, 8); System.out.println ("A: ==> " + s); System.out.println ("A: out.processQuery (0, 1.0, 2)"); out.processQuery (0, 1.0, 2); System.out.println ("A: ==> returned OK"); } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/Any2OneMain.java0000644000000000000000000000524311111352066017316 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class Any2OneMain { public static final String TITLE = "Any-One Call Channel"; public static final String DESCR = "Shows an Any-One call channel in use. The channel has three methods: " + "'processQuery', 'calculate' and 'closeValve'."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); Any2OneFooChannel c = new Any2OneFooChannel (); new Parallel ( new CSProcess[] { new A (c), new B2 (c) } ).run (); System.exit (0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/One2AnyMain.java0000644000000000000000000000524311111352066017316 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class One2AnyMain { public static final String TITLE = "One-Any Call Channel"; public static final String DESCR = "Shows an One-Any call channel in use. The channel has three methods: " + "'processQuery', 'calculate' and 'closeValve'."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); One2AnyFooChannel c = new One2AnyFooChannel (); new Parallel ( new CSProcess[] { new A (c), new B2 (c) } ).run (); System.exit (0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/Foo.java0000644000000000000000000000434411111352066015762 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface Foo { public int calculate (int a, double b, long c); public void processQuery (int a, double b, long c); public double closeValve (int a, double b, long c); } jcsp-1.1-rc4.orig/src/jcsp-demos/call/FooChannel.java0000644000000000000000000000417111111352066017251 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ interface FooChannel extends Foo, ChannelAccept {} jcsp-1.1-rc4.orig/src/jcsp-demos/call/Any2AnyFooChannel.java0000644000000000000000000000564611111352066020463 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Any2AnyFooChannel extends Any2AnyCallChannel implements FooChannel { public int calculate (int a, double b, long c) { join (); // ready to make the CALL int t = ((Foo) server).calculate (a, b, c); fork (); // call finished return t; } public void processQuery (int a, double b, long c) { join (); // ready to make the CALL ((Foo) server).processQuery (a, b, c); fork (); // call finished } public double closeValve (int a, double b, long c) { join (); // ready to make the CALL double t = ((Foo) server).closeValve (a, b, c); fork (); // call finished return t; } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/One2AnyFooChannel.java0000644000000000000000000000564611111352066020455 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class One2AnyFooChannel extends One2AnyCallChannel implements FooChannel { public int calculate (int a, double b, long c) { join (); // ready to make the CALL int t = ((Foo) server).calculate (a, b, c); fork (); // call finished return t; } public void processQuery (int a, double b, long c) { join (); // ready to make the CALL ((Foo) server).processQuery (a, b, c); fork (); // call finished } public double closeValve (int a, double b, long c) { join (); // ready to make the CALL double t = ((Foo) server).closeValve (a, b, c); fork (); // call finished return t; } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/B1.java0000644000000000000000000000555211111352066015503 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class B1 implements CSProcess, Foo { private final ChannelAccept in; public B1 (final ChannelAccept in) { this.in = in; } public int calculate (int a, double b, long c) { int result = a + (int) b + (int) c; System.out.println ("B.calculate: " + a + ", " + b + ", " + c + " ==> " + result); return result; } public void processQuery (int a, double b, long c) { System.out.println ("B1.processQuery: " + a + ", " + b + ", " + c); } public double closeValve (int a, double b, long c) { int result = a + (int) b + (int) c; System.out.println ("B1.closeValve: " + a + ", " + b + ", " + c + " ==> " + result); return result; } public void run () { in.accept (this); in.accept (this); in.accept (this); } } jcsp-1.1-rc4.orig/src/jcsp-demos/call/One2OneMain.java0000644000000000000000000000524311111352066017310 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class One2OneMain { public static final String TITLE = "One-One Call Channel"; public static final String DESCR = "Shows an One-One call channel in use. The channel has three methods: " + "'processQuery', 'calculate' and 'closeValve'."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); One2OneFooChannel c = new One2OneFooChannel (); new Parallel ( new CSProcess[] { new A (c), new B2 (c) } ).run (); System.exit (0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/0000755000000000000000000000000011410045034016167 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/0000755000000000000000000000000011410045034017577 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/DiningPhilosophersCollege.java0000644000000000000000000000647711111352066025567 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class DiningPhilosophersCollege implements CSProcess { private final int nPhilosophers; private final ChannelOutput report; public DiningPhilosophersCollege (int nPhilosophers, ChannelOutput report) { this.nPhilosophers = nPhilosophers; this.report = report; } public void run () { final One2OneChannel[] left = Channel.one2oneArray (nPhilosophers); final One2OneChannel[] right = Channel.one2oneArray (nPhilosophers); final Any2OneChannel down = Channel.any2one (); final Any2OneChannel up = Channel.any2one (); final Fork[] fork = new Fork[nPhilosophers]; for (int i = 0; i < nPhilosophers; i++) { fork[i] = new Fork (nPhilosophers, i, left[i].in (), right[(i + 1)%nPhilosophers].in (), report); } final Philosopher[] phil = new Philosopher[nPhilosophers]; for (int i = 0; i < nPhilosophers; i++) { phil[i] = new Philosopher (i, left[i].out (), right[i].out (), down.out (), up.out (), report); } new Parallel ( new CSProcess[] { new Parallel (phil), new Parallel (fork), new Security (down.in (), up.in (), report, nPhilosophers - 1), new Clock (report) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/ForkReport.java0000644000000000000000000000454211111352066022550 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class ForkReport extends ISReport { public static final int DOWN = 0; public static final int UP = 1; protected int philId; public ForkReport (int philId, int id, int state) { super (id, state); this.philId = philId; } public int getPhilId () { return philId; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/ClockReport.java0000644000000000000000000000422511111352066022700 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class ClockReport extends ISReport { public ClockReport (int tick) { super (tick, 0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/DiningDisplay.java0000644000000000000000000000421511111352066023206 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface DiningDisplay extends CollegeDisplay, PhilDisplay, ForkDisplay, SecurityDisplay { } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/TextDisplay.java0000644000000000000000000001112211111352066022715 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class TextDisplay implements CSProcess { // attributes private final ChannelInput in; private final int nPhilosophers; // constructors public TextDisplay (int nPhilosophers, ChannelInput in) { this.nPhilosophers = nPhilosophers; this.in = in; } private String space (int n) { String s = " "; for (int i = 0; i < n; i++) { s = s + " "; } return s; } // public methods public void run () { ISReport report; int id, state, philId; System.out.println ("\nCollege starting with " + nPhilosophers + " philosophers\n"); while (true) { report = (ISReport) in.read (); id = report.getId (); state = report.getState (); if (report instanceof PhilReport) { switch (state) { case PhilReport.THINKING: System.out.println (space(id) + "Philosopher " + id + " is thinking ..."); break; case PhilReport.HUNGRY: System.out.println (space(id) + "Philosopher " + id + " is hungry ..."); break; case PhilReport.SITTING: System.out.println (space(id) + "Philosopher " + id + " is sitting ..."); break; case PhilReport.EATING: System.out.println (space(id) + "Philosopher " + id + " is eating ..."); break; case PhilReport.LEAVING: System.out.println (space(id) + "Philosopher " + id + " has finished eating ..."); break; } } else if (report instanceof ForkReport) { philId = ((ForkReport) report).getPhilId (); switch (state) { case ForkReport.DOWN: System.out.println (space(philId) + "Philosopher " + philId + " has put down fork " + id + " ..."); break; case ForkReport.UP: System.out.println (space(philId) + "Philosopher " + philId + " has picked up fork " + id + " ..."); break; } } else if (report instanceof SecurityReport) { System.out.println ("Security: " + id + " sat down ..."); } else if (report instanceof ClockReport) { System.out.println ("\n[TICK " + id + "]\n"); } else { System.out.println ("\nBad report !!!"); } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/ForkDisplay.java0000644000000000000000000000425011111352066022676 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface ForkDisplay { public void forkUp (int id, int philId); public void forkDown (int id, int philId); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/PhilReport.java0000644000000000000000000000454711111352066022550 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class PhilReport extends ISReport { public static final int THINKING = 0; public static final int HUNGRY = 1; public static final int SITTING = 2; public static final int EATING = 3; public static final int LEAVING = 4; public PhilReport (int id, int state) { super (id, state); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/ISReport.java0000644000000000000000000000444111111352066022160 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class ISReport { protected int id, state; public ISReport (int id, int state) { this.id = id; this.state = state; } public int getId () { return id; } public int getState () { return state; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/Fork.java0000644000000000000000000000666511111352066021364 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Fork implements CSProcess { // protected attributes protected int id; protected Integer Id; protected AltingChannelInput left, right; protected ChannelOutput report; protected ForkReport leftUp, leftDown, rightUp, rightDown; // constructors public Fork (int nPhilosophers, int id, AltingChannelInput left, AltingChannelInput right, ChannelOutput report) { this.id = id; Id = new Integer(id); this.left = left; this.right = right; this.report = report; leftUp = new ForkReport (id, id, ForkReport.UP); leftDown = new ForkReport (id, id, ForkReport.DOWN); rightUp = new ForkReport ((id + 1) % nPhilosophers, id, ForkReport.UP); rightDown = new ForkReport ((id + 1) % nPhilosophers, id, ForkReport.DOWN); } // public methods public void run () { Alternative alt = new Alternative (new Guard[] {left, right}); final int LEFT = 0; final int RIGHT = 1; while (true) { switch (alt.fairSelect ()) { case LEFT: left.read (); report.write (leftUp); left.read (); report.write (leftDown); break; case RIGHT: right.read (); report.write (rightUp); right.read (); report.write (rightDown); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/Philosopher.java0000644000000000000000000001155011111352066022744 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.util.Random; import org.jcsp.lang.*; import org.jcsp.plugNplay.*; /** * @author P.H. Welch */ class Philosopher implements CSProcess { // protected attributes protected final static int seconds = 1000; protected final static int maxThink = 10*seconds; protected final static int maxEat = 15*seconds; protected final static String[] space = {" ", " ", " ", " ", " "}; protected final int id; protected final ChannelOutput left, right, down, up; protected final ChannelOutput report; protected final Random random; // constructors public Philosopher (int id, ChannelOutput left, ChannelOutput right, ChannelOutput down, ChannelOutput up, ChannelOutput report) { this.id = id; this.left = left; this.right = right; this.down = down; this.up = up; this.report = report; this.random = new Random (id + 1); } // public methods public void run () { final Integer Id = new Integer (id); final CSTimer tim = new CSTimer (); final PhilReport thinking = new PhilReport (id, PhilReport.THINKING); final PhilReport hungry = new PhilReport (id, PhilReport.HUNGRY); final PhilReport sitting = new PhilReport (id, PhilReport.SITTING); final PhilReport eating= new PhilReport (id, PhilReport.EATING); final PhilReport leaving = new PhilReport (id, PhilReport.LEAVING); final ProcessWrite signalLeft = new ProcessWrite (left); signalLeft.value = Id; final ProcessWrite signalRight = new ProcessWrite (right); signalRight.value = Id; final CSProcess signalForks = new Parallel (new CSProcess[] {signalLeft, signalRight}); /*final CSProcess signalForks = new Sequence ( new CSProcess[] { signalLeft, new CSProcess () { public void run () { tim.sleep (seconds); } }, signalRight } );*/ while (true) { report.write (thinking); tim.sleep (range (maxThink)); // thinking report.write (hungry); down.write (Id); // get past the security guard report.write (sitting); signalForks.run (); // pick up my forks (in parallel) report.write (eating); tim.sleep (range (maxEat)); // eating report.write (leaving); signalForks.run (); // put down my forks (in parallel) up.write (Id); // get up from the table and go past the security guard } } // protected methods protected int range (int n) { // returns random int in the range 0 .. (n - 1) [This is not needed in JDK 1.2.x] int i = random.nextInt (); if (i < 0) { if (i == Integer.MIN_VALUE) { i = 42; } else { i = -i; } } return i % n; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/PhilDisplay.java0000644000000000000000000000441611111352066022675 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface PhilDisplay { public void philThinking (int id); public void philHungry (int id); public void philSitting (int id); public void philEating (int id); public void philLeaving (int id); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/SecurityReport.java0000644000000000000000000000424311111352066023454 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class SecurityReport extends ISReport { public SecurityReport (int nSitting) { super (nSitting, 0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/Security.java0000644000000000000000000000647411111352066022270 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Security implements CSProcess { // protected attributes protected AltingChannelInput down, up; protected ChannelOutput report; protected int maxSitting; protected SecurityReport[] seated; // constructors public Security (AltingChannelInput down, AltingChannelInput up, ChannelOutput report, int nMaxSitting) { this.down = down; this.up = up; this.report = report; this.maxSitting = nMaxSitting; this.seated = new SecurityReport [nMaxSitting + 1]; for (int i = 0; i < (maxSitting + 1); i++) { seated[i] = new SecurityReport (i); } } // public methods public void run () { Alternative alt = new Alternative (new Guard[] {down, up}); boolean[] precondition = {true, true}; final int DOWN = 0; final int UP = 1; int nSitting = 0; while (true) { precondition[DOWN] = (nSitting < maxSitting); switch (alt.fairSelect (precondition)) { case DOWN: down.read (); nSitting++; report.write (seated[nSitting]); break; case UP: up.read (); nSitting--; report.write (seated[nSitting]); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/Clock.java0000644000000000000000000000527411111352066021511 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Clock implements CSProcess { // protected attributes protected static final int seconds = 1000; protected static final int period = 1*seconds; protected ChannelOutput report; // constructors public Clock (ChannelOutput report) { this.report = report; } // public methods public void run () { int tick = 0; while (true) { report.write (new ClockReport (tick)); sleep (period); tick++; } } // protected methods protected void sleep (long t) { try { Thread.sleep (t); } catch (InterruptedException e) {}; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/SecurityDisplay.java0000644000000000000000000000415611111352066023611 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface SecurityDisplay { public void sitting (int n); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/PhilMain.java0000644000000000000000000000604611111352066022155 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class PhilMain { public static final String TITLE = "Dining Philosophers"; public static final String DESCR = "Shows the 'dining philosophers' deadlock problem and solution implemented using JCSP channels. " + "Each of the philosophers attempts to claim the shared resources (forks) via channels (which may block). " + "Deadlock is prevented by the security guard which each philosopher must communicate " + "with to gain permission to claim a fork."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("philosophers", 1, 100, 10); Ask.show (); final int nPhilosophers = Ask.readInt ("philosophers"); Ask.blank (); Any2OneChannel report = Channel.any2one (); new Parallel ( new CSProcess[] { new DiningPhilosophersCollege (nPhilosophers, report.out ()), new TextDisplay (nPhilosophers, report.in ()) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/channel/CollegeDisplay.java0000644000000000000000000000424011111352066023346 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface CollegeDisplay { public void collegeInitialise (int n); public void collegeTick (int tick); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/0000755000000000000000000000000011410045034017735 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/DiningPhilosophersCollege.java0000644000000000000000000000616411111352066025716 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class DiningPhilosophersCollege implements CSProcess { private final int nPhilosophers; private final ChannelOutput report; public DiningPhilosophersCollege (int nPhilosophers, ChannelOutput report) { this.nPhilosophers = nPhilosophers; this.report = report; } public void run () { final One2OneChannel[] left = Channel.one2oneArray (nPhilosophers); final One2OneChannel[] right = Channel.one2oneArray (nPhilosophers); final Fork[] fork = new Fork[nPhilosophers]; for (int i = 0; i < nPhilosophers; i++) { fork[i] = new Fork (nPhilosophers, i, left[i].in (), right[(i + 1)%nPhilosophers].in (), report); } final Philosopher[] phil = new Philosopher[nPhilosophers]; for (int i = 0; i < nPhilosophers; i++) { phil[i] = new Philosopher (i, left[i].out (), right[i].out (), report); } new Parallel ( new CSProcess[] { new Parallel (phil), new Parallel (fork), new Clock (report) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/ForkReport.java0000644000000000000000000000454211111352066022706 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class ForkReport extends ISReport { public static final int DOWN = 0; public static final int UP = 1; protected int philId; public ForkReport (int philId, int id, int state) { super (id, state); this.philId = philId; } public int getPhilId () { return philId; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/ClockReport.java0000644000000000000000000000422511111352066023036 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class ClockReport extends ISReport { public ClockReport (int tick) { super (tick, 0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/DiningDisplay.java0000644000000000000000000000417411111352066023350 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface DiningDisplay extends CollegeDisplay, PhilDisplay, ForkDisplay { } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/TextDisplay.java0000644000000000000000000001073111111352066023060 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class TextDisplay implements CSProcess { // attributes private final ChannelInput in; private final int nPhilosophers; // constructors public TextDisplay (int nPhilosophers, ChannelInput in) { this.nPhilosophers = nPhilosophers; this.in = in; } private String space (int n) { String s = " "; for (int i = 0; i < n; i++) { s = s + " "; } return s; } // public methods public void run () { ISReport report; int id, state, philId; System.out.println ("\nCollege starting with " + nPhilosophers + " philosophers\n"); while (true) { report = (ISReport) in.read (); id = report.getId (); state = report.getState (); if (report instanceof PhilReport) { switch (state) { case PhilReport.THINKING: System.out.println (space(id) + "Philosopher " + id + " is thinking ..."); break; case PhilReport.HUNGRY: System.out.println (space(id) + "Philosopher " + id + " is hungry ..."); break; case PhilReport.SITTING: System.out.println (space(id) + "Philosopher " + id + " is sitting ..."); break; case PhilReport.EATING: System.out.println (space(id) + "Philosopher " + id + " is eating ..."); break; case PhilReport.LEAVING: System.out.println (space(id) + "Philosopher " + id + " has finished eating ..."); break; } } else if (report instanceof ForkReport) { philId = ((ForkReport) report).getPhilId (); switch (state) { case ForkReport.DOWN: System.out.println (space(philId) + "Philosopher " + philId + " has put down fork " + id + " ..."); break; case ForkReport.UP: System.out.println (space(philId) + "Philosopher " + philId + " has picked up fork " + id + " ..."); break; } } else if (report instanceof ClockReport) { System.out.println ("\n[TICK " + id + "]\n"); } else { System.out.println ("\nBad report !!!"); } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/ForkDisplay.java0000644000000000000000000000425011111352066023034 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface ForkDisplay { public void forkUp (int id, int philId); public void forkDown (int id, int philId); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/PhilReport.java0000644000000000000000000000454711111352066022706 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class PhilReport extends ISReport { public static final int THINKING = 0; public static final int HUNGRY = 1; public static final int SITTING = 2; public static final int EATING = 3; public static final int LEAVING = 4; public PhilReport (int id, int state) { super (id, state); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/ISReport.java0000644000000000000000000000444111111352066022316 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class ISReport { protected int id, state; public ISReport (int id, int state) { this.id = id; this.state = state; } public int getId () { return id; } public int getState () { return state; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/Fork.java0000644000000000000000000000666511111352066021522 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Fork implements CSProcess { // protected attributes protected int id; protected Integer Id; protected AltingChannelInput left, right; protected ChannelOutput report; protected ForkReport leftUp, leftDown, rightUp, rightDown; // constructors public Fork (int nPhilosophers, int id, AltingChannelInput left, AltingChannelInput right, ChannelOutput report) { this.id = id; Id = new Integer(id); this.left = left; this.right = right; this.report = report; leftUp = new ForkReport (id, id, ForkReport.UP); leftDown = new ForkReport (id, id, ForkReport.DOWN); rightUp = new ForkReport ((id + 1) % nPhilosophers, id, ForkReport.UP); rightDown = new ForkReport ((id + 1) % nPhilosophers, id, ForkReport.DOWN); } // public methods public void run () { Alternative alt = new Alternative (new Guard[] {left, right}); final int LEFT = 0; final int RIGHT = 1; while (true) { switch (alt.fairSelect ()) { case LEFT: left.read (); report.write (leftUp); left.read (); report.write (leftDown); break; case RIGHT: right.read (); report.write (rightUp); right.read (); report.write (rightDown); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/Philosopher.java0000644000000000000000000001106511111352066023103 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.util.Random; import org.jcsp.lang.*; import org.jcsp.plugNplay.*; /** * @author P.H. Welch */ class Philosopher implements CSProcess { // protected attributes protected final static int seconds = 1000; protected final static int maxThink = 3*seconds; protected final static int maxEat = 5*seconds; protected final static String[] space = {" ", " ", " ", " ", " "}; protected final int id; protected final ChannelOutput left, right; protected final ChannelOutput report; protected final Random random; // constructors public Philosopher (int id, ChannelOutput left, ChannelOutput right, ChannelOutput report) { this.id = id; this.left = left; this.right = right; this.report = report; this.random = new Random (id + 1); } // public methods public void run () { final Integer Id = new Integer (id); final CSTimer tim = new CSTimer (); final PhilReport thinking = new PhilReport (id, PhilReport.THINKING); final PhilReport hungry = new PhilReport (id, PhilReport.HUNGRY); final PhilReport sitting = new PhilReport (id, PhilReport.SITTING); final PhilReport eating= new PhilReport (id, PhilReport.EATING); final PhilReport leaving = new PhilReport (id, PhilReport.LEAVING); final ProcessWrite signalLeft = new ProcessWrite (left); signalLeft.value = Id; final ProcessWrite signalRight = new ProcessWrite (right); signalRight.value = Id; //final CSProcess signalForks = new Parallel (new CSProcess[] {signalLeft, signalRight}); final CSProcess signalForks = new Sequence ( new CSProcess[] { signalLeft, new CSProcess () { public void run () { tim.sleep (seconds); } }, signalRight } ); while (true) { report.write (thinking); tim.sleep (range (maxThink)); // thinking report.write (hungry); report.write (sitting); signalForks.run (); // pick up my forks (in parallel) report.write (eating); tim.sleep (range (maxEat)); // eating report.write (leaving); signalForks.run (); // put down my forks (in parallel) } } // protected methods protected int range (int n) { // returns random int in the range 0 .. (n - 1) [This is not needed in JDK 1.2.x] int i = random.nextInt (); if (i < 0) { if (i == Integer.MIN_VALUE) { i = 42; } else { i = -i; } } return i % n; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/PhilDisplay.java0000644000000000000000000000441611111352066023033 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface PhilDisplay { public void philThinking (int id); public void philHungry (int id); public void philSitting (int id); public void philEating (int id); public void philLeaving (int id); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/Clock.java0000644000000000000000000000527411111352066021647 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Clock implements CSProcess { // protected attributes protected static final int seconds = 1000; protected static final int period = 1*seconds; protected ChannelOutput report; // constructors public Clock (ChannelOutput report) { this.report = report; } // public methods public void run () { int tick = 0; while (true) { report.write (new ClockReport (tick)); sleep (period); tick++; } } // protected methods protected void sleep (long t) { try { Thread.sleep (t); } catch (InterruptedException e) {}; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/DeadMain.java0000644000000000000000000000636711111352066022262 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class DeadMain { public static final String TITLE = "Dining Philosophers [deadlocking]"; public static final String DESCR = "Shows the 'dining philosophers' deadlock problem. Each of the philosophers attempts to claim the " + "shared resources (forks) via channels (which may block). Deadlock may occur if all philosophers are " + "seated and each holds one fork. This is a non-deterministic system and so the point at which deadlock " + "occurs (if at all) cannot be predicted. When deadlock occurs, the clock will continue ticking but " + "no actions will be written to the screen by the philosophers as each is waiting to pick up another " + "fork."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("philosophers", 1, 100, 5); Ask.show (); final int nPhilosophers = Ask.readInt ("philosophers"); Ask.blank (); Any2OneChannel report = Channel.any2one (); new Parallel ( new CSProcess[] { new DiningPhilosophersCollege (nPhilosophers, report.out ()), new TextDisplay (nPhilosophers, report.in ()) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/deadlock/CollegeDisplay.java0000644000000000000000000000424011111352066023504 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface CollegeDisplay { public void collegeInitialise (int n); public void collegeTick (int tick); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/0000755000000000000000000000000011410045034020373 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/DiningPhilosophersCollege.java0000644000000000000000000000770111111352066026352 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class DiningPhilosophersCollege implements CSProcess { private final int nPhilosophers; private final int clockPeriod; private final PhilReport philReport; private final ForkReport forkReport; private final ChannelOutputInt securityReport; private final ChannelOutputInt clockReport; public DiningPhilosophersCollege (int nPhilosophers, int clockPeriod, PhilReport philReport, ForkReport forkReport, ChannelOutputInt securityReport, ChannelOutputInt clockReport) { this.nPhilosophers = nPhilosophers; this.clockPeriod = clockPeriod; this.philReport = philReport; this.forkReport = forkReport; this.securityReport = securityReport; this.clockReport = clockReport; } public void run () { final One2OneChannelInt[] left = Channel.one2oneIntArray (nPhilosophers); final One2OneChannelInt[] right = Channel.one2oneIntArray (nPhilosophers); final Any2OneChannelInt down = Channel.any2oneInt (); final Any2OneChannelInt up = Channel.any2oneInt (); final Fork[] fork = new Fork[nPhilosophers]; for (int i = 0; i < nPhilosophers; i++) { fork[i] = new Fork (nPhilosophers, i, left[i].in (), right[(i + 1)%nPhilosophers].in (), forkReport); } final Philosopher[] phil = new Philosopher[nPhilosophers]; for (int i = 0; i < nPhilosophers; i++) { phil[i] = new Philosopher (i, left[i].out (), right[i].out (), down.out (), up.out (), philReport); } new Parallel ( new CSProcess[] { new Parallel (phil), new Parallel (fork), new Security (down.in (), up.in (), securityReport, nPhilosophers - 1), new Clock (clockReport, clockPeriod) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/PhilCall.java0000644000000000000000000000704611111352066022741 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class PhilCall { public static final String TITLE = "Dining Philosophers [call channels]"; public static final String DESCR = "Shows the 'dining philosophers' deadlock problem and solution implemented using JCSP call channels. " + "Each of the philosophers attempts to claim the shared resources (forks) via calls made on the fork " + "call channels. Deadlock is prevented by the security guard which each philosopher must communicate " + "with (via call channel) to gain permission to claim a fork."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("philsophers", 1, 100, 10); Ask.show (); final int nPhilosophers = Ask.readInt ("philosophers"); Ask.blank (); final int seconds = 1000; final int clockPeriod = 1*seconds; PhilChannel philChannel = new PhilChannel (); ForkChannel forkChannel = new ForkChannel (); One2OneChannelInt securityChannel = Channel.one2oneInt (); One2OneChannelInt clockChannel = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new DiningPhilosophersCollege ( nPhilosophers, clockPeriod, philChannel, forkChannel, securityChannel.out (), clockChannel.out () ), new TextDisplay ( nPhilosophers, philChannel, forkChannel, securityChannel.in (), clockChannel.in () ) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/ForkReport.java0000644000000000000000000000424311111352066023342 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface ForkReport { public void forkUp (int id, int philId); public void forkDown (int id, int philId); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/TextDisplay.java0000644000000000000000000001254211111352066023520 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class TextDisplay implements CSProcess { // attributes private final int nPhilosophers; private final AltingChannelAccept philChannel; private final AltingChannelAccept forkChannel; private final AltingChannelInputInt securityChannel; private final AltingChannelInputInt clockChannel; private String space (int n) { String s = " "; for (int i = 0; i < n; i++) { s = s + " "; } return s; } // constructors public TextDisplay (int nPhilosophers, PhilChannel philChannel, ForkChannel forkChannel, AltingChannelInputInt securityChannel, AltingChannelInputInt clockChannel) { this.nPhilosophers = nPhilosophers; this.philChannel = philChannel; this.forkChannel = forkChannel; this.securityChannel = securityChannel; this.clockChannel = clockChannel; } private interface inner extends CSProcess, PhilReport, ForkReport {}; // public methods public void run () { new inner () { public void thinking (int id) { System.out.println (space(id) + "Philosopher " + id + " is thinking ..."); } public void hungry (int id) { System.out.println (space(id) + "Philosopher " + id + " is hungry ..."); } public void sitting (int id) { System.out.println (space(id) + "Philosopher " + id + " is sitting ..."); } public void eating (int id) { System.out.println (space(id) + "Philosopher " + id + " is eating ..."); } public void leaving (int id) { System.out.println (space(id) + "Philosopher " + id + " is leaving ..."); } public void forkUp (int id, int philId) { System.out.println (space(philId) + "Philosopher " + philId + " has picked up fork " + id + " ..."); } public void forkDown (int id, int philId) { System.out.println (space(philId) + "Philosopher " + philId + " has put down fork " + id + " ..."); } public void run () { final Alternative alt = new Alternative ( new Guard[] {philChannel, forkChannel, securityChannel, clockChannel} ); final int PHIL = 0; final int FORK = 1; final int SECURITY = 2; final int CLOCK = 3; System.out.println ("\nCollege starting with " + nPhilosophers + " philosophers\n"); while (true) { switch (alt.fairSelect ()) { case PHIL: philChannel.accept (this); break; case FORK: forkChannel.accept (this); break; case SECURITY: final int nSitting = securityChannel.read (); System.out.println ("Security: " + nSitting + " sat down ..."); break; case CLOCK: final int tick = clockChannel.read (); System.out.println ("\n[TICK " + tick + "]\n"); break; } } } }.run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/PhilReport.java0000644000000000000000000000435511111352066023341 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface PhilReport { public void thinking (int id); public void hungry (int id); public void sitting (int id); public void eating (int id); public void leaving (int id); } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/Fork.java0000644000000000000000000000620311111352066022144 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Fork implements CSProcess { // protected attributes protected int id; protected AltingChannelInputInt left, right; protected ForkReport report; // constructors public Fork (int nPhilosophers, int id, AltingChannelInputInt left, AltingChannelInputInt right, ForkReport report) { this.id = id; this.left = left; this.right = right; this.report = report; } // public methods public void run () { final Alternative alt = new Alternative (new Guard[] {left, right}); final int LEFT = 0; final int RIGHT = 1; int philId; while (true) { switch (alt.fairSelect ()) { case LEFT: philId = left.read (); report.forkUp (id, philId); philId = left.read (); report.forkDown (id, philId); break; case RIGHT: philId = right.read (); report.forkUp (id, philId); philId = right.read (); report.forkDown (id, philId); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/Philosopher.java0000644000000000000000000001056711111352066023547 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.util.Random; import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; /** * @author P.H. Welch */ class Philosopher implements CSProcess { // protected attributes protected final static int seconds = 1000; protected final static int maxThink = 10*seconds; protected final static int maxEat = 15*seconds; protected final int id; protected final ChannelOutputInt left, right, down, up; protected final PhilReport report; protected final Random random; // constructors public Philosopher (int id, ChannelOutputInt left, ChannelOutputInt right, ChannelOutputInt down, ChannelOutputInt up, PhilReport report) { this.id = id; this.left = left; this.right = right; this.down = down; this.up = up; this.report = report; this.random = new Random (id + 1); } // public methods public void run () { final CSTimer tim = new CSTimer (); final ProcessWriteInt signalLeft = new ProcessWriteInt (left); signalLeft.value = id; final ProcessWriteInt signalRight = new ProcessWriteInt (right); signalRight.value = id; final CSProcess signalForks = new Parallel (new CSProcess[] {signalLeft, signalRight}); /*final CSProcess signalForks = new Sequence ( new CSProcess[] { signalLeft, new CSProcess () { public void run () { tim.sleep (seconds); } }, signalRight } );*/ while (true) { report.thinking (id); tim.sleep (range (maxThink)); // thinking report.hungry (id); down.write (id); // get past the security guard report.sitting (id); signalForks.run (); // pick up my forks (in parallel) report.eating (id); tim.sleep (range (maxEat)); // eating report.leaving (id); signalForks.run (); // put down my forks (in parallel) up.write (id); // get up from the table and go past the security guard } } // protected methods protected int range (int n) { // returns random int in the range 0 .. (n - 1) [This is not needed in JDK 1.2.x] int i = random.nextInt (); if (i < 0) { if (i == Integer.MIN_VALUE) { i = 42; } else { i = -i; } } return i % n; } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/Security.java0000644000000000000000000000613011111352066023051 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Security implements CSProcess { // protected attributes protected AltingChannelInputInt down, up; protected ChannelOutputInt report; protected final int maxSitting; // constructors public Security (AltingChannelInputInt down, AltingChannelInputInt up, ChannelOutputInt report, int maxSitting) { this.down = down; this.up = up; this.report = report; this.maxSitting = maxSitting; } // public methods public void run () { final Alternative alt = new Alternative (new Guard[] {down, up}); boolean[] precondition = {true, true}; final int DOWN = 0; final int UP = 1; int nSitting = 0; while (true) { report.write (nSitting); precondition[DOWN] = (nSitting < maxSitting); switch (alt.fairSelect (precondition)) { case DOWN: down.read (); nSitting++; break; case UP: up.read (); nSitting--; break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/Clock.java0000644000000000000000000000523311111352066022300 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Clock implements CSProcess { // protected attributes protected static final int seconds = 1000; protected final int period; protected ChannelOutputInt report; // constructors public Clock (ChannelOutputInt report, int period) { this.report = report; this.period = period; } // public methods public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read (); int tick = 0; while (true) { report.write (tick); timeout += period; tim.after (timeout); tick++; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/PhilChannel.java0000644000000000000000000000640711111352066023436 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class PhilChannel extends Any2OneCallChannel implements PhilReport { public void thinking (int id) { join (); // ready to make the CALL ((PhilReport) server).thinking (id); fork (); // call finished } public void hungry (int id) { join (); // ready to make the CALL ((PhilReport) server).hungry (id); fork (); // call finished } public void sitting (int id) { join (); // ready to make the CALL ((PhilReport) server).sitting (id); fork (); // call finished } public void eating (int id) { join (); // ready to make the CALL ((PhilReport) server).eating (id); fork (); // call finished } public void leaving (int id) { join (); // ready to make the CALL ((PhilReport) server).leaving (id); fork (); // call finished } } jcsp-1.1-rc4.orig/src/jcsp-demos/philosophers/callChannel/ForkChannel.java0000644000000000000000000000520411111352066023435 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class ForkChannel extends Any2OneCallChannel implements ForkReport { public void forkUp (int id, int philId) { join (); // ready to make the CALL ((ForkReport) server).forkUp (id, philId); fork (); // call finished } public void forkDown (int id, int philId) { join (); // ready to make the CALL ((ForkReport) server).forkDown (id, philId); fork (); // call finished } } jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/0000755000000000000000000000000011410045042014722 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/BounceNetwork.java0000644000000000000000000000604411111352066020363 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.awt.*; import java.net.*; import org.jcsp.lang.*; /** * @author P.H. Welch */ public class BounceNetwork implements CSProcess { private final Bounce[] bounce; public BounceNetwork (final BounceMain.Params[] params, final URL documentBase, final Container parent) { bounce = new Bounce[params.length]; final Object[] images = new Object[params.length]; final Panel[] panel = new Panel[params.length]; for (int i = 0; i < params.length; i++) { images[i] = ImageLoader.load (params[i], documentBase); bounce[i] = new Bounce ((Image[]) images[i], params[i].background, parent, params.length); panel[i] = bounce[i].getPanel (); } parent.setLayout (new GridLayout (params.length, 1)); parent.add (panel[0]); parent.add (panel[1]); parent.add (panel[2]); } public void run () { new Parallel (bounce).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/Bounce.html0000644000000000000000000000424211113065047017034 0ustar JCSP Bounce

Bounce

The sliders control the speed of the animations to their right. Initially, they are in the bottom position which represents a speed of zero (and consumes no processor resource). Clicking on an animation panel reverses the order of the sequence of frames being dusplayed.

JCSP concurrency makes this type of control very easy ... jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/BounceController.java0000644000000000000000000001115011111352066021047 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.awt.event.*; /** * @author P.H. Welch */ public class BounceController implements CSProcess { private final AltingChannelInput direction; private final AltingChannelInputInt speed; private final ChannelOutputInt control; private final int MAX_SCALE; public BounceController (final AltingChannelInput direction, final AltingChannelInputInt speed, final ChannelOutputInt control, final int MAX_SCALE) { this.direction = direction; this.speed = speed; this.control = control; this.MAX_SCALE = MAX_SCALE; } public void run() { final Thread me = Thread.currentThread (); System.out.println ("BounceController " + " priority = " + me.getPriority ()); me.setPriority (Thread.MIN_PRIORITY); System.out.println ("BounceController " + " priority = " + me.getPriority ()); final int TICKS_PER_SECOND = 1000; final int MAX_FPS = 100; final int MIN_FPS = 1; final int SPAN_FPS = (MAX_FPS - MIN_FPS) + 1; final int MINFPS_MAXSCALE = MIN_FPS * MAX_SCALE; boolean forwards = true; int speedValue = 0; int interval = 0; long timeout = 0; final CSTimer tim = new CSTimer (); final Guard[] guard = {tim, speed, direction}; final boolean[] preCondition = {false, true, true}; final Alternative alt = new Alternative (guard); while (true) { switch (alt.fairSelect (preCondition)) { case 0: // time-out // timeout += interval; timeout = tim.read () + interval; tim.setAlarm (timeout); if (forwards) { control.write (+1); } else { control.write (-1); } break; case 1: int value = MAX_SCALE - speed.read (); if (value > 0) { int fps = ((value - 1 ) * SPAN_FPS + MINFPS_MAXSCALE) / MAX_SCALE; interval = TICKS_PER_SECOND / fps; if (speedValue <= 0) { // "<=" is work-around for slider bug in IE JVM timeout = tim.read () + interval; tim.setAlarm (timeout); preCondition[0] = true; } } else { preCondition[0] = false; } speedValue = value; break; case 2: MouseEvent event = (MouseEvent) direction.read(); if (event.getID () == MouseEvent.MOUSE_PRESSED) { forwards = ! forwards; } break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/0000755000000000000000000000000011410045042016167 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/0000755000000000000000000000000011410045042017117 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/14.gif0000644000000000000000000000405210520670125020042 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøøàøððøðèøðàøèôøÀèø¨Èød˜øT€øH€øHxø@”ø@xø@pø8pø8hðøøðøèððøððèððàðèàðèØèøøèøìèðøèððèðäèèàèèØèèÐèàØä,LàìÜààÐàØÐàÐÐà ¸à,Xà <ØèèØàÔØØÈØÐÐØÐÄØÈÐØÈÈØ(LØ <Ø 0Ø0ÐààÐØØÐÀÀÏ ¸ÈØØÈÐØÈȼÈÀ¼ÆÅÃÆÃÃÅÃÅÅÃÄÅÃÃÅÂÀÄÄÂÄÃÄÄÂÄÄÂÂÄ,XÄ,PÃÇÈÃÆÆÃÆÅÃÅÆÃÅÅÃÄÄÃÃÅÃÃÄÃÃÃÃÃÂÃüÃÀ¼ÂÆÆÂÄÆÂÄÄÂÃÃÂÂÃÂÂÂÀÈÀÀÅÅÀÅÂÀÂÂÀÀÂÀÀÀÀÀ¸À¸´À´¨À¬´¼8„¸ÃøÀøÀÀ¸¸À¸¸¸¸¸°¸´¤¸(L°¸¸°°¸°°°°¨´° ¤°`°(P¬¬ ¨ ¤¨œ”¤¬´ ¤¤  ˜ ˜  Œœ $H˜œ˜”œ¤””ˆ”ˆˆ Œ€(Hˆˆ€ˆ„tˆ|€ˆxt„ˆˆ€€x€xt€ppxt”xtpxp`txxtththhppppl`phpl\hhhphhhhh`h``h\Th(`d```X`X``XT`PT` 8Xd`XTTXPHTDHPTTPPHP@@P8È C '\¯©:wáËrM“Jk‚\ÓA½T²³©¦à´¿œÊ4Ϥ…A½ci· HÐ#…À şîlv¼|à‰™âLV’AAÌ1NJ/ç­÷Þ{ŸÿŠ#w¤Ê6)J†Ä2¾ôJ|‹m¶ã¦îYgAÎ`cÈf…LÓ A?ÈÒx¼RùÀH5×"¯T£è@yXòùÒ/k€ ²P1ШÍTÎv`‘è†ð@ðQ»Þ´;^Á­¼%ÐÓtçL(]q\5Šñ Ç'ü²¬RÅ@rhã 2ÐÔØÏõ¥É@¾hà}ÞóÓª%yo~w¼ŒWѧQ™@t1?©=Ži »Õ a2¨ÓèY¾¢=Dcs¡‹%"„\L­oôaÄÜPºq-CztéX:1—èÑEXDPèì7µ&° È+ áÂc¤,zàŽcÿ¨°aaýôf€Ђ R`Ä5j… À% ¬ˆM5„1; q†I¬ßãð]¤I‰yÂ)0a P  ÛØ’¨·ôm0#úŠ0Bê¨ÀµîåQw*’/–µ,@†  †„$ÑÔ‘~!è…“¸ ¦bm@Å1p±‰NÔ"¹ØÃüL Gý òcD@ b "a¡‚Stq ô­ ¬øÒ0Úp+ ŒA°XÃAt™ T” …‚œŠM JÂ@ÄB¦@ Y”€§2,¶æ$+ C§È…Â…QÐÂÌJÄíDˆM@âj….øˆXX1TaD.N!2°;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/13.gif0000644000000000000000000000426210520670125020044 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøøàøðèøðàøHxøHpø@pø8pø8hø8`ø0`ø0Xø(\ôhœðøøðøððøèððøðððððèððàðèàðèØðàØðØìðÐèð(Lì,\èðèèðàèðØèèèèèàèèØèàÐèØÐèÐÐààÐàØÐàØÈà(Là$@ÜÐÄܤØàØØØÐØØÈØ$LØ 8Ø 0ÔȼѤÐààÐÐÄÐÀ¸Ð 0Ð0ÈиÈÃÃÈÀ¸È¸¸È°¸È0\ÇÆÄÇÅÄÆÇÄÆÆÃÆÅÄÆÅÃÆÄÄÆÃÅÆÃ¼ÅÅÃÅÄÅÅÄÃÅÃÃÄÅÆÄÅÅÄÅÄÄÄÅÄÄÄÄÄÃÄÄÁÄÃÄÄÂÃÄÀÂļ¬ÃÆÆÃÅÆÃÅÅÃÄÄÃÃÅÃÃÄÃÃÃÃÂÂÃÀ¸Ã°¸ÂÇÈÂÆÆÂÄÆÂÄÁÂÂÄÂÂÂÂÂÀÀÅÅÀÅÂÀÂÅÀÂÂÀÀÂÀÀÀÀÀ¸À°¬À4\¸ÃøÀøÀÀ¸À¸¸¸¸¸¸°¸´¤°ÃưÃðÀðÀÀ°¸À°¸¬°´¸°°°°°¨¨ÀĨÀÀ¨¸À¨¸¸¨°¸¨°°¨°¨¤¤¬¤¤”¤  ¤˜” ¸¸ °¸ ˜¨ ˜ˆ ”œ$@˜ ¬˜œ ˜”””˜””ˆ”ˆˆ„|€ˆˆˆ€ˆˆ€x„„€„x€€€x€xx€pxxxlt|€pxxpl`phxphlpX\l`lhpphhhhh`h``h`X`d\``l`X``XX`XL`PL\HLXXPXPPXPHXwíˆð‹f:7NÚ4¹rÝÀ<·X ðät5ÿGg;ÅKÉgc†,œ9—æÚßp¢Dl€ ƒR8»ã°ÓÈ|™¢Î8ÜáB¸ðÀ+ ã[:øËQÂpà‚ 4 ƒ„é0faC·Ê8+4p ÀŒ PòW2'2Ç1#ıM ¤Œ46Ø99.¤Ë%Ä1M $pÀ3ΨÛвN’ M! ÀàM ,à +¤É@ˆáÔÀË\Ê(@B/È(°Ãž;Ì@ƒxްprŠäšŸÜ⊥!Ë5>pÁŽ D;¬°ç :t@É0dâ AiŒÍ8ÛˆM&|¥ÿ1Ë7רbJ+Ç„,ä3Á\`.Û1Çtê%æèa@ÞP!PÒø –ТÍ8ÊÄA–Z}R%ÄäʼnÁbA¸pC +ÌÁ 2Ô¬’Â%l£Ú%»0Q¦°úŠ·N¥Í5hä—9/ `€¥øÑI/܀à 5Æ”RC ðŒ7Él’P$ã| Mu±Ì5R „Š:¹ løúàH$“Lâˆ?d`é®°ÓŠBW|ƒÖ5Ú-uË8m$äI; €îÌÁj`B@ð|‚—^`#íšPżN4](µ :&"´Ä5 Ë,³¨«d@@\ÿŠB;“(”†2hm3ŽØGibœ( U ÝSO ,`ùäpAßàÑx6h¡5 Rœ¸6ޏ 1‹ÔR£+¹ÜP€—ŽŒ| ¹bN6Þä…´Q˜”†–2g$´¤ëÀ"/s°Op) ® nPæ¤#J/ç€s¿E:\–TL¸^>ò¯/ï<’¤’)oÝPLi¿……é¬z£¿ÓkS‚ùçCë¦fÍe ªAÈ"С+càEFY„`ÒQ gÀ%aD4,€>–v}늄´, ‰ñîˆÒˆtlãëè\‰ƒ ‚h]?øAÖÉLs 1ÿ–°O¸G±8Ę…Ì‚ #—<™Y`!0À.ä°V¤ãIyÅ9Ð"—„CR ×H9Ú  XÈLQ£l!à UÒ¢¬qŠÉ£"°úvx"|„AD5Æ‘> d ÖøÀغ*ÂÎRD1@#o\£<qC4"g> p—ÂÁ3V³‘!»PÞë$—>™e.Þ¨#A‹*žRyk–, mèr>˜H… a·L`âKBÈQ2k)Ì @v2Kß&P‚iHëDˆìdw©  8ÀA˜—Ma Þˆæ‰!ŒÉ  r (LQ—Œk`Âè&·Lß8¦y– kB ’(†6’!ŠAÄAŸÈ6Fä1×àR3j༠ä!Ýh… ²"8â¶(̬™ŠZpÉ©° Hñ a,¤ ÄàEf†ep1IhÐ?¥Á8†Áº(AßqŒ8ÁAÙØÅr›_Ä ÏU'’`ì] ;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/6.gif0000644000000000000000000000375310520670125017772 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøððøðèøÀØø8hø0`ø0Xô(HððèððàðèèðèÜðààðàØð˜Äð(XèèØààààÜÐàØØà0|Ù˜ÂØàÐØØÐØØÄØ(PØ 8Ø 0Ô”˜ÐØÐÐÔÄÐÈÈÐ 0ÈмÈȼÈȰÈÃÅÇÃÄÇÃÃÆÄÂÆÃÅÆÃÃÆÂÆÆÂÃÅÆÃÅÅÃÅÃÅÅÃÄÅÃÃÄÄÃÄÃÄÄÂÂÃÆÆÃÅÈÃÅÆÃÅÅÃÅÃÃÄÅÃÄÄÃÄÃÃÃÅÃÃÄÃÃÃÃÂÂÃÀÀÂÄÆÂÄÄÂÂÃÂÂÂÀÅÅÀÅÂÀÂÅÀÂÂÀÀÂÀÀÀÀ¼¬À(H¸ÅŸÃĸÀøÀÀ¸¼°¸¸À¸¸¸¸°°´¨¨´$@°ÀðÀÀ°¸¸°´¨°°¸°°°°¨´¬ÃŨÀèÀÀ¨°´¨¬œ¨¨´¨¨¨¨ œ¨˜œ ÀÀ ¸À ¸¸ ¨   œ ˜œ (@œ¤°˜˜ ˜˜˜˜˜Œœ˜”ˆ˜ˆ˜ˆ„Œ 4ˆ„€ˆ€˜ˆT|„€ˆ€ˆ€€ˆx€€€€€x€x€xx€pt€@Px€ˆx€lxxtxptxphx4pthplpphhlxlxxhphhhphh`h`ph`hhXXdlXd`X`h``Xh`XX`TL\,XXPXPXXPPXPHXDLPPLPHPPHHP@LLL@L@H 4Æ5£GpÌ#²4¦³y¸¢Æ-]3"DÆËê6…Œ@3…”võ,3w“4s±ÒÐ\’Ðÿ (Äz<G-¯`‘0ޤòÅsuTñË’P"«+š/“Œ0i@ðå]&¦…ȇÃeòò¿'CHB—\ü/ÙÇ4!]L`—¨ä•¡÷pX)3¤”;‰Må_GCôÉÈÃÌ2´[„pØpµ¼ ñ18ä{ýA¬¤‹÷Ý¥¼±Új.sL&&Â(B ÷JÄÌHÑÄÈ ’Ð-d»ŒA0È v ?ôtÏLÓI ÐÀ‹/Öò 1Þ`’ãCˆt36¥ ,0ä‹”#È'Á,éÐiÉ8ÓH A”y‘12³AÈàè¥BÄIJÈ-60°€\ Ä•60C dò¦BvüÒC¨@RÃB4Ú‚ 4R ÐÑå a"J„b‹Œ6Ú(¥¬2À0c¦½ÒGÿa %wÖŠe3q0A­0“«]ò‹ œzI3´ Á($Ì|bÁ °ˆ7³+ÞœRl´!ˆRL)”¸BI-Ã|BÃH`ÁÌLsɬŠñ‹7ŽK@°€‰0²# *’œ+L@/ÛhBŠX^¦aI/³!0)¼Qˆ{ ‘BpÀÑŽÒ wÈRUŽi ÂŠ'ÖܒœzÀT +„@Í!KpÀ’0sí/z˜è„,»¸¡4²Øû€Í6ß<4Í@`@´q3P$»¸¹^,Çð Ð.›^M1Ö§¶ÝöÈïÐ A©¨µž#Þ 2Ð*Œÿàöß5rÈ$Ì3u ¤Š5^’ͪgûPì“ÿ=ôÚ!C0´¢‰@‰x£Þ}id£Ê@Âû÷ä—Wì:´À+nÑM1hT¨ŠqnD²ÊÔnWòk·.AŒÆH“ãÔ £'—ø}êä•ÿ:ñ[OàA ÔüÒÍè&ZB­/|dÿ·ÛÇ\°H@L7Ì´±$ÌÐ/ñúìkùÛœNQfÌaIN†7Œ‘ƒ¶YÓ^Á öKH“XÒž ^œÀ^<$µ‘Œð€#Ü‹q¡=Ôx&&BÂí<€æ(‚DÜÆ9zE5ÿº³Š ¨ïoÍÐå½<4拨Ìj°B•ž4@@‡Þ³C|žq‹ 9AÞèF¶ø74NË ´ U¼!×ð†)LT‡X¼b§ ÜÛà·$âÔ+Ä ZŒ`ØÃ2|ñŠ'¸ð ЏEìÅÈ0"¼ø/fA‹_Àâ ÞÀ öGÄ" b3QŒ1ƒ€‘{à2^‰;Á mЃ&ˆq‹LLÞóÀ%.).üâ œò(¢>„œÃø®&ð‚¬úD+&`‡[ ñ,HLq ‰ýìÌHgŽÔ` ` # c)xa(pà|ÖB K>ÄÃØ,t‘;kQ¤«¨SZyRtP;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/12.gif0000644000000000000000000000414010520670125020036 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøøàøðèøðàøèèø„¬ødœøX€øH€øHxø@xø@pø8pø8hø0hø0`ôèôðøèðøàððèððàðèàðèØðààèðøèèàèèØèàØèàÐèØðèØàèØÔè(Pä$@àèààèØààÐà 4ØØØØØÈØÐàØ(TØ(@Ø 8Ø 0ÔÐÈÔÈÐÐØÐÐÐÀÐÀ¸Ð@ˆÐ 0ÈÐÀÈÀ¸È¼°È¸¸ÇÇÄÇÄÅÆÀ¸ÅÅÄÅÄÈÅÄÇÅÄÅÅÄÄÅÄÂÅÂÄÅÁÀÄÅÈÄÅÇÄÅÅÄÅÄÄÄÆÄÄÅÄÄÄÃÃÂÃÂÃÃÂÂÃÀÃÃÀÀÂÇÉÂÅÅÂÄÂÂÃÃÂÃÂÂÂÅÂÂÃÂÂÂÀÈÈÀÄÅÀÀÀÀÀ°À¸°À°°¼ÄüÀü¸¸¸ÆÉ¸ÀÀ¸¸¨¸¨¬¸ ¨°ÄǰÀİÀÀ°¸À°¸¸°°¸°°¬°° °$L¨ÀĨÀÀ¨¸À¨´¸¨¨ ¨¨˜¤¬¬¤ ¨¤˜¤ ¸À ¨   ˜ œ (L˜œ¤˜Œˆ˜ 8”˜ˆŒˆˆ$Lˆ€ˆˆˆˆˆˆ€|€ˆ€€„€€ˆ€€€€€t€xpx€˜x|pxthxppttxpthphhp0lpplhpld\hdh``h````X\`XPX`XXP\XPPPTPPPHPHHPH@P@HLP\HHHHH@H@HH@@H@8H88@@@@@8@8D@88@80@,4@,8‚ áIrM! &Œ€Â¥—¾@µPB€XÐÑS'p[ì–ÂàÐ –fÿjƒ -Ò @”ñ +‘ô'Õ€r«@ÒL #´àl pØR‹"°:¢3Úœ Ú+Ñ i®0@rL-˜ØbH-ÍÐ X‹h®Ë…'}€VÇ1ÄÄ`mèÐ$¯¼² *䡃¬0¨x¨@™|RYB‚Tâ­S|d’I,`-äpÆ_äñE9ˆ/«Ç^P × „1”TÖAT¨ÒÌ1x=e +dɸÖ A (¯,‚P@W`ŸÄF0˘òË* À‹2?×FSL€BÌ\ì‚«È"K=@| BÄõ±‡Þÿ Ì-ñ ÙϽL3d“ERL Q† Àø2LSÂq[Ë*Qs¾ù¡T óÂØ['»­ex3‘•…$»(sŒ2̨Â6{´¢9ÒÿÊÝpÃ\{ì,uT…)vÎÌ-g•Å(»~ÙÍÜB$Gk®ýöšSó¡‚PjéÂ!PEìyÏ0sø3ψAÐ(fdž¹öy€ôÞÇ&’IB¢xÆ/.V&Ì~AZ 44A&ôB"—çXÅ»íQ`j0€H‘<Ì)£Hà2Ú÷¾; ¿8þ"…´q±…Ú+qP$„P¡ÕÀOQáŒd4ƒŸ¨üÿXQ,ЂÖz¡þ–ÈD r®8p…Bta F å  ÃªÐŠh(ã7©Ã(âC š†dU E…dAW`Êr# ƒðáÌSþΨÇ2òŽ8hEVñ g„ÁŽ›ˆZÓHÁû‰ÌèÂ)²Ò†h¤â uÀ£™HìêZšËpA ”ƒYYÃÆR„S¼ iˆº:Ð ê‚Ü‹—%þ—$äB¼C” ø0‰Rœb¥xD:€(3>l¥Ð!h¢©€jŠÈÅ.8ñ>ðá²(Ê ÂßàÁÑlð‹ ê.A@.4Á^¸D0&aE‚cYm‡˜vXáŠ> "ºHÄ* "‡S¼¢ ±œA,PÃ&°¢º@D=b…DcoxÃ*.‘Ÿ6„ Ÿ †/•€;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/15.gif0000644000000000000000000000370210520670125020044 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøðèøðàøØìø Üø@pø8pø8hø0hø0Pø,\ðøèðøàððèððàðèððèàðèØðàèèðàèèàèèØèàØèàÐè(HàøøàðèàèÜààØààÐàØÔà0`à(Hà HØàÐØØàØØÐØØÈØÐÈØÐÀØL„Ø 8Ô0XÐØàÐØØÐØÐÐÐÐÐÐÀÐÌÈÐÄÀÐ 4Ð(Ì DÈÐØÈÐÀÈÈÈÈÈ¼ÈÆÅȸ¼È(PÈ4ÇÇÀÇÅÇÇÅÆÇÂÀÆÆÅÆÅÆÆÅÅÆÄÃÅÈËÅÈÈÅÇÉÅÇÈÅÇÇÅÇÆÅÇÅÅÆÇÅÆÆÅÅÇÅÅÆÅÅÅÃÈËÃÈÈÃÆÈÃÆÆÃÆÃÃÃÆÃÃÄÃÃÃÃÀÃÀÊÍÀÊÊÀÈÈÀÈÀÀÈ´ÀÇÊÀÇÇÀÃÇÀÃÃÀÃÀÀÀÀÀÀ´À¸¼À°¼À°°À¨¸¸ÈȸÄĸÀ¼¸¸À¸¸¸¸¸°¸¬¸¸¬¨°¼¸°°¼°°°°¬ °  °,P¨¬ ¤´¸¤ ” ¨     ˜  ˜ ˜˜”˜”˜(L”„€”Œˆˆ˜”ˆˆˆˆ€€ˆ$L€xx€xp€ 8|ˆŒxxxxxpxphxhhx``x 8x4plpphˆllhld`hX`dTP`hh``X`XX`PX`@PXXXXPXXPPXLHPPHPHHP@HP(4LPPHHHH@HH@@@HH@@H@@@@8D@84@048088008(08$$0,40((0 00(((( (( (((    ,‚PÿÏH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Ñ£H“îdbF©Í?±œÖ-’Ô™•œós5&+eÅt1éúò—²dÇX‘mɤÙ1dÅ”eZ»òʳdÊŒ+††nJ:ÏÎÂ-ÖÊ/JGÍð‚ūȰÉVÊ΂«Œ‡ã‘[lIÆ W™ÚË!§˜Eö6r²bÉö€yµ2d¦“Á¥EdµÇC‘ó*>&[YcÛ=-ƒMš3oe½¶ßˆª™dØ®Q;s´<#”[¦÷&;}ºÜ)Õ/VÿQVº˜±Èå!ÛÞ"ŸhqÏcÔ‚#UÁöþRÞ~¢#gq SÉ  °Â 0r j’ô7‘+yóGH` <‚ 1À@á DI0™(`bèÃ/`€2ɇÝ¥Ì PX  à¸@0İŒ 2\1䑊8b¸/ @ !@2´Ék¼$  l0Â$°"Ô1K” årË"À(°B6Ôছ\bÊ`0Ëd"Ä/0|Ð #l²`à?Œ Ç1}L 4’çAw˜"”Ó#°À ¢ ')0Àx,ÃÞ£¢‰ @Ë1–èÿq#… # )kP0ìK1X *¿ â¨Ê.Àì2 0´¢Fˆ:¬c x¨:Í“F€Á y"H lÐÁF ÁD°I1¤€Â™q³L @„ÐÃÓAµøÁ„ȦäÉ„-ÅB PL0A»ýŠ:@¼¡Œ@¦`å¦$bŒ.ô+ó¿ÿ&Ü/Æ8@ żp† ¿Ä¤$œœÑÊ, ³ÒL ÀÓLP@ s‡@ Œ£¿àpƬ@ð4ÔKõ® ã"ˆ@¿hc%¾èðõ*Èl7Ófßì@tÿâ("ËÌ#ÎhÝF)J]¶ÝKï&Zÿ˽¢âŒul’øâ6Ÿ=2ɉÄI1PIF1·@"‰(ÎxâgS}2½Ø’ç(Ê CÙ®o¾ô{_ Ã]¡ä©Z}ôî;ÙMë\Â1ʤ’§'ÉCÇâ¿+5|€Ý0cE‰û/iØ|wÔfG-î,p $¿óK7— ;ó8cà X†¹…&zÉE êW?¼Ù/aâB„2€Q4 b1©p€ç0FÁÎÝl Ã1ˆQ ñA/È Äö.’¡`; À(دX º€ €„‰ZýªÚ4ЇRØâ¿˜Å&§P€·Ïå€b­ œƒžp‹;0mo¤š…-1 œa¶˜… :7²¼bO St†Œ‰k½˜„yŠY `f(+”#[¼ás2(E-ìPœ ÛÛæø¨U4bdr˜…½BŠOD2øLž¡ D|B‡hÈP1‰½Y`§z&vŠ:$ ²ø„ v0 ÷ K"R@….n‘ÉWVá³¥°;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/10.gif0000644000000000000000000000404310520670125020036 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøðèøðàø„¸øHœø8`ø0`ø0Xôøàðøèðððððèððàðèàð(PèðøèððèðàèèðèèèèèàèèØèàØèØÜè(Pè(HàððàèðàèèààØàÜÐà¤Àà(LØèôØèèØàèØàÐØØÐØØÈØÐÌØ(LØ @ÔÈÌÐÐÄÐ(LÐ 0Ð(ËÃÆÈÈÈÈļÅÅÄÅÄÃÅÂÃÄÇÈÄÇÇÄÇÆÄÆÈÄÆÆÄÅÈÄÅÆÄÅÅÄÄÅÄÄÄÄÄÃÄÃÄÄÃÃÃÈÉÃÈÈÃÈÆÃÆÈÃÆÆÃÆÅÃÅÆÃÅÅÃÅÃÃÄÅÃÄÄÃÄÃÃÃÅÃÃÃÃÁ¼ÂÈÆÂÆÈÂÆÆÂÄÆÂÄÄÂÄÂÂÃÃÂÂÄÂÂÃÂÂÂÀÅÇÀÂÄÀÀÐÀÀÀÀ´ÀÀ°¨¼Ä´¼ D¸ÀĸÀÀ¸¸¸¸´Ã¸°¨¸ ¨°¸°°°°°°¨°° °¨¨°¨ ° œ¨¬¨¨¨ ¨  ¨˜¤œ˜ ¨¨ ” ,Dœœ œŒˆ˜œ˜˜”˜˜”€ˆˆ€€ˆˆˆˆˆˆ€ˆˆxˆ€ˆˆ€€ˆ€xˆpx€ˆ€€€€€x€xx€px€hx€@xtxxppxphxhlptppphphhpd`lhphhhh`hh``hX`h<`hp``h`````X`X`\PXXXXXPLPPXPPPPHPPHHP(8HHHH@HH@@H@8D$@@8@8@@88@08@((<@@8888088008(000000(0(00((0 $((0(((( (( ($((   $     ,‚PÿÃH° Áƒ»ô¡4éN„#JœH±¢Å‹ûc¦¬³\CŠI²dAJÌž1c¶Œ#“0cÊ,3gÑRMZÅg¦ÏŸ@ J¦2Z¤ H“ú<Y´\€ MQJµêÅFN‰®dÖˆկ` J)¦uk±baÓ‚ÅíÙÙW…mÚ£¶.ULÑ`I±Ë×j´B}+e´‹‹àÃ@kFÌ8¦f†K& ÈÕH(R¤<œ|8]‹PèŒòåQ0Dœ³ºQÑÍ)cÏœA‹ÖìÙ«Ô»¸z"±Ë ]ZÛ:{ÍÜ}¥œ’XQœ)‡ÏFœ/“Péìj»²i4¢Ñ¢ ÿ R¯Kk˜Úº²víð)?•ç‹å‘A:Åà³î”ø±6óÙ…uM’3Ð C {ÌÔ&/Ú%Å ©R2zˆF$Æ4Õßl›DX×Ôu1K-tüáLh€,ÜÒLƒ±U³—ˆiuÑHŽìR ôqŒ `$ÈÒVx¿àX%ÀDC @ (  å–^5Ø9™'Ñô2C€‰,[¶‰€$Ô0# b†õÄ0ÑÀ±€ ›njùÂ1Í E`IaÍ#Ðçj 3– l€€IJ¹¢UR 8@€£ì"KÀ ªª#ÈòL)œZÿÕE1lð 0ðÀvS0Ä0‚ª+Èâ …±RuÊ(8º¢>‚%ÊH2B Án Ns$«TÉ\0Àº’;î4@¢L+e¬0BÈ°Ò Þ&ÅI"ã@€¾üÁv°RÌ1É0³ ÌlZ¯OAøB¾3 *ÿ®Q!‹ð1Æ Ç@±0PŠd"@¾ àºïÏ:ð€ c´Ü4D#ÈÇ?õ‚ÆÈŒ<Àã.0n8 ­¨M-µüRL-žÐA3InÔ’fš#30À£XÛ:nŸr¼:{ÐÂÌ% ?M‘+€èœó¸ûžœï¾9ãj3ŸÔÆ/ÀLe6E5ÿ“ÎSC<®£Î/Á@¤J4î- ªèœ/à’ëkuÛ ²D¯}áxD¦Ü1à“÷à†À.±|Ž»P9zà‚?¸†ˆ"Q˰BžëáʕϞ/šVì€è..Oý|yXbø£†[~5áS/ßüD½Ló 0YL†%Œì6Äh­6Û `È(¥R ‚°˜Ê’«¯¯Hú8“ @œ˜È)¦q 9™¯s¨ÚÛˆX0c}\Õ %G$P"½àN421½^am ¸Ú\À fœž`†r·’ À˜ÈlR]LOsÀÕÿlÈeÀâ Á3Ð@»åU⃠B4’‘f czÀàŸ ðeh …PÆÃÒD€œ E5VÁŠïcz°HŸ®À†c¨ ¥@ñÖF\4"ǨÆlžü¬xf "¶Õ€‚[”­ 7€F1ð°$BLÏ Ïp QŒ?H Á ÁÔÜ@‹‰Ð¢hK55½B#º ÓD(Q‹äŒ¨+ž!K˜O @HÃELŒ@‚@ H†Á J“$‘èÅ+÷ÉÏ~úóŸi ;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/4.gif0000644000000000000000000000371610520670125017767 0ustar GIF87a‚P÷¸°¸@ˆ|ÈÈÈ`X`ˆˆ€hh`xxx  ¨P@@x„„èøðà(XPH@xhd¸¨¨¬ @plxxpxp @ ˜ÀÈÐØÈÀ8@@ÀÐР¨¨à @°¨¸ˆ€€HHH€xxÈÀ¼ppphhhààШ ˜(((¸¸À°ÈЈˆxèT€ ¸ÐØ¸ØØH<8ØÐЈˆˆ`\X°ÐÐL\X``` ¸ÀÀ¸ÀÈȼ€„xøðà((0ÐÈȰ¬°PPPˆ€t¨  ˆˆ  ààØh``°¬¨œ¨ÀÈ808ÀÀÈ@(¸¸¸ø”ÔhDXÀÀ¸èèØø8xXTXè(Pèèà”„° ¨p<˜”˜ø0h@880((H@HÀÀ°¨¨œØèàÜÐÄH@@hphÐÐЄ˜¸ÀÀ ÀÈ|pp0088$ÀÈÈ@08àèèØàÐèààX0@¸À´ø0X €˜ÀÀÀTHPØ0ÐÀÀ€x„¸ÐÐØèèàðè¬l|¨ÀÀààèè8`hh|HHP80(px€¨À´Œˆ˜HPHˆ€ˆ°´¸800ì Dœ¤œ`hd¨ ¨8@HØ 0¸ÀÈ0(0ÈÔЈt|¤¸¸ØØà@@8h\X@<@ØØØÐÐØtxpØØðÀÐÈ0$ø0|èððàÈà°ÄÈÐØØÈÄÐ( XTP ÀÀÀ¸¸ÀÌÀØààððàèàèðàèP,¤”œ`TLÈÀÈ888( ,ˆ˜ˆðèäøððà0øèøÄ´°tl„( ¨ÈÈø0`àØØ¸$h( ¸ÈÀØØÐððèàààXLHààôðìØèè蜘ÐàÐ000¸ÈÈ ¼´¨ttdX@@øÐìèðè°ÀÀœ”ˆÈÔÈðððÜìôl`x ðàà(0,èðàP@8´  ø(tØàðððøèàÔ¸Ôìðøìøðè@40èØì€„„Ð̼èðø°¸à T\tìàôøøè XÐØìøT€øøððøøøðøøøø,‚PÿçH° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ¦"Ô§ oEyÒX!$éÎðè8Í™^Ó©%“Eñ.š‰-ÞšÕ#Œ½e£6[6oCà™*Ëñ]=ˆXâ­píZoB¼5£›1ÑŠ»g¼ƒÍã@ºõdvªË`qÉ—Lÿ /àÃòàƒ#ÃÖ¡…@õHñ>:`À /ãLŽà„»ÍkX€¸@RB #óƒO0]€Ì2‚cž¹ÕîPùùͼ3Ë­ãž;Ð÷Î2 ZÍ.È®›>xñ¾Í´x1»/4(<îÒÿã»õX2û">¼n¼àWÞûÕø$âùç„ï½æÖ[}="ÚÞýÕêãÓ>ïã·yŸÓÁ¾æ™£Ÿõh½às\Pžúè>·cXÇçÂÐÀä)P|î ?Zá%ÄÝMz ¡ó7‰óÇÐ  ‡òNs˜â’q z´ ÇrЊþÃ2Üš8³,v½Ìშ‚@Šw´o`ÀâÂ`Œ'¾ §XA€`iè¯c[3Ĩ<|´"Z,ÈLq‰.C ÁÛ šaEê ~ñ)L‘„Ù udY ô”ÍÎ ²¸ŸéðÑ_`av‰„æZH0’IÄÈwŒ¤“ 9À$p—Žœ”Ù€ZaFl•1…H° z–€7¶°…[âò!08Ã/§;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/2.gif0000644000000000000000000000356110520670125017763 0ustar GIF87a‚P÷PHH¸ D œp`t¸À°( XPP0 ¸¨¨@@HH@PˆŒ|8H@H¨¨¬ø@|˜  ì(PhptÀÀ¸ÈȰˆ€€èèðXXXèèøààÔ””„À¸¼HD@ÈÐИ˜øèðˆ€ˆØÐÔÐÐØØÈÐèØÔ€p0øàà€„ÄÀÈÈÀ¼@00¸°°@8@hdh  èààxpt¨¸ÀØàØø\œ$H8@¨ÀÈ004ØØà¤@¸¸¸€€„PPP@88h`XÈ̼8 $ÐÈȘˆˆÀ¬¬øðàHHH8œˆðØèðàè€x„ÜÐÈÀÀÀ˜”˜ppt°ÈÐððàððèð(\èàØÌÈиÀÈÀȰèØà¬¨ Ø0èðè¨ÀÀ€pxèèà$44èÐаÐÐHTPÜØÌh`` ¨œ è(H¨¸ÈàÈÐ0(4pdht|„Ø8è T°°¼øH|hh\ÀÌÐ800 ¸¸ø0`@@@°¨¬ø0hP@H°ÀÈØ 8¸¸° ¸Àø8p@08ÐÀ¼ ÄÌȘ€„øàèø0Xˆ(PŒ`\p °¼ðØØ°`„8@@ø(d8080( THPààèàèèÜ(T@@8`h\ ¨¨8(4èèèØØØP(4ØÈØh€pàààüSc‹8ä6ëï Ú €DhŸÇ\qLt­ q¿Îòƒ¬h3ˆEŒ@,-‚LHD,1­åâSD5äÒ* ׂ̭@Îý6ËoÉ$ó3A,•Æ€LeÑ5c3É#Gœt¹œ±À@-95gÍo¹Z7[Fq™n?üqõÍ=ã¬õ Ûd†°]ÿ‰ÝH.8­`ä]a>°PÍi£½µÖøiÛhaÅ<>òÙŒ;û#BuyÀ0>7֦肠_c¸[a búÙMsÞ¯.1´>¤`v4’zà='54¯tMäîÖ5šoÝ´ãåöËÄ6eOjÞø€¿O·ÝT\sÐêxƒÊ5àeDçÑ34êø rP4×4`ÇXnypAãÑ#l2ꦣžAhóIàï,%ØŸÖøÄàx‚66¸IÂx«€€oäwaø€òápãvð–:M0Bìà–L4 dõ*LDrh‚QH]úVuÜ'+n‰ÏŠà`h/!xØãŠÀAƒ<ál@` ‚p`<`H ì |4‹FHH°Üòd¬€‡ ù!Âñ‡·­"fЄ$4Aµ;ú±);jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/9.gif0000644000000000000000000000400510520670125017764 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøøàøðèøðàøHpø8`ø0`ø0Xø(`ðøèðøàððèððàððØðèàðèØìØÔì(PèðàèèàèèØè(lè Dä 8ààØààÐàØààØÐà(Pà Dà 0ØàØØàÐØØàØØÐØØÈØÐÈØœ°Ø 0ÐØØÐØÐÐÐÈÐÐÀÐ0ÌÈÀÉÅÄÈÀÈÇÇÄÆÆÄÆÅÄÆÄÆÆÄÄÅÅÄÅÄÅÅÂÅÄÈÈÄÈÇÄÇÇÄÇÆÄÆÇÄÆÆÄÆÄÄÅÅÄÅÄÄÄÇÄÄÆÄÄÅÄÄÄÄĸÄÃÀÄ(PÃÃÂÃÂÃÃÀÃÂÇÈÂÃÃÂÂøÁÅÄÀÃÆÀÃÃÀÀÃÀÀÀ¸ÀÀ¸¸À¸¸¸¸´¬¸°¸¸° °¼¸°°¸°°°°¬¨¬¬ ¬¤˜¬ @¨°¸¨¨°¨¨¨¨ ¨¨  ¨˜˜ ¤   ˜ Œ ˆŒœœ˜¨¨˜ ˜˜˜ ˜˜˜˜ˆŒ°°ˆˆˆˆ€ŒŒ˜Œ€tˆ  ˆˆˆŒˆˆ€ˆ€€ˆpx„€Œ€€|€x|€px€8\€0x€€xx€xxxxxpxppxhhx``x,tthpppphhph`hhhh``h`Xh(````\P`X``XX`PP`HHXXXXPXXPPPHHPD@P8A ¦ÅIS ndƒ-’X € €0¾ˆ!^ð€Ë å %f„ƒ,s¸£DÂXÀl`‚&Ê4sÕ/wôx‘$…¼¸¢‹2b#€LžìòH,Êô„Ì'RR$D+`‰e–[ù@…¼B â RÈœBbš©q‰•ªá–/🠽È@$K3ÍäÈ €>$pÂgœlÀ‚B(,ÀÑUi1•}Œ*†La„jFxá[áõrÄ•‹è@`œòK,É(£ ÚªÄñè ÉÐ˵žüÀb’J3>Êç´+ô…/A:á' ` ðÌ^ü°’ ;@‹2€$„óÉÓ7$/-ÄI Ѐ\À‚&Ïô¾C_´òö×`À„D¨†( ØS|AHØÛß pˆ‚2ÑŒ|ŠF`Þ)L…Ðá#TÈ0Fð)H-E& Ò†³Ä!%4Ÿÿê´`‹I„ uø!BJ+µ¨@\ð…!†*Ñ y`Ä–à€(šæ iHÄ b]„Fƒ/¾HÅFŒÑ q'øpMÊÁƒ$ÞxMÌb„¨ÁBþàF>V¤{4$E>!FENä}p¤D‚ ‹7H2"eh'. ‘Q4#œ|H/šaÄP2ä Ìh†pL©'ÔÂl°`¥BÎàeàB– Éð–Ñ \d^X!…/ begÃ&AÖ atáÅ0ƒ2­`© c>¡8† ”YFŸìð3¥`‚2×€ ÌL³ FØ@;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/11.gif0000644000000000000000000000373310520670125020044 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøðèøðàøØðøÐìø¨Äø`ŒøP„ø8|ø0hø0`ðøøðøèðððððèððàðèàð(PìèôèøøèðøèðàèèèèèàèèØèàØèØÔàðôàèèàäÔààèàààà 8ØìðØàèØààØàÔØØÐØÐÐØ(PØ 0ÐààÐÐÀÐ 4Ì0pȼ¸È°°ÇÄÄÆÅÄÅÅÃÅÄÅÅÄÄÅÄÃÅÃÅÅÃÃÄÇÈÄÆÄÄÅÆÄÅÅÄÄÄÄÄÃÄÄÂÄÃÄÄÃÃÄÂÄļ°ÃÅÅÃÅÄÃÄÅÃÄÄÃÄÃÃÃÅÃÃÄÃÃÃü¸Ã°¸ÂÆÂÂÄÄÂÃÃÂÂÄÂÂÃÂÂÂÂÂÀ¼°ÁÅÇÀÅÅÀÂÂÀÂÀÀÀÂÀÀÀÀ¸¸À¨¬¸ÆÃ¸ÃƸÃøÀÀ¸¸À¸¸°¸¸¨¸(P°ÃðÀðÀÀ°¸À°¸¸°¸°°°¸°°°°° °¨ ¬$H¨¬¬¨¨ ¨ ¨¨ ˜  ˜ œ ˜¬˜ ˜˜˜ ˜˜˜˜˜˜˜˜˜ˆ˜p„ˆˆˆ€|(@8ˆˆˆˆˆˆˆˆ€ˆ€€„„t„€Œ„ Εp-D  70¾…",’€À9xCÎCœš2–4Ü=<"ùŒ¸;öžKtAÚ@"FäÍnˆÀ@*r HP"ŒœƒÀ%°¼ÁwøÃÞ‚è0y@]Š@ ;H`Ž #P¡‹ZÈ"§E.vaŠ:N`ÿˆà‹/.€±AÜÀ¥ŽU&”ÁT³ÃUÇ>lÀÎtêTbBÄŒÀξÀ†Ž,¶Ø‚;Ò­2ãA=è°Â>¸àC%•ÄaB%´ÐË(Z iט2N5sÄáå—q¸Àü4¡‹•ÍðÃ? ÂB5»€G5ÃŒc >ü”c še@ðÊÿðã,DPÍ¡ÃN! ðÃÏ ¢©Î*8H+9ÔÂŽ,°ÀÎ8cÀ€Ï?ÿX2š+¨Ó?òÃÀÌôÿŠ}ôÈ<ª°úÏ;Û06c!êXA*?x2` ;`°1äè?ö`¥ÄP@*žÄÖ#rÓè³&@3òÎÃ:ª.>ìªËê»øè±Ç£âIº­ºÛ*©éšÈ!NðˆH¤ë®£ù¾û,–”1†ƒu`’Á1 üîÅêN0EG€xÝ3­`2FÅØZ¼/±¦øV†#Ì\7A 攀¿#¬+ÍŽRðÌ@¢´ò[ Û4h 5ë;¬ÁüüRAuH Z!ãh"Ð<[´Íº"ŒŒ1’ÁeÔ°ÓXín»X›í¨'€´ 1Äd`ÅX]A°Ç8Ä”Â!G¯ÿë(¶àžüÏž´E\ãŒS1uX2T]lc¹¬k0ž%# ®Í˜`ê¶.qÙ ,NqBœ;Ž„)4ç›ùæÿsË89BÜ6ÄðŽ(MõN8å€ÀÑëk³Õ œy#Ä)®‹<ÍP¥xïÄÀã³@Ää{Âfã«k¸$ƒ[ùd ú6#Õ ïŠÇµô@ÄÈÂïýµãÿ³«ìyÐîh˜ÐŒS$)XÜ6V‚q€céE?w6À}ïhXB®  8å 6`ÊpzT ÍÀŸ£~ÑBð⬀En¶¿`ƒ ѹ¢Òƒ=| èEß{°Ä ]¨À*VzÔUoÀ!hÁƒô­JÀ"¶ñ_ d«èCöÇ*lÁAĈ±°P‡UDê XÅÈHÿ¹áhB ÆÁ5…Œ€á¸Y Ê× ­­kÑ&¸!!˜Ñ¶‘,q‘äL;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/8.gif0000644000000000000000000000370110520670125017765 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøøàøðèøðàøÜðølœøDpø0hø0`ø0XðøøðøèððøððèððàððØðèôðèàðèØì(PèøðèðøèððèðàèèèèèàèèØèèÐèàÔàððàèðàèèààèààØàØØà¤¬à DØððØàèØàØØàÐØØÈØØÀØÐÈØ(PØ 0ÐèàÐààÐØàÐÐÐÐÐÄÐÈÀÐ @Ð 0Ì(PÈÈÈÈ <ÇÄÃÇÀÂÆÃÅÆÂÄÆÂÂÅÅÃÅÃÅÅÃÃÅÀÂÅÀÀÄÄÃÄÄÁÄÃÄÄÃÃÄÂÂÄÀ¸ÃÈÆÃÇÈÃÇÇÃÇÆÃÆÆÃÆÅÃÅÆÃÅÅÃÅÃÃÄÄÃÃÅÃÃÄÃÃÃÃÃÂÃÂÂøÀÂÆÈÂÆÆÂÄÄÂÄÂÂÃÃÂÃÂÂÂÄÂÂÃÂÂÂÂÁÀÁÀ¸ÀÅÇÀÂÅÀÂÂÀÀÀÀ¸ÀÀ´¬¸ÃŸÃøÀøÀÀ¸¼°¸¸À¸¸¤¸´¸¸°¬°ÀȰÀðÀÀ°¼¸°¸À°°¬°¬ °¨¬°¨˜¨¸À¨¸¸¨°¸¨¬¨¨ ¬¨ ”¨ D ¤¬    œ˜ ˜Œ˜œ¨˜˜˜Œ„˜ @”œ˜”˜”ˆˆ„Œ$DŒ 8ˆ˜˜ˆˆˆˆˆˆˆˆˆˆ€ˆ€˜ˆ€x€|€|xxxx€xp€xlhxT`ptpppxph`hhphh`hdXh``ddh``X`\``XT`PP\HP\0XPXTPHTD@PPPPHTPHHHHTHH@H@@H@8H8¤¶< @6±œ[ ’Èš ËÔ—ÿàåZ;D3„PCÖ‡°jå"Èrtðˆ™u Ê0žPˆidcVÏ»Fœ¢áŒT˜N;B¨…5<Ñ °!Ó€%`áÀYÙíyGºF2>qAó bS¡XB(¶1êÜØ†¬ø‡n0-ì-¦ž§l8lpº1L±4&„ Ð &@ÑŠa0ƒĨ+TщAÈ!ˆNTa1„1#VHß1â‹5jd„p#FªPŒˆÉÑ"¤(nîH2ä‡à#E¬`‹hxBÉ7²ÑDD>ÄÞÀ†.¨àH‡ÂŠFÀAÉJdÑÀE*Šh(#¥L†§4Þb,ÜZeÉÏ•-0¯ö l¬  €@#ÄLWøIäEVÓ0óE˜€ ´0Ý. F”ˆ6ÑX#I” ¡ $0‰2¶4CD†e’U2,@Á"@¢º àÈ&,:4,@£ NèA/p =.T6Ũ$ DºÀW* Ã. @ M*dÇ.(ä –.¤é‚ 2xÀ*¦`!—„™Ð)„ €B4:$ ƒ•l¶©ƒ3vÁ±èf'Aä`€Ÿ¬âÁŸlZ©1®t0€¸bŒ¢‹âÑ HPƒ0²è@å“DsK<ÿJ@$Ðе¨@P óÊJà†-Ðä"K.Îä‰$ÐÀ£{@s ‚·*²#à€#”qH&¤dòHe¬ÀÖ: ‚3¿¸BÈ¢{ sM¼n*AQÜáFeDQB Ð@¹ÃØ,ë6éˆ"Æ8ƒB¿¤ð$”°B Ä:8à¤X"P/Ðf "aü"L pq¿KPñ\¼±Æ<2Vz ~¸"$ºdpñ¤l@,ý(Ñç!°@´”’àΠ1)¨o¿ñª3Ñ›:ð ÷ $L/ Ú1×@™Tû5¯{½©ÊÕjœ¸ĉ6ìáÿ3ÈØÆ#¼­µá‡ÏÁø†3¾°ˆ 5„}RˆÊh²Ö‰óê€lÀÊ¥Xs‹G G.npîúë)~­”ãŒ+Tôhˆ5Â3Æ™gþºÖ,S@.§ƒFXAì' Z /ýðdÌi.ÏâÑ4# Áÿzæ)ÇN׎a 4º€ÚÞÓD çÂO¼ñjC0Í ³"‹‚( ½úÕoh¤š™ÆB@ h8# º‚*t¡•ELÏuå[ÊE3 œÂ;uJ”ñ gX#Ô\µdÅÂxÑÌ„F†´0‹eh… ôÜ£šiÌÆs€Ä°­ -CEh0š Šm„ˆÄ+n‰9hàKà4PDc€©GS0†Ðèö(`B¼…"‘¢S„àxÖÒ€A ®4 Æ8Ð]ÜŒ v˜Å)N @e"5vÂÅd¦Jƒ ÑÂ)n^@zXÔ"Na->ôBî+%lq,: º`¢~` Lœ¢ˆd%v± H ¨¸UÀŠJô"£Æ!ú 0è²"ŽF- yÌf:Ó";jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/5.gif0000644000000000000000000000366310520670125017771 0ustar GIF87a‚P÷ÿÿÿøøøøøðøøèøøàøðèøðàøÀèø¨Èød˜øH”øH€øDpø@Œø8hø0hø0`ø0Xô´ðøèððàðèèðäØð(LèèØèàØèàÐèp˜è$DàäÔàØÐàØÈà 8ØàØØØÌØÐÈØÈÈØL„Ø(PØ 4ÐÐÐÐ̼и¸Ð(PÌØÌÈÈÀÈȸÈÂÂÈÀ¸È°¸ÇÀÂÆÆÃÆÄÂÆÃÃÆÂÂÆ¼ÀÅÅÃÅÃÅÅÃÃÅÀŸ¸ÄÄÂÄÃÃÄÂÄÄÂÂÃÆÆÃÅÆÃÅÅÃÅÃÃÄÅÃÄÄÃÄÃÃÃÅÃÃÃÃÀ¸Ã¸Àø¸ÂÄÆÂÃÂÂÂÆÂÂÃÂÂÂÂÂÀÂÀÂÂÀÀÀÂÅÀÂÂÀÀÂÀÀÀÀ¼ÀÀ¸¸¼°´¼ H¸Ãø¼À¸¸¸¸¸°¸°¨¸¤°¸œ°¸´°°¸°°°° œ¬°¨¨°´¨¨´¨¨ ¨¤¨¨  ¨ ”¨ @ ¤°  œ ˜œœ˜˜˜œ˜Œˆˆ0Œˆ˜ˆˆˆˆ€ˆˆxx€€€€|p€x€|xxxppxphptppphphhp`hlxŒlhpl`Xhh`hX`h4d`h``X`XX`TP`PXXXPXTXXPPPPLPHPPHHP@LP@@HHLH@PH@@H@8H0@@@@8@@88@$0@80@8088008(88((808l0,00((0 (0 (,0( (( ( (((     ,‚Pÿ±H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ J´¨Q•@MÒåhM°lI-õÅ©Ì8QoIµ‹ŠÕ—`Vmµ%K*£¯-AIÕjKk.©«š¢E)gíØ­ZOi™{RK[Wx¾TÊ…kl-[‰øš”ÃK’R[k}bÖ-Pr—¤TxU&6“8ªe)³æ4vÙ’„P ¬I§G~Ù•+IÂ¥ÅéÖY…I@ÉÙ Ò6Ã!›~o¥Òò–kúôBté&(Àº¸¡"ÄVaL¸`u“0D˜ Qƒä­ÒÀ*WÁ(”"„‘Â%<8€8àP„q8B@ÑMÀ!(ø€>"A)8µ@:È¢…é(€‡ Òï›°Å*à(PôAV|¤ú°‰úØÂG ÒûÀzIH(@± V¼°h…}VÑŠ ä [Z±ŠW¬bªøD&>qÊU(b';jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/duke/3.gif0000644000000000000000000000354710520670125017770 0ustar GIF87a‚P÷ØØÈ˜˜ˆÀÀ°@@0@@HH@Hà<(à <ÈÀ¸ððè80<Œ€€øXˆXXXhppÐ(PD@T¨¨œPX`@@<¨  phxÐÈÀÐàèÀÀ¸0 À°°ðèàà0°¬¨˜˜ØØÐh``PHTÀ°¸€ <ÐÐÀ\0¸ÐØ0(08(0€xxÀ¸´8HP„Œh`h¸¸À€€|@88H@@phh`XTxp€ØððÈÐÜx|€04<ÀÀÈÈÀÈ``XøL|pph¨œ˜ˆ€Œ„lp¸¸¬lhpøðàÀ¸¨000è(X@80èôèHH@ÐØÌlX`8 À¸Àp`h@8@XPP°í<‘ªA1xÀϰüêƒ GÐzI­´ ì=ø«–ðóä“Ö®“ `4ÛJ+Ë‚‘ íHôÀ ¾FÁ×ZûϰÔäC‚ɶ‚$RÁ<-ÓU¹ÉâîµïŠ I M sÄ@ÛB:¤DW…忇gÌÏÐFW“¤ %xq „L2 3J6Õ$Ã2°Æÿ|ò2@¢$|lÂO ¨¤Ä,¨0Cœ|çòp0ø±ÆÅ^€ÌÔ £Ï? È'ˆv4ImTÁEn ò4ÁîòÃ%ÄÄ‚è?lS["t_YíÔug÷ÿ=ó“?ÊÉBOL¥á•§e¡Bߌ§ý5³ÈÒW³h8iãŒÀøæ×ªá´ XWÙTBZ´pÞø??4È•ó,2 i"ü­zÆ?ððsP5Kl=²øíŒ?ÂÄCu“Í<« ÆÄ÷½ úÄ ØVç¶gœ€ä¹[±¨>lÁí>YB ¿£ñÖëxÉí¯bþùø£O t¿¶±yüï’_þ’à_e!«Ããg-þŠ C8?°Ž,PcúP`Á†•þYêÆÐX Æa„l˜0ç€-X°RÀ,Uå@ ¶ä¡ž4ƒ 0@B „`;ˆ= ÿ8ÐL²á„ø ·x›»`º_¥€ò@^¨ Œ#ƒ[ÁU~eŒ#ck(°ŽCÑâ0hß1PƇx, ~&"£yµ °c‡Ѝ%\R$“†”QËMº8a“© Å0€yлx@b{f}Èá–©A@È1mºi»HceJ2É• ¡øò¥Ÿª"ˆX.9èhØr Œ”G-Zç` †:!Ž$#I¦é‹ f¨tÿÚd¨ø‚ª)S‹|X@*P‘¯¾º „*ØŠ ¸N¹Œ0ðpÄbË/ÄÈBg}š1ƒ4‹Ð$ÓÁ L² TPE¸¬Á[ïA B0uˆ‹Ð­HÓ‚v“FT€+ÌÒI{ 0X‹ ú"´ ¦Øá.U <Á  ÀĸQlŒ¤Äº}$Cˆ+PÁÔ¬€q„bÖ„«)¢Â06øÁä=c]©/Ö¶GÒØÞ¡Ñ†„cm™@a ÿ•±¼&îA2Æ1M௠ˆFç’áŒI($ Ú(žHø¢tKéaBrA¹ •Biü$·PÂj¡èBt°Âg´b!›x„ÕFQŠ„bƒ‹Xˆ# a5M¼B!ª˜B FXMÃPÈ–Á†…ŠA{3Ž F”a!ÀdÊ1 &h …(#fŒdÃ"5hFSæ†øÃ™Äߘˆ+4 c)Æ0n%€âÈHÆ%p¥[Ä¢¼†1Œq `ÃõSáFÔb¿ç&8±FâšÖüE0F!‰^ Ùã/|ñ _ ƒ¶˜'¾v;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/cube/0000755000000000000000000000000011410045042017105 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/cube/4.gif0000644000000000000000000000017610520670125017752 0ustar GIF87a €ÿÿÿ, ]Œ©Ëm£tOÚh€:eÊuÇç„ân'Zª+Édp7+òÊÆ¹X#_ßÂì<–‰nSŒÀàâ‡s=‡´es©»³Ñë 畞ÂÚi©l¡=ên¬i&•êyôŽÏë;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/cube/2.gif0000644000000000000000000000020710520670125017743 0ustar GIF87a €ÿÿÿ, fŒíØš°&Öæ²[íA!wl"™z)Jb0Ìy*]—^…£¤‰µV;JæHgC”©iàu¦I'UÇr!±,fU¸fµ‘ßøs¿¹5ûã.gmŸ`O<·¯¤µ%ÿü7&8èP;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/cube/1.gif0000644000000000000000000000021010520670125017734 0ustar GIF87a €ÿÿÿ, gŒ íoVd°"©¨uøõ|•Èiàä™çe’k…ê+‡1Jw”ê–Ê ƒ¸vÂYφ,â„ÀÑŒÓd‚ˆ›'49:Q-ÖÆ6;z´âkµì%׸ÓVë‹§SU£¼} ÒÖšãjÁà·'¸·W;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/cube/5.gif0000644000000000000000000000020510520670125017744 0ustar GIF87a €ÿÿÿ, dŒ™ê˜ ZÉ\µïËeœv}c5æI¥»<ÛzÒ=®7™~i¡b O‘3‚† œ Édý޼)´v}U³B˜5ŠÍ:ŸÔØ„Öz]j)» \ž•!x'È»Sðùâ¹S;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/cube/3.gif0000644000000000000000000000017510520670125017750 0ustar GIF87a €ÿÿÿ, \Œ©Ëc›´ˆ-ÕÔñÛ%ÏŠßrvV*–UÀ:®±N± ã³vç;}É@@>TPÈ#þŠŠ#ùœ™-)Ôh¥V=§±+ͳãÓÛ<‡G:óyC…áºýŽ?;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/0000755000000000000000000000000011410045042017272 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/25.gif0000644000000000000000000000047010520670125020217 0ustar GIF87a@@€ÿÿÿ,@@þŒ©«À£d΀‹ñÜ<û^ÜØ„æ)’#ʆêÖÆßûÈöL#÷ŽçüŸ¢‡¹€cx+Z1cñhd²t° Nj²8%™öt¨D\ßiU-‹ÇàžúìJkÖòœïx×_g5ѲäQc¨×EwhÖó§‘àÈFØ5¹˜xIa³’Y(ÈHÈÉõ©™4ØIuº£±ÈÚšÚ¹{IZbë´†©»•¨š¬7æá6¥Ú¢ÙkWKábÁñÌ0Ñ^3޾áñßœ^‡5×÷k{ú‘ÑW¶•Õä1豘8SvÑèuƒ‡X‰C™)ˆÉIøµùÙV8 !eágºõ—d9ª‘êZ(z·y ¹ZŧKËÛ $;|&ìR›i·jûüÉÍ)G=äLœ·-ÌíVûë=^Y®¾ÎÞîþÎR¼žM¢U;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/30.gif0000644000000000000000000000046310520670125020215 0ustar GIF87a@@€ÿÿÿ,@@þŒ© × £œØ7-ÝÜéz5áו Žêe¶T¬ª›eØ'¯4c?ùOÚ%À"‹†ê‹»Ò(¶Ô5‰Gƒ/úœ2ª(›Ô~‰V°øônç²LÉ<ÇÁ31ý—® ï°z®É÷¤ç¦Ö(øF¸wÈ’è¶Èx•å™V¸9sƱéÈã:òyZ:b²ÚiÓâw¨™IÊW›ŠDj{‹e h,\ ä*5Ìæ¤|ü×켋,Ë:Mm|—lú¬¬› ý;Ž0Ígž ]–í[,*ï¹¾=Øn¯ß+Í/^ož¶imDM (ð_®‚÷ì(lƒ¢D4+Z±ˆ1£Æ;zü2¤È‘$K²C'ò–;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/18.gif0000644000000000000000000000036310520670125020222 0ustar GIF87a@@€ÿÿÿ,@@ÒŒ©Ëí˜3Ôˆ³£¼{Ãi"â•%Ù™¢¨>,¥\ @ÆËܸöÓYx4¡D,uÉKp)jB¼aneÁ|ج6ñìBª\±×df’Óg4{´~¿òùÐV‡#ñùÕ¯·Õ·&8Fh(Äg‘ˆQÈØ¨²9H öx‰é£¹Ù¹÷)*úbÉ5iXø˜Rºè¹Y!ûjëx›TKézj‹¦TJôÚÄ[g¬*˜¬ÜÇüÉ|ü–<Œç–»'Œ=º½,! íM^n~ž…z‡í‹U;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/22.gif0000644000000000000000000000045110520670125020213 0ustar GIF87a@@€ÿÿÿ,@@þŒ©k £œË‡­¥¼Ÿ †âæ•͈¦Ù©.y±ÔK#°¬Ðúãù¾ó1€AáX3Ú/›’™:9…Ðhcê«¢*<œvûQ^¾#ñRCΘÇvzíîÆ‘ðèS­‹ûS¨îtǧ†'8Æ6Ô6h¨÷psÑG¨1¹ù3±XÉ5#)W‚™#É9êñ)“šÊÚi¢q$¶JúI«i{¦Û«ÊS{µûDÒvóè š ü‹wÈ!<í,EmfÝ¢|[= ý‡8³Òm=|ž¥Òž™Ên«óîhíY¤OÉ¿-J@E0ú ¬÷í`3S :|è¢Ä‰+Z¼ˆqÛ( s å³FI;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/17.gif0000644000000000000000000000036310520670125020221 0ustar GIF87a@@€ÿÿÿ,@@ÒŒ©Ëí˜>³ž¼{úaÚ˜„¦u˜äx"èbq+Ôº"{Ïå™ç¸nãa>\«8¬ iÂJ’Hª=/K¢Ç™šJª»ŽáÆÕ†¿W›–F-Ÿ£ŽÐz­z³qù<èµOÕúd¾/6ø“5ô"hÈð¢8”Ø©$éHöh)ÂhyAÖ¹ñYº8Ù•Iª† É F‡±J:K»÷Z +cŠKvÅIË#Ûü«I\,y¬;«ŒÌÚ\ RÇ‹'ùWjÝÆ[åìÍ=N^n~™~­]þ>R;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/12.gif0000644000000000000000000000035110520670125020211 0ustar GIF87a@@€ÿÿÿ,@@ÈŒ©«à £œÑÙK³Æ·ûhbóßiå¸-k€¦fÈÖP̽ö>ãTù~ÎçÈ‘ Ž×˜I/þ«NýníŽU=eò´ $ж\Ÿœ%¡…i7†>/ßÂ#yý•èè±LÈ‘$=”<‰2¥Ê•,[º| óF‹ï–ÀÄX¤;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/26.gif0000644000000000000000000000046510520670125020224 0ustar GIF87a@@€ÿÿÿ,@@þŒ©Ëí#ØK¥Ö¸{¿…ÌG––(žæÚ¡PF±rë.óMÖ ÎƒzÐ btÂâ)o¨cE¹d…œÏ¨tziXK†ÌƒfÛæ¼Z˜ùvÏié§²ý2ßdhÐÁ³¿á÷2š»³ç#÷—6ÄG5Ò³†¸˜•öˆÓXwhYI¨&HeY„…ɇÅù¹45b£Ó÷ÓÄ( dûÔ&S Ç«yµ«Ô˜»<Ñ{ëI\Lꤘ¸ÜÕ:içm-Í©¬dâ= žZ:¾yYí ¬N-Ù¾û¾îˆ-‰m¼œ¯ÿ>ꇿÝ üGN(yýèEØgíHÁ„&R¼ˆ1£Æ;zü2¤È‘$O1$ d¶;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/10.gif0000644000000000000000000000034310520670125020210 0ustar GIF87a@@€ÿÿÿ,@@ÂŒ©‹àÀ¢œt9óªÞêùÿaÄ• ˆz i¶â˜fÇźvµÝâþÎÛüp`2L¥¤’Éqæ B©Šµ^°U-·)ý‚“âªSާéÛZÖ>^ãÁéöEGÂËüä'7hÆG(tbxØÁ¸ˆôÆö3©÷dÉX™™HĹâó93$úé$šªJÊúSjzû ;8‹Y»©›‹+éû[*[«G{iÝGˆn«}ŽN± ß®~l•î{_¿±OIžvø’QãgÀ|øØ™BÕ¤D(õ&z h1bFP7NéèQHÈ‘$Kš<©%ÅW I~(£;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/23.gif0000644000000000000000000000047310520670125020220 0ustar GIF87a@@€ÿÿÿ,@@þŒ©‹À£T šŠóÜü¸ †bGRâ‰Z%—¶ãº¹2è9ð2çÚë¾Ê«ý|AáPwáÅÀr–ôÜž2itJME›3‹j`Á®âˆ ž.hŒÚBK€Íð´ñH¯ÇöoÚû¦çf²sg8&ˆxGX˜§á(·(ÉÀÕˆé´Ò¡Ù³³æŠsYzú"ŠZÓ¥ªvi+zåÊYk‹8X¢‹Å˜k©4ÜÊÖÛ„¼¼É÷‰ükJ˜­LJyíû¬½í jý-:<Þ3®œ¹£þè=©òNöPx\¯Õî•/\ÆoÖ¶«üékQÐ ¹*Í…Î!4gô$&Th±aF‡7Êñ2¤È‘$Kš<‰2å¸*å!ii¯I;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/27.gif0000644000000000000000000000045210520670125020221 0ustar GIF87a@@€ÿÿÿ,@@þŒ© °£œ4´[³6·ûïl"–å8bæÚ¡TØpì»{6™÷í.ó k»¡1”":޹$ìcÎDD Ô"]Q,hó‰x¿vÌ*KÏë› Ýox41„í:hO<LJ@Ö§hÆSÅ¥˜g8ȹÇxˆDX…—e¥Ö•‰Ù¦q©0 :V&fyšQú¢²Ô:Ygs)K*Äqåú§ËYÙ8õ»Œ‹C쇥6œÌ Öì|«šèÌËœfí”­ =Ýí×üYÄ:N©¥œ ~LÆþ‹>[9¿µm¸KlOiío.ß?wôÂñëEÐÅÁt :|1¢Ä‰+Z¼ˆ1£Æ ±¤…±;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/28.gif0000644000000000000000000000044610520670125020225 0ustar GIF87a@@€ÿÿÿ,@@þŒ©kÀ£œ XG³´éúÿiâ–æˆ"W`¶kša¬ãÖ ­öîá9ìù:ÁâmØèwCál¶táœg´{dÉ+Èúyš“xÌÔ 4t˜âæ\áQ¶vIš—XD[¾¾¶åwVg÷&øBµàÖuˆx¤UÖÙ§B¦‡¡˜‰‰ÙÇø)Ùù )ZšV…jzÚ±H¨ 72‰T6—²9‹—¥zÔD³ dÛ&RT\©Æc{yÌÜœ4Í÷Ó^޲þÍÙ”ìè^®€Ê+ˆ0¡Â… :|1¢Ä‰+Z¼ˆ±‚Ddóù(;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/19.gif0000644000000000000000000000037210520670125020223 0ustar GIF87a@@€ÿÿÿ,@@ÙŒ©Ë현³–µûzaÛx|¦YR¤vz‰¨À+Óº¯5“5Zæã~òÍ€Ÿ‹PGìpÇLRÕk:ѪôA´Ê®´ìÒÊízÁa1µ¼y2Ñ5›õ|Ãwò´H¹®·a ýoÝçÇ%‘²ed³P˜ÂèD‰‡XyIIÆ”IiaÙ© ™*BZjÊ©øeº„ú™ŠYX«©äúâø¹û lxl{‹+ˆ2ë:¦×ì,ªÆ*ìöœ´[m]¬K¼}­ÌÛíð]W>®¾ÎÞîþÞä{žK§nÃU;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/2.gif0000644000000000000000000000050210520670125020126 0ustar GIF87a@@€ÿÿÿ,@@þŒ© ÷–œ´¦çšÝ¼ÇàPYؕע’6jféÂlûZ˜*~n×'¹!ñh>Hô*‹#¦rè;:Ÿ<“´Ö„¤žžxÙVƒ¸/.rW¼Eq•°§o…šÑþ-S⸽lF%8F7¸ÇVxØ$u6gÅåçV™'y(r‰Yue™gÄIS¸(¢Špº·Êz÷ÙKÙ7ËQk{ûš%Ê¥ª'+|Ûºš|Œ<\wœ LÅܼëÆM],ÝË%—-¼ÍM,þ ¾,;î½þìì>Vjí¹‰¸Ö~?O/E/´Br#¨ƒ–=Uû-$e Ç N‘W-£"ÕRqÜô1£ÅIH2Ãe²dÊ•,[º| 3æ'v×`úkS;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/9.gif0000644000000000000000000000035310520670125020141 0ustar GIF87a@@€ÿÿÿ,@@ÊŒ©{àÏ¢œ4Q®¼¾:Ø5v&¦bCbçëŽê*·ð]Ïí‡÷ú¿éu€¿€Mè!¦/åŒir† ')µÒ°I-7+ý6•âªJq,O.ÓEZa_áÈ9ÝܾïîÌV³ÇÇb'x"ˆTóÇØxøH!·4Iùt)¤‰ÂÙY:ø9jª•H—ª —Šë4jDF;K›s–[«Ã«ÛÆëû ìx»KÜLŒÌl™¬l,, ]Syš=¸-Ó]ò.>NÎÜ;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/11.gif0000644000000000000000000000034010520670125020206 0ustar GIF87a@@€ÿÿÿ,@@¿Œ©›àÀ¢œ”½\Ý<à †ZÖ• dˆêè¥æÛëƒÐð]϶ãúÜ»ýTAØPT4AÉÒ’Ùì<1QéUå\³Î'·;ü¾ˆ5±ÔC5 Ñ,µç~³°¤x…ÙNÑí(_÷g’'èÔPx¦ˆ(Äxç÷Øè(¹°RÙG‰™C¶)sé©êù*bz:jÚÊÚ™ª)‹šú¹êŠ ›f˶GËk«»K˜»ü Ü{’¬¼\ö í2]m}­PÌøŠS;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/1.gif0000644000000000000000000000050310520670125020126 0ustar GIF87a@@€ÿÿÿ,@@þŒ© p½¢œ”µKaÝÜ8,]¢Ö•‘“A£h–h‡­l›r¤*Ï´¦hÜ!t6 ñÕêÁŽGšr‰cŽL$hõ'­fvÄG´),N°à­ð3 ÍÜ Ú~³Ýø¾^1Îx}:=ÔÖçG¤6(ãñ‡Àh…È¢§˜àX9Øh§x9S¸Ù™ø´Ùš³ç!h:úÀ©ºÊÊY¹›IK x)gh‡È;×ÌG7–H*+…|JŠç'Ì\A=]Ö¼æË”«½ NŒ›Ä©Þûê¼î%þíæ~'97ÿn{(]L¯¿¯Ÿ?|çÄ ¨,Ÿ¹jÿÖ¡²ÐICˆ Vdx1¡D#½tüHð£‘3’´qR£É”,[º| 3åJ’äb.{¸£;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/8.gif0000644000000000000000000000040510520670125020136 0ustar GIF87a@@€ÿÿÿ,@@䌩kà˜œ´ž Ò¶{> Æy¦¦ 6žî5¦l;¿v&—àTßh¾SIz¾0—)žŽ@¥‹‰$:‡ÐÐSYµ¾¤ŸliÚõrÁN^n^};T;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/5.gif0000644000000000000000000000047110520670125020136 0ustar GIF87a@@€ÿÿÿ,@@þŒ© í°¢œ”½ó`Ý<æàӕʞ͚Ý(BÚ›ºT¶‚ð¦É¶‡“á^«Ö/DéLÃc2xÔíJOe´I­¹éM;‹ÆÛoU|Jó´h`xýl«¼¬¸l.ŽmÊ_…ï<ßKL½]ûæ“. (W .I#Eï!Äi'Ú²¸ð ÆQ jìh¤È‘$KšdqÒÛ§l$[$,Q;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/3.gif0000644000000000000000000000047610520670125020141 0ustar GIF87a@@€ÿÿÿ,@@þŒ© Ý £œñç¨Þ \ÜÈ(–deäzŽ™¸¢Üy†Ù±™«ÝuéùvÁQhÜ!‰Eä³d6ºPšKDk4æsÚ }­Ï”[–³¼´6ŒÝ~ÆxÜ vߪê9•Ê Ãw÷—V5èUøgÒ¸h&ÙYh†èX¹Ô¢§¦yUÖ©øiøæøFʦU—“š´ æùj'§DÛiëÊV ÁxêÙ¦{jùˆÌ*¼\ܬ¼˜ü;Ü›‰L­II ={%Öí ëûiý >N©nÔÊý|{NÑ®ϼ=O'síŽÊ>2ªÒ¸ëà=Qše玸|ÉøQ¬È¢F‚¥1오4‘#Iš<‰2¥Ê’+¢ûxGA);jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/29.gif0000644000000000000000000000044310520670125020223 0ustar GIF87a@@€ÿÿÿ,@@þŒ©{À£LÀÍj§ÞáVÛ¸tTˆ‚äú`Fš²r&ð-sõÍ¹Þ º~¡qH,IÒöZÆš>ŠÍ! QkžÆ5ûü¡$àä´6‘xQQ:.«½Š“nüM.æßÍKÜÿ¬¿N Ÿ¿ <ˆ0¡Â… :|1¢Ä‰+Z¼X ã!";jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/images/earth/7.gif0000644000000000000000000000042110520670125020133 0ustar GIF87a@@€ÿÿÿ,@@ðŒ©í›´Ú#Ö·{“… ‘ß©„âd¢n©>Û#SõËÆܲ8£Sñz â/ˆ¼YŒ®dðÄü8c8%tºjF—ØÝkkë‚;V²¸¬ÕN©qÛÉ~«3©xÂk¦×í3tØm§'…ÇWDxá¥ä‡’å¡Ç˜sÈ%Xx7éXiÙøy…)Õ¨Y… SÚy:g9òĺ¹ÖÔÚÕ:g;(–›y¶Èëêë9*œj[l|Œ ,éËü·ûÜ\+ -[=„]A½ „ëÍn¸J.núªþMÕ.Ï-$ß\??|ž~¿þËŸ\/¿ òòw :z– ;jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/BounceMain.java0000644000000000000000000001054311111352066017615 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class BounceMain extends ActiveApplet { public static final int minWidth = 300; public static final int minHeight = 100; public static final int maxWidth = 1024; public static final int maxHeight = 768; public static final Params[] params = {new Params ("images/cube/", 1, 5, ".gif", Color.white), new Params ("images/duke/", 1, 17, ".gif", Color.lightGray), new Params ("images/earth/", 1, 30, ".gif", Color.white)}; public void init () { setProcess (new BounceNetwork (params, getDocumentBase (), this)); } public static final String TITLE = "Bounce"; public static final String DESCR = "Demonstrates animation of images using the ActiveCanvas. Three animation processes are created, each " + "with an image that it will move around. ActiveScroll processes allow the speed of the animation to be " + "controlled by sending messages to the animator process."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame (TITLE); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final BounceNetwork bounceNetwork = new BounceNetwork (params, null, activeFrame); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, bounceNetwork } ).run (); } public static class Params { public final String path, suffix; public final int from, to; public final Color background; public Params (String path, int from, int to, String suffix, Color background) { this.path = path; this.from = from; this.to = to; this.suffix = suffix; this.background = background; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/ns-Bounce.html0000644000000000000000000000131511113065047017450 0ustar JCSP Bounce

Bounce

The sliders control the speed of the animations to their right. Initially, they are in the bottom position which represents a speed of zero (and consumes no processor resource). Clicking on an animation panel reverses the order of the sequence of frames being dusplayed.

JCSP concurrency makes this type of control very easy ... jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/ImageLoader.java0000644000000000000000000000704511111352066017751 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.awt.*; import java.net.*; /** * @author P.H. Welch */ public class ImageLoader { final private static MediaTracker tracker = new MediaTracker (new Canvas ()); public static Image[] load (BounceMain.Params params, final URL documentBase) { final int nImages = (params.to - params.from) + 1; if (nImages < 0) return null; final Image[] images = new Image[nImages]; if (documentBase == null) { // we're an application -- so load from a file for (int i = 0; i < nImages; i++) { String file = params.path + (i + params.from) + params.suffix; images[i] = Toolkit.getDefaultToolkit ().getImage (file); System.out.println ("ImageLoader.load: " + file + " " + images[i]); } } else { // we're an applet -- so load from a URL try { for (int i = 0; i < nImages; i++) { URL url = new URL (documentBase, params.path + (i + params.from) + params.suffix); images[i] = Toolkit.getDefaultToolkit ().getImage (url); System.out.println ("ImageLoader.load: " + url + " " + images[i]); } } catch (MalformedURLException e) { System.out.println ("ImageLoader.load: MalformedURLException" + e); } } for (int i = 0; i < nImages; i++) { tracker.addImage (images[i], 0); } try { tracker.waitForAll (); } catch (InterruptedException e) { System.out.println (e); System.exit (-1); } return images; } } jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/Bounce.java0000644000000000000000000001141711111352066017011 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.util.ints.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class Bounce implements CSProcess { private final Image[] images; private final Color background; private final Panel panel; private final ActiveCanvas activeCanvas; private final ActiveScrollbar activeScrollBar; private final BounceController bounceController; private final ImageAnimator imageAnimator; public Bounce (Image[] images, Color background, final Container parent, final int nSiblings) { this.images = images; this.background = background; // channels ... final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10)); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); final One2OneChannelInt control = Channel.one2oneInt (); final One2OneChannelInt scroll = Channel.one2oneInt (new OverWriteOldestBufferInt (1)); final DisplayList displayList = new DisplayList (); // awt processes ... activeCanvas = new ActiveCanvas (); activeCanvas.addMouseEventChannel (mouseEvent.out ()); activeCanvas.setGraphicsChannels (toGraphics.in (), fromGraphics.out ()); activeCanvas.setPaintable (displayList); activeCanvas.setBackground (background); final Dimension parentSize = parent.getSize (); activeCanvas.setSize (parentSize.width, parentSize.height/nSiblings); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. final int MAX_SCALE = 200; final int SLIDER = 30; activeScrollBar = new ActiveScrollbar ( null, scroll.out (), Scrollbar.VERTICAL, MAX_SCALE, SLIDER, 0, MAX_SCALE + SLIDER ); panel = new Panel (); panel.setLayout (new BorderLayout ()); panel.add ("West", activeScrollBar); panel.add ("Center", activeCanvas); // application-specific processes ... bounceController = new BounceController ( mouseEvent.in (), scroll.in (), control.out (), MAX_SCALE ); imageAnimator = new ImageAnimator ( control.in (), toGraphics.out (), fromGraphics.in (), displayList, images, 1, 1 ); } public Panel getPanel () { return panel; } public void run () { new Parallel ( new CSProcess[] { activeScrollBar, activeCanvas, bounceController, imageAnimator } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/bounce/ImageAnimator.java0000644000000000000000000001252111111352066020310 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.awt.*; import org.jcsp.lang.*; import org.jcsp.awt.*; /** * @author P.H. Welch */ public class ImageAnimator implements CSProcess { private final ChannelInputInt in; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; private final Display display; private final Image[] images; private int dx; private int dy; /** * Construct a new ImageAnimator that will cycle. * * @param in the channel used to direct the animation * @param toGraphics the channel to the graphics component * @param fromGraphics the channel from the graphics component * @param display the display-channel to the graphics component * @param images the array of images to be displayed on the animation * @param dx the x displacement between each frame * @param dy the y displacement between each frame */ public ImageAnimator (ChannelInputInt in, ChannelOutput toGraphics, ChannelInput fromGraphics, Display display, Image[] images, int dx, int dy) { this.in = in; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; this.display = display; this.images = images; this.dx = dx; this.dy = dy; } private Dimension dimension; private int lastX = 0; private int lastY = 0; private final GraphicsCommand[] gCommand = {null, null, null}; public void run () { final Thread me = Thread.currentThread (); System.out.println ("ImageAnimator " + " priority = " + me.getPriority ()); me.setPriority (Thread.MIN_PRIORITY); System.out.println ("ImageAnimator " + " priority = " + me.getPriority ()); toGraphics.write (GraphicsProtocol.GET_DIMENSION); dimension = (Dimension) fromGraphics.read (); toGraphics.write (GraphicsProtocol.GET_BACKGROUND); gCommand[0] = new GraphicsCommand.SetColor ((Color) fromGraphics.read ()); gCommand[1] = new GraphicsCommand.FillRect (0, 0, dimension.width, dimension.height); final int nImages = images.length; int frame = 0; displayFirstImage (images[frame]); while (true) { final int delta = in.read (); frame = (frame + delta + nImages) % nImages; displayNextImage (images[frame]); } } /** * Called to update the graphics display * * @param image the image to draw */ public void displayFirstImage (final Image image) { final int imageWidth = image.getWidth (null); final int imageHeight = image.getHeight (null); lastX = (dimension.width - imageWidth)/2; lastY = (dimension.height - imageHeight)/2; gCommand[2] = new GraphicsCommand.DrawImage (image, lastX, lastY); display.set (gCommand); } /** * Called to update the graphics display * * @param image the image to draw */ public void displayNextImage (final Image image) { final int imageWidth = image.getWidth (null); final int imageHeight = image.getHeight (null); lastX += dx; if ((lastX < 0) | ((lastX + imageWidth) >= dimension.width)) { dx = -dx; lastX += dx; } lastY += dy; if ((lastY < 0) | ((lastY + imageHeight) >= dimension.height)) { dy = -dy; lastY += dy; } gCommand[2] = new GraphicsCommand.DrawImage (image, lastX, lastY); display.set (gCommand); } } jcsp-1.1-rc4.orig/src/jcsp-demos/plasma/0000755000000000000000000000000011410045043014725 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/plasma/PlasmaMain.java0000644000000000000000000000775611111352066017635 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * This example is based on * Sam's Java Plasma Applet * by Sam Marshall. It was modified to use * 8-bit images by Menno van Gangelen. * This JCSP demonstration is by Peter Welch. * * @author P.H. Welch */ public class PlasmaMain extends ActiveApplet { public static final String TITLE = "Plasma"; public static final String DESCR = "A benchmark for measuring the frame rate of the ActiveCanvas for a simple animation. The thread " + "generating the images responds to changes in the parameters from events sent by the user interface " + "controls."; public static final int minWidth = 256; public static final int minHeight = 256; public static final int maxWidth = 1024; public static final int maxHeight = 768; public void init () { setProcess (new PlasmaNetwork (this)); } public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame (TITLE); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final PlasmaNetwork plasmaNetwork = new PlasmaNetwork (activeFrame); //activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, plasmaNetwork } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/plasma/Plasma.html0000755000000000000000000000660611113065047017051 0ustar JCSP Plasma

Plasma

The Colours choice box offers four colour tables. The Scale choice box offers five scales of computation. In 1:8 scale, only one point in each 8 x 8 box in the plasma is computed and that colour is rendered for the whole of that box. The Freeze button freezes the animation.

The Genetic Code sequence shows 8 integer parameters whose values effect various properties of the plasma being animated. Each position in the sequence controls a different property. These vales may be altered by editing the text entry window. However, each edit must atomically leave 8 integers. The line is parsed after each edit and, if illegal (e.g. 9 integers or some non-integer character), it is set back to its previous sequence. Negative integers are allowed.

Interesting sequences (which you can cut and paste into the above Genetic Code box) are:

  2   5   1  4     16   23   13   10       (try scale 1:2 and colour Green/Blue)
  32  5  31 44     16   23   13   10
  32  5  31 44    206  203   13   10
  32  5  31 44    206  203  103   10
  32  5  31 44    206  203  103  100

The Frames/Second label at the top shows the number of plasma frames computed per second. For the higher scale values, this will be more than the number of frames actually being rendered per second - the rendering keeps up as best it can.

With acknowledgements to Sam's Java Plasma Applet ... have fun! jcsp-1.1-rc4.orig/src/jcsp-demos/plasma/PlasmaControl.java0000644000000000000000000004276511111352066020370 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.util.*; /** * @author P.H. Welch */ class PlasmaControl implements CSProcess { private final ChannelOutput codeConfigure; private final AltingChannelInput codeChannel; private final ChannelOutput colourConfigure; private final AltingChannelInput colourChannel; private final String[] colourMenu; private final ChannelOutput scaleConfigure; private final AltingChannelInput scaleChannel; private final String[] scaleMenu; private final ChannelOutput freezeConfigure; private final AltingChannelInput freezeChannel; private final ChannelOutput fpsConfigure; private final AltingChannelInput resizeChannel; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; public PlasmaControl (final ChannelOutput codeConfigure, final AltingChannelInput codeChannel, final ChannelOutput colourConfigure, final AltingChannelInput colourChannel, final String[] colourMenu, final ChannelOutput scaleConfigure, final AltingChannelInput scaleChannel, final String[] scaleMenu, final ChannelOutput freezeConfigure, final AltingChannelInput freezeChannel, final ChannelOutput fpsConfigure, final ChannelOutput toGraphics, final ChannelInput fromGraphics, final AltingChannelInput resizeChannel) { this.codeConfigure = codeConfigure; this.codeChannel = codeChannel; this.colourConfigure = colourConfigure; this.colourChannel = colourChannel; this.colourMenu = colourMenu; this.scaleConfigure = scaleConfigure; this.scaleChannel = scaleChannel; this.scaleMenu = scaleMenu; this.freezeConfigure = freezeConfigure; this.freezeChannel = freezeChannel; this.fpsConfigure = fpsConfigure; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; this.resizeChannel = resizeChannel; } // protected methods // ----------------- protected void fade (final byte[] downColour, final byte[] upColour, final int start, final int finish, final int step) { int up = 0; int down = 255; for (int i = start; i < finish; i++) { upColour[i] = (byte) up; downColour[i] = (byte) down; up += step; down -= step; } } protected ColorModel createColorModel (final int variety) { byte[] red = new byte[256]; byte[] green = new byte[256]; byte[] blue = new byte[256]; switch (variety) { case 0: fade (green, blue, 0, 86, 3); fade (blue, red, 86, 171, 3); fade (red, green, 171, 256, 3); break; case 1: fade (blue, red, 0, 128, 2); fade (red, blue, 128, 256, 2); break; case 2: fade (green, red, 0, 128, 2); fade (red, green, 128, 256, 2); break; case 3: fade (blue, green, 0, 128, 2); fade (green, blue, 128, 256, 2); break; case 4: final int redF = 127; final int greenF = 30; final int blueF = 50; for (int i = 0; i < 256; i++) { red[i] = (byte) (((i*redF) % 256) - 128); green[i] = (byte) (((i*greenF) % 256) - 128); blue[i] = (byte) (((i*blueF) % 256) - 128); } break; } final int nBitsOfColour = 8; return new IndexColorModel (nBitsOfColour, red.length, red, green, blue); } protected int[] createWaveTable (final int size) { int[] table = new int[size]; for (int i = 0; i < size; i++) { table[i] = (int) (32*(1 + Math.sin(((double)i*2*Math.PI)/size))); } return table; } public void run () { final int nScales = scaleMenu.length; final int[] scale = new int[nScales]; int scaleFactor = 1; for (int s = 0; s < nScales; s++) { scale[s] = scaleFactor; scaleFactor *= 2; } final int initialScale = 3; // 1:8 final int nColourModels = 5; MemoryImageSource[] mis = new MemoryImageSource[nColourModels]; final int initialColourModel = 0; final Image[] image = new Image[nColourModels]; int[] waveTable; final GraphicsCommand[] gcImage = {null}; final GraphicsCommand[] draw = new GraphicsCommand[nColourModels]; final DisplayList displayList = new DisplayList (); toGraphics.write (GraphicsProtocol.GET_DIMENSION); Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("PlasmaControl: graphics dimension = " + graphicsDim); int givenWidth = graphicsDim.width; int givenHeight = graphicsDim.height; byte[] pixels = new byte[givenWidth*givenHeight]; // for the computed image int scaledWidth, scaledHeight; scaledWidth = givenWidth/scale[initialScale]; scaledHeight = givenHeight/scale[initialScale]; waveTable = createWaveTable ((scaledWidth + scaledHeight)*2); for (int i = 0; i < nColourModels; i++) { mis[i] = new MemoryImageSource (scaledWidth, scaledHeight, createColorModel (i), pixels, 0, scaledWidth); mis[i].setAnimated (true); mis[i].setFullBufferUpdates (true); toGraphics.write (new GraphicsProtocol.MakeMISImage (mis[i])); image[i] = (Image) fromGraphics.read (); draw[i] = new GraphicsCommand.DrawImage (image[i], 0, 0, givenWidth, givenHeight); } int currentScale = initialScale; int currentColourModel = initialColourModel; MemoryImageSource currentMIS = mis[currentColourModel]; scaledWidth = givenWidth/scale[currentScale]; scaledHeight = givenHeight/scale[currentScale]; int[] currentWaveTable = waveTable; int currentWaveTableSize = currentWaveTable.length; toGraphics.write (new GraphicsProtocol.SetPaintable (displayList)); fromGraphics.read (); freezeConfigure.write ("Freeze"); fpsConfigure.write ("0"); scaleConfigure.write (new Integer (currentScale)); colourConfigure.write (new Integer (currentColourModel)); gcImage[0] = draw[currentColourModel]; // about to start cycling -- drop our priority to the minimum ... final Thread me = Thread.currentThread (); System.out.println ("Plasma priority = " + me.getPriority ()); me.setPriority (Thread.MIN_PRIORITY); System.out.println ("Plasma priority = " + me.getPriority ()); // the following are the main compute variables ... String scode = "2 5 1 4 6 3 3 0"; final int nCodes = 8; codeConfigure.write (scode); final int[] icode = new int[nCodes]; // int versions of scode final int[] mcode = new int[nCodes]; // modulo currentWaveTableSize versions of scode decode (scode, icode, mcode); // extracts icode (mcode used as workspace) modulate (icode, mcode, currentWaveTableSize); // ensures non-negative mcode int speed0 = mcode[0], speed1 = mcode[1]; int speed2 = mcode[2], speed3 = mcode[3]; int increment0 = mcode[4], increment1 = mcode[5]; int increment2 = mcode[6], increment3 = mcode[7]; int position0 = 0, position1 = 0, position2 = 0, position3 = 0; final int CODE_EVENT = 0; final int SCALE_EVENT = 1; final int RESIZE_EVENT = 2; final int COLOUR_EVENT = 3; final int FREEZE_EVENT = 4; final int SKIP_EVENT = 5; final Guard[] guard = { codeChannel, scaleChannel, resizeChannel, colourChannel, freezeChannel, new Skip () }; final boolean[] preCondition = new boolean[guard.length]; for (int i = 0; i < preCondition.length; i++) preCondition[i] = true; final Alternative alt = new Alternative (guard); final CSTimer tim = new CSTimer (); long firstFrameTime = tim.read (); long frames = 0; long fpsUpdate = 1; boolean displayChange = true; while(true) { // invariant: 0 <= position[i] < currentWaveTableSize // invariant: 0 <= speed[i] < currentWaveTableSize // invariant: 0 <= increment[i] < currentWaveTableSize switch (alt.priSelect (preCondition)) { case CODE_EVENT: String s = (String) codeChannel.read (); // System.out.println ("CODE_EVENT: " + s); if (decode (s, icode, mcode)) { scode = s; modulate (icode, mcode, currentWaveTableSize); speed0 = mcode[0]; speed1 = mcode[1]; speed2 = mcode[2]; speed3 = mcode[3]; increment0 = mcode[4]; increment1 = mcode[5]; increment2 = mcode[6]; increment3 = mcode[7]; } else { codeConfigure.write (scode); } break; case SCALE_EVENT: final ItemEvent se = (ItemEvent) scaleChannel.read (); final String schoice = (String) se.getItem (); // System.out.println ("SCALE_EVENT: " + schoice); int sindex = 0; while (schoice != scaleMenu[sindex]) sindex++; if (sindex == currentScale) break; currentScale = sindex; // DROP THROUGH TO RESIZE case RESIZE_EVENT : if (resizeChannel.pending ()) { ComponentEvent e = (ComponentEvent)resizeChannel.read (); if (e.getID () != ComponentEvent.COMPONENT_RESIZED) break; } toGraphics.write (GraphicsProtocol.GET_DIMENSION); graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("PlasmaControl: graphics dimension = " + graphicsDim); givenWidth = graphicsDim.width; givenHeight = graphicsDim.height; pixels = new byte[givenWidth*givenHeight]; // for the computed image scaledWidth = givenWidth/scale[currentScale]; scaledHeight = givenHeight/scale[currentScale]; waveTable = createWaveTable ((scaledWidth + scaledHeight)*2); for (int i = 0; i < nColourModels; i++) { mis[i] = new MemoryImageSource (scaledWidth, scaledHeight, createColorModel (i), pixels, 0, scaledWidth); mis[i].setAnimated (true); mis[i].setFullBufferUpdates (true); toGraphics.write (new GraphicsProtocol.MakeMISImage (mis[i])); image[i] = (Image) fromGraphics.read (); draw[i] = new GraphicsCommand.DrawImage (image[i], 0, 0, givenWidth, givenHeight); } currentMIS = mis[currentColourModel]; scaledWidth = givenWidth/scale[currentScale]; scaledHeight = givenHeight/scale[currentScale]; currentWaveTable = waveTable; currentWaveTableSize = currentWaveTable.length; position0 %= currentWaveTableSize; position1 %= currentWaveTableSize; position2 %= currentWaveTableSize; position3 %= currentWaveTableSize; modulate (icode, mcode, currentWaveTableSize); speed0 = mcode[0]; speed1 = mcode[1]; speed2 = mcode[2]; speed3 = mcode[3]; increment0 = mcode[4]; increment1 = mcode[5]; increment2 = mcode[6]; increment3 = mcode[7]; firstFrameTime = tim.read (); frames = 0; fpsUpdate = 1; gcImage[0] = draw[currentColourModel]; displayChange = true; break; case COLOUR_EVENT: final ItemEvent ce = (ItemEvent) colourChannel.read (); final String cchoice = (String) ce.getItem (); int cindex = 0; while (cchoice != colourMenu[cindex]) cindex++; if (cindex != currentColourModel) { currentColourModel = cindex; currentMIS = mis[currentColourModel]; currentMIS.newPixels (); gcImage[0] = draw[currentColourModel]; displayList.set (gcImage); } break; case FREEZE_EVENT: freezeChannel.read (); if (preCondition[SKIP_EVENT]) { freezeConfigure.write ("Unfreeze"); preCondition[SKIP_EVENT] = false; } else { freezeConfigure.write ("Freeze"); preCondition[SKIP_EVENT] = true; firstFrameTime = tim.read (); frames = 0; fpsUpdate = 1; } break; case SKIP_EVENT: int tposition0 = position0; int tposition1 = position1; int index = 0; for (int y = 0; y < scaledHeight; y++) { int tposition2 = position2; int tposition3 = position3; int tempval = currentWaveTable[tposition0] + currentWaveTable[tposition1]; for (int x = 0; x < scaledWidth; x++) { pixels[index++] = (byte) (tempval + currentWaveTable[tposition2] + currentWaveTable[tposition3]); tposition2 = (tposition2 + increment2) % currentWaveTableSize; tposition3 = (tposition3 + increment3) % currentWaveTableSize; } tposition0 = (tposition0 + increment0) % currentWaveTableSize; tposition1 = (tposition1 + increment1) % currentWaveTableSize; } position0 = (position0 + speed0) % currentWaveTableSize; position1 = (position1 + speed1) % currentWaveTableSize; position2 = (position2 + speed2) % currentWaveTableSize; position3 = (position3 + speed3) % currentWaveTableSize; frames++; if ((frames % fpsUpdate) == 0) { final long period = tim.read () - firstFrameTime; long framesPerSecond = (period == 0) ? 0 : (frames*10000) / period; fpsUpdate = framesPerSecond/10; fpsConfigure.write (fpsUpdate + "." + framesPerSecond%10); fpsUpdate /= 2; if (fpsUpdate == 0) fpsUpdate = 1; } currentMIS.newPixels (); if (displayChange) { displayChange = false; displayList.set (gcImage); } break; } } } private boolean decode (String s, int[] icode, int[] mcode) { try { if (s == null) throw new NoSuchElementException (); StringTokenizer tokens = new StringTokenizer (s); for (int i = 0; i < mcode.length; i++) { String item = tokens.nextToken(); int check = Integer.valueOf (item.trim ()).intValue (); // if (check < 0) throw new NoSuchElementException (); mcode[i] = check; // System.out.println ("code[" + i + "] = " + mcode[i]); } if (tokens.hasMoreTokens ()) throw new NoSuchElementException (); for (int i = 0; i < icode.length; i++) { icode[i] = mcode[i]; } // System.out.println ("codes OK"); return true; } catch (NoSuchElementException e) { // System.out.println ("codes BAD"); return false; } catch (NumberFormatException e2) { // System.out.println ("codes BAD"); return false; } } private void modulate (int[] icode, int[] mcode, int n) { for (int i = 0; i < icode.length; i++) { // System.out.print ("code[" + i + "] = " + icode[i]); mcode[i] = icode[i] % n; // System.out.print (", " + mcode[i]); if (mcode[i] < 0) mcode[i] += n; // System.out.println (", " + mcode[i]); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/plasma/ns-Plasma.html0000755000000000000000000000356511113065047017470 0ustar JCSP Plasma

Plasma

The Colours choice box offers four colour tables. The Scale choice box offers five scales of computation. In 1:8 scale, only one point in each 8 x 8 box in the plasma is computed and that colour is rendered for the whole of that box. The Freeze button freezes the animation.

The Genetic Code sequence shows 8 integer parameters whose values effect various properties of the plasma being animated. Each position in the sequence controls a different property. These vales may be altered by editing the text entry window. However, each edit must atomically leave 8 integers. The line is parsed after each edit and, if illegal (e.g. 9 integers or some non-integer character), it is set back to its previous sequence. Negative integers are allowed.

Interesting sequences (which you can cut and paste into the above Genetic Code box) are:

  2   5   1  4     16   23   13   10       (try scale 1:2 and colour Green/Blue)
  32  5  31 44     16   23   13   10
  32  5  31 44    206  203   13   10
  32  5  31 44    206  203  103   10
  32  5  31 44    206  203  103  100

The Frames/Second label at the top shows the number of plasma frames computed per second. For the higher scale values, this will be more than the number of frames actually being rendered per second - the rendering keeps up as best it can.

With acknowledgements to Sam's Java Plasma Applet ... have fun! jcsp-1.1-rc4.orig/src/jcsp-demos/plasma/PlasmaNetwork.java0000644000000000000000000001615511111352066020373 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ class PlasmaNetwork implements CSProcess { private final ActiveCanvas activeCanvas; private final PlasmaControl plasmaControl; private final ActiveChoice scaleChoice; private final ActiveChoice colourChoice; private final ActiveTextField codeTextField; private final ActiveButton freezeButton; private final ActiveLabel fpsLabel; public PlasmaNetwork (final Container parent) { // channels // final One2OneChannel mouseChannel = // Channel.one2one (new OverWriteOldestBuffer (10)); // final One2OneChannel mouseMotionChannel = // Channel.one2one (new OverWriteOldestBuffer (1)); // final One2OneChannel keyChannel = // Channel.one2one (new OverWriteOldestBuffer (10)); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); final One2OneChannel canvasResize = Channel.one2one (new OverWritingBuffer (1)); // processes parent.setLayout (new BorderLayout ()); parent.setBackground (Color.black); activeCanvas = new ActiveCanvas (); // activeCanvas.addMouseEventChannel (mouseChannel); // activeCanvas.addMouseMotionEventChannel (mouseMotionChannel); // activeCanvas.addKeyEventChannel (keyChannel); activeCanvas.setGraphicsChannels (toGraphics.in (), fromGraphics.out ()); activeCanvas.addComponentEventChannel (canvasResize.out ()); activeCanvas.setSize (parent.getSize ()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. parent.add ("Center", activeCanvas); // south panel final Panel south = new Panel (); south.setBackground (Color.green); final One2OneChannel codeChannel = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel codeConfigure = Channel.one2one (); codeTextField = new ActiveTextField (codeConfigure.in (), codeChannel.out (), "XXXXXXXXXXXXXX", 24); codeTextField.setBackground (Color.white); codeTextField.setEnabled (true); south.add (new Label ("Genetic Code", Label.CENTER)); south.add (codeTextField); final One2OneChannel scaleChannel = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel scaleConfigure = Channel.one2one (); scaleChoice = new ActiveChoice (scaleConfigure.in (), scaleChannel.out ()); final String[] scaleMenu = {"1:1", "1:2", "1:4", "1:8", "1:16"}; for (int i = 0; i < scaleMenu.length; i++) { scaleChoice.add (scaleMenu[i]); } south.add (new Label ("Scale", Label.CENTER)); south.add (scaleChoice); final One2OneChannel colourChannel = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel colourConfigure = Channel.one2one (); colourChoice = new ActiveChoice (colourConfigure.in (), colourChannel.out ()); final String[] colourMenu = {"Red/Green/Blue", "Red/Blue", "Red/Green", "Green/Blue", "Jumpy"}; for (int i = 0; i < colourMenu.length; i++) { colourChoice.add (colourMenu[i]); } south.add (new Label ("Colours", Label.CENTER)); south.add (colourChoice); parent.add ("South", south); // north panel final Panel north = new Panel (); north.setBackground (Color.green); final One2OneChannel freezeChannel = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel freezeConfigure = Channel.one2one (); freezeButton = new ActiveButton (freezeConfigure.in (), freezeChannel.out (), "XXXXXXXXXXXXXX"); freezeButton.setBackground (Color.white); freezeButton.setEnabled (true); north.add (freezeButton); final One2OneChannel fpsConfigure = Channel.one2one (); fpsLabel = new ActiveLabel (fpsConfigure.in (), "XXXXXXXXXXXXXX"); fpsLabel.setAlignment (Label.CENTER); fpsLabel.setBackground (Color.white); north.add (new Label ("Frames/Second", Label.CENTER)); north.add (fpsLabel); parent.add ("North", north); plasmaControl= new PlasmaControl (// mouseChannel, mouseMotionChannel, keyChannel, codeConfigure.out (), codeChannel.in (), colourConfigure.out (), colourChannel.in (), colourMenu, scaleConfigure.out (), scaleChannel.in (), scaleMenu, freezeConfigure.out (), freezeChannel.in (), fpsConfigure.out (), toGraphics.out (), fromGraphics.in (), canvasResize.in ()); } public void run () { new Parallel ( new CSProcess[] { activeCanvas, plasmaControl, codeTextField, scaleChoice, colourChoice, freezeButton, fpsLabel } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/0000755000000000000000000000000011410045043016226 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/channel/0000755000000000000000000000000011410045043017636 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/channel/Chef.java0000644000000000000000000000622311111352066021355 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Chef implements CSProcess { //The Chef is an active object. He/she cooks chickens in batches of four -- //taking around 2 seconds per batch -- and then sends them to the Canteen. //The Chef is delayed in the Canteen, waiting for an acknowledge that the //batch has been set down OK. // //This cycle continues indefinitely. private final ChannelOutputInt supply; public Chef (ChannelOutputInt supply) { this.supply = supply; } public void run () { final CSTimer tim = new CSTimer (); int n_chickens; System.out.println (" Chef : starting ... "); while (true) { // cook 4 chickens System.out.println (" Chef : cooking ... "); tim.after (tim.read () + 2000); // this takes 3 seconds to cook n_chickens = 4; System.out.println (" Chef : " + n_chickens + " chickens, ready-to-go ... "); supply.write (n_chickens); // supply the chickens supply.write (0); // wait till they're set down } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/channel/Canteen.java0000644000000000000000000001232611111352066022066 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// //| //| This program shows a use of the ALT mechanism. It is a re-implementation //| of the Starving Philosophers example but now has the Canteen programmed //| properly as an active process. Here is the College: //| //| //| 0 1 2 3 4 //| :) :) :) :) :) ___________ ________ //| | | | | | | | | | //| ---------------------<->--| Canteen |------<------| Cook | //| service/deliver |_________| supply |______| //| //| //| //| This time, although Philsopher 0 is just as greedy, no one starves. //| import org.jcsp.lang.*; /** * @author P.H. Welch */ class Canteen implements CSProcess { //The Canteen is an active object -- a pure SERVER process for its `supply' //and `service'/`deliver' Channels, giving priority to the former. // //Philosphers eat chickens. They queue up at the Canteen on its `service' //Channel. They only get served when chickens are available -- otherwise, //they just have to wait. Once they have got `service', they are dispensed //a chicken down the `deliver' Channel. // //The Chef cooks chickens. When a batch ready is ready, he/she queues up at //the Canteen on its `supply' Channel. Setting down the batch takes around //3 seconds and the Chef is made to hang about this has happened. private final AltingChannelInputInt service; // shared from all Philosphers (any-1) private final ChannelOutputInt deliver; // shared to all Philosphers (but only used 1-1) private final AltingChannelInputInt supply; // from the Chef (1-1) public Canteen (AltingChannelInputInt service, ChannelOutputInt deliver, AltingChannelInputInt supply) { this.service = service; this.deliver = deliver; this.supply = supply; } public void run () { final Alternative alt = new Alternative (new Guard[] {supply, service}); final boolean[] precondition = {true, false}; final int SUPPLY = 0; final int SERVICE = 1; final CSTimer tim = new CSTimer (); int nChickens = 0; System.out.println (" Canteen : starting ... "); while (true) { precondition[SERVICE] = (nChickens > 0); switch (alt.fairSelect (precondition)) { case SUPPLY: int value = supply.read (); // new batch of chickens from the Chef System.out.println (" Canteen : ouch ... make room ... this dish is very hot ... "); tim.after (tim.read () + 3000); // this takes 3 seconds to put down nChickens += value; System.out.println (" Canteen : more chickens ... " + nChickens + " now available ... "); supply.read (); // let the Chef get back to cooking break; case SERVICE: service.read (); // Philosopher wants a chicken System.out.println (" Canteen : one chicken coming down ... " + (nChickens - 1) + " left ... "); deliver.write (1); // serve one chicken nChickens--; break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/channel/Phil.java0000644000000000000000000000666411111352066021415 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Phil implements CSProcess { //A Philosopher thinks for a while -- around 3 seconds -- and then goes to the //Canteen for food, consuming what he gets straight away. This cycle continues //indefinitely. // //Except, that is, for Philosopher 0 ... who refuses to think and just keeps //going to the Canteen. // //For this Canteen, when there's no chicken, the Philosphers are just kept //waiting in the service queue. The greedy Philosopher no longer loses his //place through getting in before the food is cooked and doesn't starve. private final int id; private final ChannelOutputInt service; private final ChannelInputInt deliver; public Phil (int id, ChannelOutputInt service, ChannelInputInt deliver) { this.id = id; this.service = service; this.deliver = deliver; } public void run () { final CSTimer tim = new CSTimer (); System.out.println (" Phil " + id + " : starting ... "); while (true) { // everyone, bar Philosopher 0, has a little think if (id > 0) { tim.after (tim.read () + 3000); // thinking } // want chicken System.out.println (" Phil " + id + " : gotta eat ... "); service.write (0); deliver.read (); System.out.println (" Phil " + id + " : mmm ... that's good ... "); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/channel/Clock.java0000644000000000000000000000450011111352066021537 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Clock implements CSProcess { public void run () { final CSTimer tim = new CSTimer (); int tick = 0; while (true) { System.out.println ("[TICK] " + tick); tim.sleep (1000); tick++; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/channel/College.java0000644000000000000000000000711311111352066022061 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class College { public static final String TITLE = "Wot No Chickens"; public static final String DESCR = "Shows the JCSP solution to the 'Wot, No Chickens?' problem.\n\n" + "The College consists of 5 Philosophers, a Chef and the Canteen. All are " + "\"active\" objects. The Canteen ALTs between a service Channel, shared by " + "all the Philosophers, and a supply Channel from the Chef. Upon acceptance " + "of a service request, chickens are dispensed through a delivery Channel.\n\n" + "Despite the greedy behaviour of Philosopher 0, nobody starves. The Canteen " + "guards the service Channel so that Philosophers cannot blunder in when there " + "are no chickens, but are held waiting in the service queue."; public static void main (String argv[]) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); int n_philosophers = 5; final Any2OneChannelInt service = Channel.any2oneInt (); final One2OneChannelInt deliver = Channel.one2oneInt (); final One2OneChannelInt supply = Channel.one2oneInt (); final Phil[] phil = new Phil[n_philosophers]; for (int i = 0; i < n_philosophers; i++) { phil[i] = new Phil (i, service.out (), deliver.in ()); } new Parallel ( new CSProcess[] { new Clock (), new Canteen (service.in (), deliver.out (), supply.in ()), new Chef (supply.out ()), new Parallel (phil) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/starve/0000755000000000000000000000000011410045043017532 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/starve/StarveChef.java0000644000000000000000000000676611111352066022452 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class StarveChef implements CSProcess { //The Chef is an active object. He/she cooks chickens in batches of four -- //taking around 2 seconds per batch -- and then sends them to the Canteen. //The Chef is delayed in the Canteen, waiting for an acknowledge that the //batch has been set down OK. // //This cycle continues indefinitely. private final String id; private final int batchSize; private final int batchTime; private final StarveCanteen.Supply supply; public StarveChef (String id, int batchSize, int batchTime, StarveCanteen.Supply supply) { this.id = id; this.batchSize = batchSize; this.batchTime = batchTime; this.supply = supply; } public void run () { final CSTimer tim = new CSTimer (); int nReturned = 0; int nSupplied = 0; while (true) { // cook batchSize chickens System.out.println (" Chef " + id + " : cooking ... " + (batchSize - nReturned) + " chickens"); tim.sleep (batchTime); // this takes batchTime milliseconds to cook System.out.println (" Chef " + id + " : " + batchSize + " chickens, ready-to-go ... "); nReturned = supply.freshChickens (id, batchSize); // supply the chickens and wait till set down nSupplied += (batchSize - nReturned); System.out.println (" Chef " + id + " : " + nReturned + " returned [" + nSupplied + " supplied]"); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/starve/StarveCanteen.java0000644000000000000000000001333611111352066023151 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// //| //| This program shows a use of the ALT mechanism. It is a re-implementation //| of the Starving Philosophers example but now has the Canteen programmed //| properly as an active process. Here is the College: //| //| //| 0 1 2 3 4 //| :) :) :) :) :) ___________ ________ //| | | | | | | | | | //| ---------------------<->--| Canteen |------<------| Cook | //| service |_________| supply |______| //| //| //| //| This time, although Philsopher 0 is just as greedy, no one starves. //| import org.jcsp.lang.*; /** * This Canteen is an active object -- a pure SERVER process for its `service' * and `supply' CALL channels. The service channel is any-1 since, hopefully, * there will be many customers. The supply channel may be 1-1 (one chef) or * any-1 (many chefs). * * @author P.H. Welch * */ class StarveCanteen { // call interfaces and channels public static interface Service { public int takeChicken (String philId); } public static interface Supply { public int freshChickens (String chefId, int value); } // fields and constructors private final Service service; // called by the philosophers private final Supply supply; // called by the chefs private final int serviceTime; // how long a philosopher spends in the canteen private final int supplyTime; // how long the chef spends in the canteen private final int maxChickens; // maximum number of chickens in the canteen private final CSTimer tim; // for delays public StarveCanteen (int serviceTime, int supplyTime, int maxChickens) { this.service = new Service () { public int takeChicken (String philId) { return doTakeChicken (philId); } }; this.supply = new Supply () { public int freshChickens (String chefId, int value) { return doFreshChickens (chefId, value); } }; this.serviceTime = serviceTime; this.supplyTime = supplyTime; this.maxChickens = maxChickens; this.tim = new CSTimer (); } public Service getService () { return service; } public Supply getSupply () { return supply; } private int nChickens = 0; private int nSupplied = 0; private synchronized int doTakeChicken (String philId) { System.out.println (" Canteen -> " + philId + " : one chicken ordered ... " + nChickens + " left"); if (nChickens > 0) { tim.sleep (serviceTime); // this takes serviceTime to deliver nChickens--; nSupplied++; System.out.println (" Canteen -> " + philId + " : one chicken coming down ... " + nChickens + " left [" + nSupplied + " supplied]"); return 1; } else { return 0; } } private synchronized int doFreshChickens (String chefId, int value) { System.out.println (" Canteen <- " + chefId + " : ouch ... make room ... this dish is very hot ..."); tim.sleep (supplyTime); // this takes supplyTime to put down nChickens += value; int sendBack = nChickens - maxChickens; if (sendBack > 0) { nChickens = maxChickens; System.out.println (" Canteen <- " + chefId + " : full up ... sending back " + sendBack); } else { sendBack = 0; } System.out.println (" Canteen <- " + chefId + " : more chickens ... " + nChickens + " now available"); return sendBack; } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/starve/StarveCollege.java0000644000000000000000000001032511111352066023141 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class StarveCollege implements CSProcess { public static final String TITLE = "Wot No Chickens [starving]"; public static final String DESCR = "Shows the 'Wot, No Chickens?' problem with process starvation.\n\n" + "The College consists of 5 Philosophers, a Chef and the Canteen. The chef and the philosphers " + "are active processes that call methods on the passive canteen. The JCSP solution to this problem " + "makes the canteen active and able to hold the chef and philosophers in a queue. This one tells " + "the processes to wait and try again later if it cannot deal with them leading to possible starvation " + "because the place in the queue is lost."; public void run () { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final String[] philId = {"Bill", "Hilary", "Gennifer", "Paula", "Monica"}; // final int nPhilosophers = 5; final int thinkTime = 3000; final int eatTime = 100; final int waitTime = 3000; final int serviceTime = 0; final int supplyTime = 3000; final int maxChickens = 50; final StarveCanteen canteen = new StarveCanteen (serviceTime, supplyTime, maxChickens); final StarvePhil[] phils = new StarvePhil[philId.length]; for (int i = 0; i < phils.length; i++) { // String philId = new Integer (i).toString (); phils[i] = new StarvePhil (philId[i], canteen.getService (), thinkTime, eatTime, waitTime, i == 0); // phils[i] = new CallPhil (i, canteen.service, thinkTime, eatTime); } new Parallel ( new CSProcess[] { new StarveClock (), // canteen, new Parallel (phils), new StarveChef ("Pierre", 4, 2000, canteen.getSupply ()), // chefId, batchSize, batchTime //new StarveChef ("Henri", 10, 20000, canteen.getSupply ()), // chefId, batchSize, batchTime //new StarveChef ("Sid", 100, 150000, canteen.getSupply ()) // chefId, batchSize, batchTime // new CallChef (canteen.supply), } ).run (); } public static void main (String argv[]) { new StarveCollege ().run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/starve/StarvePhil.java0000644000000000000000000000747211111352066022474 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class StarvePhil implements CSProcess { //A Philosopher thinks for a while -- around 3 seconds -- and then goes to the //Canteen for food, consuming what he gets straight away. This cycle continues //indefinitely. // //Except, that is, for Philosopher 0 ... who refuses to think and just keeps //going to the Canteen. // //For this Canteen, when there's no chicken, the Philosphers wait for a bit and try again, //possibly losing their place in the queue. private final String id; private final StarveCanteen.Service service; private final int thinkTime; private final int eatTime; private final int waitTime; private final boolean greedy; public StarvePhil (String id, StarveCanteen.Service service, int thinkTime, int eatTime, int waitTime, boolean greedy) { this.id = id; this.service = service; this.thinkTime = thinkTime; this.eatTime = eatTime; this.waitTime = waitTime; this.greedy = greedy; } public void run () { final CSTimer tim = new CSTimer (); int nEaten = 0; while (true) { // everyone, unless greedy, has a little think if (! greedy) { System.out.println (" Phil " + id + " : thinking ... "); tim.sleep (thinkTime); // thinking } // want chicken System.out.println (" Phil " + id + " : gotta eat ... "); while (service.takeChicken (id) == 0) { System.out.println (" Phil " + id + " : wot, no chickens ? it's an outrage !"); tim.sleep (waitTime); // try again later } nEaten++; System.out.println (" Phil " + id + " : mmm ... that's good [" + nEaten + " so far]"); tim.sleep (eatTime); // eating } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/starve/StarveClock.java0000644000000000000000000000461711111352066022631 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class StarveClock implements CSProcess { public void run () { final CSTimer tim = new CSTimer (); final long startTime = tim.read (); while (true) { int tick = (int) (((tim.read () - startTime) + 500)/1000); System.out.println ("[TICK] " + tick); tim.sleep (1000); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/callChannel/0000755000000000000000000000000011410045043020432 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/callChannel/CallCollege.java0000644000000000000000000001113111111352066023444 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class CallCollege implements CSProcess { public static final String TITLE = "Wot No Chickens [call channels]"; public static final String DESCR = "Shows the JCSP solution to the 'Wot, No Chickens?' problem using call channels.\n\n" + "The College consists of 5 Philosophers, three Chef and the Canteen. All are " + "\"active\" objects. The Canteen ALTs between a service Channel, shared by " + "all the Philosophers, and a supply Channel from the Chef. Upon acceptance " + "of a service request, chickens are dispensed through a delivery Channel.\n\n" + "Despite the greedy behaviour of Philosopher 0, nobody starves. The Canteen " + "guards the service Channel so that Philosophers cannot blunder in when there " + "are no chickens, but are held waiting in the service queue."; public void run () { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final String[] philId = {"Bill", "Hilary", "Gennifer", "Paula", "Monica"}; // final int nPhilosophers = 5; final int thinkTime = 3000; final int eatTime = 100; final int serviceTime = 0; final int supplyTime = 3000; final int maxChickens = 50; final CallCanteen.Any2OneServiceChannel service = new CallCanteen.Any2OneServiceChannel (); // final CallCanteen.One2OneSupplyChannel supply = new CallCanteen.One2OneSupplyChannel (); final CallCanteen.Any2OneSupplyChannel supply = new CallCanteen.Any2OneSupplyChannel (); // final CallCanteen canteen = new CallCanteen (serviceTime, supplyTime); final CallPhil[] phils = new CallPhil[philId.length]; for (int i = 0; i < phils.length; i++) { // String philId = new Integer (i).toString (); phils[i] = new CallPhil (philId[i], service, thinkTime, eatTime, i == 0); // phils[i] = new CallPhil (i, canteen.service, thinkTime, eatTime); } new Parallel ( new CSProcess[] { new CallClock (), new CallCanteen (service, supply, serviceTime, supplyTime, maxChickens), // canteen, new Parallel (phils), new CallChef ("Pierre", 4, 2000, supply), // chefId, batchSize, batchTime new CallChef ("Henri", 10, 20000, supply), // chefId, batchSize, batchTime new CallChef ("Sid", 100, 150000, supply) // chefId, batchSize, batchTime // new CallChef (canteen.supply), } ).run (); } public static void main (String argv[]) { new CallCollege ().run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/callChannel/CallPhil.java0000644000000000000000000000723611111352066023001 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class CallPhil implements CSProcess { //A Philosopher thinks for a while -- around 3 seconds -- and then goes to the //Canteen for food, consuming what he gets straight away. This cycle continues //indefinitely. // //Except, that is, for Philosopher 0 ... who refuses to think and just keeps //going to the Canteen. // //For this Canteen, when there's no chicken, the Philosphers are just kept //waiting in the service queue. The greedy Philosopher no longer loses his //place through getting in before the food is cooked and doesn't starve. private final String id; private final CallCanteen.Service service; private final int thinkTime; private final int eatTime; private final boolean greedy; public CallPhil (String id, CallCanteen.Service service, int thinkTime, int eatTime, boolean greedy) { this.id = id; this.service = service; this.thinkTime = thinkTime; this.eatTime = eatTime; this.greedy = greedy; } public void run () { final CSTimer tim = new CSTimer (); int nEaten = 0; while (true) { // everyone, unless greedy, has a little think if (! greedy) { System.out.println (" Phil " + id + " : thinking ... "); tim.sleep (thinkTime); // thinking } // want chicken System.out.println (" Phil " + id + " : gotta eat ... "); service.takeChicken (id); nEaten++; System.out.println (" Phil " + id + " : mmm ... that's good [" + nEaten + " so far]"); tim.sleep (eatTime); // eating } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/callChannel/CallChef.java0000644000000000000000000000675611111352066022760 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class CallChef implements CSProcess { //The Chef is an active object. He/she cooks chickens in batches of four -- //taking around 2 seconds per batch -- and then sends them to the Canteen. //The Chef is delayed in the Canteen, waiting for an acknowledge that the //batch has been set down OK. // //This cycle continues indefinitely. private final String id; private final int batchSize; private final int batchTime; private final CallCanteen.Supply supply; public CallChef (String id, int batchSize, int batchTime, CallCanteen.Supply supply) { this.id = id; this.batchSize = batchSize; this.batchTime = batchTime; this.supply = supply; } public void run () { final CSTimer tim = new CSTimer (); int nReturned = 0; int nSupplied = 0; while (true) { // cook batchSize chickens System.out.println (" Chef " + id + " : cooking ... " + (batchSize - nReturned) + " chickens"); tim.sleep (batchTime); // this takes batchTime milliseconds to cook System.out.println (" Chef " + id + " : " + batchSize + " chickens, ready-to-go ... "); nReturned = supply.freshChickens (id, batchSize); // supply the chickens and wait till set down nSupplied += (batchSize - nReturned); System.out.println (" Chef " + id + " : " + nReturned + " returned [" + nSupplied + " supplied]"); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/callChannel/CallClock.java0000644000000000000000000000461511111352066023136 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class CallClock implements CSProcess { public void run () { final CSTimer tim = new CSTimer (); final long startTime = tim.read (); while (true) { int tick = (int) (((tim.read () - startTime) + 500)/1000); System.out.println ("[TICK] " + tick); tim.sleep (1000); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/wotNoChickens/callChannel/CallCanteen.java0000644000000000000000000001754611111352066023467 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// //| //| This program shows a use of the ALT mechanism. It is a re-implementation //| of the Starving Philosophers example but now has the Canteen programmed //| properly as an active process. Here is the College: //| //| //| 0 1 2 3 4 //| :) :) :) :) :) ___________ ________ //| | | | | | | | | | //| ---------------------<->--| Canteen |------<------| Cook | //| service |_________| supply |______| //| //| //| //| This time, although Philsopher 0 is just as greedy, no one starves. //| import org.jcsp.lang.*; /** * This Canteen is an active object -- a pure SERVER process for its `service' * and `supply' CALL channels. The service channel is any-1 since, hopefully, * there will be many customers. The supply channel may be 1-1 (one chef) or * any-1 (many chefs). * * @author P.H. Welch */ class CallCanteen implements CSProcess { // call interfaces and channels public static interface Service { public int takeChicken (String philId); } public static class One2OneServiceChannel extends One2OneCallChannel implements Service { public int takeChicken (String philId) { join (); int n = ((Service) server).takeChicken (philId); fork (); return n; } } public static class Any2OneServiceChannel extends Any2OneCallChannel implements Service { public int takeChicken (String philId) { join (); int n = ((Service) server).takeChicken (philId); fork (); return n; } } public static interface Supply { public int freshChickens (String chefId, int value); } public static class One2OneSupplyChannel extends One2OneCallChannel implements Supply { public int freshChickens (String chefId, int value) { join (); int n = ((Supply) server).freshChickens (chefId, value); fork (); return n; } } public static class Any2OneSupplyChannel extends Any2OneCallChannel implements Supply { public int freshChickens (String chefId, int value) { join (); int n = ((Supply) server).freshChickens (chefId, value); fork (); return n; } } // fields and constructors private final AltingChannelAccept service; // shared from all Philosphers (any-1) private final AltingChannelAccept supply; // from the Chef (1-1) private final int serviceTime; // how long a philosopher spends in the canteen private final int supplyTime; // how long the chef spends in the canteen private final int maxChickens; // maximum number of chickens in the canteen public CallCanteen (Any2OneServiceChannel service, One2OneSupplyChannel supply, int serviceTime, int supplyTime, int maxChickens) { this.service = service; this.supply = supply; this.serviceTime = serviceTime; this.supplyTime = supplyTime; this.maxChickens = maxChickens; } public CallCanteen (Any2OneServiceChannel service, Any2OneSupplyChannel supply, int serviceTime, int supplyTime, int maxChickens) { this.service = service; this.supply = supply; this.serviceTime = serviceTime; this.supplyTime = supplyTime; this.maxChickens = maxChickens; } // inner process and run method private interface inner extends CSProcess, Service, Supply {}; public void run () { new inner () { private int nChickens = 0; private int nSupplied = 0; private final CSTimer tim = new CSTimer (); public int takeChicken (String philId) { // precondition : nChickens > 0 System.out.println (" Canteen -> " + philId + " : one chicken ordered ... " + nChickens + " left"); tim.sleep (serviceTime); // this takes serviceTime to deliver nChickens--; nSupplied++; System.out.println (" Canteen -> " + philId + " : one chicken coming down ... " + nChickens + " left [" + nSupplied + " supplied]"); return 1; } public int freshChickens (String chefId, int value) { // precondition : nChickens < maxChickens System.out.println (" Canteen <- " + chefId + " : ouch ... make room ... this dish is very hot ..."); tim.sleep (supplyTime); // this takes supplyTime to put down nChickens += value; int sendBack = nChickens - maxChickens; if (sendBack > 0) { nChickens = maxChickens; System.out.println (" Canteen <- " + chefId + " : full up ... sending back " + sendBack); } else { sendBack = 0; } System.out.println (" Canteen <- " + chefId + " : more chickens ... " + nChickens + " now available"); return sendBack; } public void run () { final Alternative alt = new Alternative (new Guard[] {supply, service}); final boolean[] precondition = {true, false}; final int SUPPLY = 0; final int SERVICE = 1; System.out.println (" Canteen : starting ... "); while (true) { precondition[SERVICE] = (nChickens > 0); precondition[SUPPLY] = (nChickens < maxChickens); switch (alt.fairSelect (precondition)) { case SUPPLY: supply.accept (this); // new batch of chickens from the Chef break; case SERVICE: service.accept (this); // Philosopher wants a chicken break; } } } }.run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/crew/0000755000000000000000000000000011410045036014412 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/crew/CrewPhilosopher.java0000644000000000000000000001325111111352066020376 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// //| //| Each philosopher reads/writes a shared blackboard through a Crew-lock. //| //| crewBlackboard //| ------------------------<--->-------- //| | //| _______|_________ //| | | //| | CrewPhilosopher | //| | (n) | //| |_________________| //| | //| | //| -------------------------->---------- //| display/displayInfo //| //| Each philosopher reports its state through a shared channel (display). //| import org.jcsp.lang.*; import java.util.*; /** * @author P.H. Welch */ class CrewPhilosopher implements CSProcess { private final int id; private final Crew crewBlackboard; private final ChannelOutputInt display, displayInfo; public CrewPhilosopher (final int id, final Crew crewBlackboard, final ChannelOutputInt display, final ChannelOutputInt displayInfo) { this.id = id; this.crewBlackboard = crewBlackboard; this.display = display; this.displayInfo = displayInfo; } protected Random random; protected int range (int n) { int i = random.nextInt (); if (i < 0) { i = (i == Integer.MIN_VALUE) ? 42 : -i; } return i % n; } public void run () { final int[] blackboard = (int[]) crewBlackboard.getShared (); int scribble; final int milliseconds = 1; final int seconds = 1000*milliseconds; final int minThink = 2*seconds; final int maxThink = 10*seconds; final int minRead = 5*seconds; final int maxRead = 10*seconds; final int minWrite = 5*seconds; final int maxWrite = 10*seconds; final int readPercent = 80; final CSTimer tim = new CSTimer (); long t; t = tim.read (); // initial thoughts tim.after (t + ((15*id)*milliseconds)); // to randomise this random = new Random (); // random generator while (true) { display.write (PhilState.THINKING); displayInfo.write (id); t = tim.read (); // do the thinking tim.after ( t + range (maxThink - minThink) + minThink ); if (range (100) < readPercent) { display.write (PhilState.WANNA_READ); displayInfo.write (id); crewBlackboard.startRead (); display.write (PhilState.READING); displayInfo.write (id); t = tim.read (); // do the reading tim.after ( t + range (maxRead - minRead) + minRead ); scribble = blackboard[0]; display.write (PhilState.DONE_READ); displayInfo.write (id); displayInfo.write (scribble); crewBlackboard.endRead (); } else { display.write (PhilState.WANNA_WRITE); displayInfo.write (id); crewBlackboard.startWrite (); display.write (PhilState.WRITING); displayInfo.write (id); t = tim.read (); // do the writing tim.after ( t + range (maxWrite - minWrite) + minWrite ); for (int i = 0; i < blackboard.length; i++) { blackboard[i] = id; } scribble = blackboard[0]; display.write (PhilState.DONE_WRITE); displayInfo.write (id); displayInfo.write (scribble); crewBlackboard.endWrite (); } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/crew/PhilState.java0000644000000000000000000000464011111352066017160 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ interface PhilState { public static final int THINKING = 0; public static final int WANNA_READ = 1; public static final int READING = 2; public static final int DONE_READ = 3; public static final int WANNA_WRITE = 4; public static final int WRITING = 5; public static final int DONE_WRITE = 6; public static final int TIME = 7; } jcsp-1.1-rc4.orig/src/jcsp-demos/crew/CrewDisplay.java0000644000000000000000000001105111111352066017503 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class CrewDisplay implements CSProcess { private final ChannelInputInt in, info; public CrewDisplay (final ChannelInputInt in, final ChannelInputInt info) { this.in = in; this.info = info; } protected void initialise () { } protected void updateBlackboard (char scribbleChar) { System.out.print ("BLACKBOARD = "); System.out.print (scribbleChar); System.out.print (scribbleChar); System.out.println (scribbleChar); } public void run () { final int zeroInt = 48; int scribbleInt; char scribbleChar = '?'; initialise (); updateBlackboard (scribbleChar); while (true) { int state = in.read (); int philId = info.read (); switch (state) { case PhilState.THINKING: System.out.println ("\tPhil " + philId + " : thinking ..."); break; case PhilState.WANNA_READ: System.out.println ("\t\tPhil " + philId + " : wanna read ..."); break; case PhilState.READING: System.out.println ("\t\t\tPhil " + philId + " : reading ..."); break; case PhilState.DONE_READ: scribbleInt = info.read (); if (scribbleInt != -1) scribbleChar = (char) (scribbleInt + zeroInt); System.out.print ("\t\t\t\tPhil " + philId + " : read "); System.out.print (scribbleChar); System.out.print (scribbleChar); System.out.println (scribbleChar); break; case PhilState.WANNA_WRITE: System.out.print ("\t\t\t\t\tPhil " + philId + " : wanna write ... "); System.out.print (philId); System.out.print (philId); System.out.println (philId); break; case PhilState.WRITING: System.out.print ("\t\t\t\t\t\tPhil " + philId + " : writing ... "); System.out.print (philId); System.out.print (philId); System.out.println (philId); break; case PhilState.DONE_WRITE: scribbleInt = info.read (); scribbleChar = (char) (scribbleInt + zeroInt); System.out.print ("\t\t\t\t\t\t\tPhil " + philId + " : wrote ... "); System.out.print (scribbleChar); System.out.print (scribbleChar); System.out.println (scribbleChar); updateBlackboard (scribbleChar); break; case PhilState.TIME: System.out.println ("TICK " + philId); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/crew/AWTDisplay.java0000644000000000000000000001412011111352066017236 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.event.*; /** * @author Quickstone Technologies Limited */ class AWTDisplay implements CSProcess { private final ChannelInputInt in, info; private Canvas canvas; private Graphics graphics; private int fontHeight = 1, fontWidth = 1; private class FixedSizeCanvas extends Canvas { public Dimension getPreferredSize () { return new Dimension (90 * fontWidth, 18 * fontHeight); } } public AWTDisplay (final ChannelInputInt in, final ChannelInputInt info) { this.in = in; this.info = info; } private void print (int x, int y, String text) { graphics.clearRect (x * fontWidth, (y - 1) * fontHeight, text.length () * fontWidth, fontHeight); graphics.drawString (text, x * fontWidth, y * fontHeight); } private void eraseEOS () { Dimension dim = canvas.getSize (); graphics.clearRect (0, 0, (int)dim.width, (int)dim.height); } protected void initialise () { eraseEOS (); print (2, 2, "Thinking Wanna Read Reading " + "Wanna Write Writing Local View"); print (2, 3, "======== ========== ======= " + "=========== ======= =========="); print (43, 16, "Time ="); print (60, 16, "Blackboard ="); } protected void updateBlackboard (char scribbleChar) { print (73, 16, "" + scribbleChar + scribbleChar + scribbleChar); } public void run () { Frame f = new ActiveFrame ("Scribbling Philosophers"); canvas = new FixedSizeCanvas (); f.add (canvas); f.setVisible (true); graphics = canvas.getGraphics (); graphics.setFont (new Font ("monospaced", Font.PLAIN, 16)); FontMetrics fm = graphics.getFontMetrics (); fontHeight = fm.getHeight (); fontWidth = fm.charWidth ('x'); f.pack (); f.addWindowListener (new WindowAdapter () { public void windowClosing (WindowEvent e) { System.exit(0); } }); final int[] col = {4, 19, 32, 73, 46, 60, 73}; final int rowShift = 5; final int zeroInt = 48; int scribbleInt; char scribbleChar = '?'; initialise (); updateBlackboard (scribbleChar); while (true) { int state = in.read (); int philId = info.read (); switch (state) { case PhilState.THINKING: print (col[PhilState.THINKING], philId + rowShift, ":-)"); break; case PhilState.WANNA_READ: print (col[PhilState.THINKING], philId + rowShift, " "); print (col[PhilState.WANNA_READ], philId + rowShift, ":-("); break; case PhilState.READING: print (col[PhilState.WANNA_READ], philId + rowShift, " "); print (col[PhilState.READING], philId + rowShift, ":-)"); break; case PhilState.DONE_READ: scribbleInt = info.read (); if (scribbleInt != -1) scribbleChar = (char) (scribbleInt + zeroInt); print (col[PhilState.DONE_READ], philId + rowShift, "" + scribbleChar + scribbleChar + scribbleChar); print (col[PhilState.READING], philId + rowShift, " "); break; case PhilState.WANNA_WRITE: print (col[PhilState.THINKING], philId + rowShift, " "); print (col[PhilState.WANNA_WRITE], philId + rowShift, "" + philId + philId + philId); break; case PhilState.WRITING: print (col[PhilState.WANNA_WRITE], philId + rowShift, " "); print (col[PhilState.WRITING], philId + rowShift, "" + philId + philId + philId); break; case PhilState.DONE_WRITE: scribbleInt = info.read (); scribbleChar = (char) (scribbleInt + zeroInt); print (col[PhilState.DONE_WRITE], philId + rowShift, "" + scribbleChar + scribbleChar + scribbleChar); updateBlackboard (scribbleChar); print (col[PhilState.WRITING], philId + rowShift, " "); break; case PhilState.TIME: print (50, 16, "" + philId); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/crew/VT100Display.java0000644000000000000000000001407111111352066017362 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch */ class VT100Display implements CSProcess { private final ChannelInputInt in, info; public VT100Display (final ChannelInputInt in, final ChannelInputInt info) { this.in = in; this.info = info; } private final static void cursorXY (int x, int y) { System.out.print ("\u001b[" + y + ";" + x + "H"); } private final static void eraseEOS () { System.out.print ("\u001b[0J"); } protected void initialise () { cursorXY (1, 1); eraseEOS (); cursorXY (2, 2); System.out.println ("Thinking Wanna Read Reading " + "Wanna Write Writing Local View"); cursorXY (2, 3); System.out.println ("======== ========== ======= " + "=========== ======= =========="); cursorXY (43, 16); System.out.print ("Time ="); cursorXY (60, 16); System.out.print ("Blackboard ="); } protected void updateBlackboard (char scribbleChar) { cursorXY (73, 16); System.out.print (scribbleChar); System.out.print (scribbleChar); System.out.print (scribbleChar); } public void run () { final int[] col = {4, 19, 32, 73, 46, 60, 73}; final int rowShift = 5; final int zeroInt = 48; int scribbleInt; char scribbleChar = '?'; initialise (); updateBlackboard (scribbleChar); while (true) { int state = in.read (); int philId = info.read (); switch (state) { case PhilState.THINKING: cursorXY (col[PhilState.THINKING], philId + rowShift); System.out.print (":-)"); break; case PhilState.WANNA_READ: cursorXY (col[PhilState.THINKING], philId + rowShift); System.out.print (" "); cursorXY (col[PhilState.WANNA_READ], philId + rowShift); System.out.print (":-("); break; case PhilState.READING: cursorXY (col[PhilState.WANNA_READ], philId + rowShift); System.out.print (" "); cursorXY (col[PhilState.READING], philId + rowShift); System.out.print (":-)"); break; case PhilState.DONE_READ: scribbleInt = info.read (); if (scribbleInt != -1) scribbleChar = (char) (scribbleInt + zeroInt); cursorXY (col[PhilState.DONE_READ], philId + rowShift); System.out.print (scribbleChar); System.out.print (scribbleChar); System.out.print (scribbleChar); cursorXY (col[PhilState.READING], philId + rowShift); System.out.print (" "); break; case PhilState.WANNA_WRITE: cursorXY (col[PhilState.THINKING], philId + rowShift); System.out.print (" "); cursorXY (col[PhilState.WANNA_WRITE], philId + rowShift); // System.out.print (":-("); System.out.print (philId); System.out.print (philId); System.out.print (philId); break; case PhilState.WRITING: cursorXY (col[PhilState.WANNA_WRITE], philId + rowShift); System.out.print (" "); cursorXY (col[PhilState.WRITING], philId + rowShift); // System.out.print (":-)"); System.out.print (philId); System.out.print (philId); System.out.print (philId); break; case PhilState.DONE_WRITE: scribbleInt = info.read (); scribbleChar = (char) (scribbleInt + zeroInt); cursorXY (col[PhilState.DONE_WRITE], philId + rowShift); System.out.print (scribbleChar); System.out.print (scribbleChar); System.out.print (scribbleChar); updateBlackboard (scribbleChar); cursorXY (col[PhilState.WRITING], philId + rowShift); System.out.print (" "); break; case PhilState.TIME: cursorXY (50, 16); System.out.print (philId); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/crew/TimeKeeper.java0000644000000000000000000000530611111352066017315 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class TimeKeeper implements CSProcess { private final ChannelOutputInt display, displayInfo; public TimeKeeper (final ChannelOutputInt display, final ChannelOutputInt displayInfo) { this.display = display; this.displayInfo = displayInfo; } public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read (); final long oneSecond = 1000; int count = 0; while (true) { display.write (PhilState.TIME); displayInfo.write (count); timeout += oneSecond; tim.after (timeout); count++; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/crew/CrewCollege.java0000644000000000000000000001366111111352066017461 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// //| //| The Scribbling Philosophers //| =========================== //| //| This program demonstrates the Crew class for Concurrent-read-exclusive-write //| access to a shared object. //| //| A college consists of five philosophers and a blackboard. The philosophers spend //| their time between thinking, looking at what others have written on the blackboard //| and scribbling on the blackboard themselves. //| //| Access to the blackboard is a bit constrained, so only one at a time may scribble. //| Any number of philosophers may read the blackboard simultaenously, but not whilst //| a scribbler is scribbling -- space is so tight that someone scribbling on the board //| completely blocks the view. //| //| ______________ //| | | _______________ //| | blackboard | | | //| ---------------------<->--| | /-<-| TimeKeeper | //| | | | | | | (CREW) | | |_____________| //| :) :) :) :) :) |____________| | //| 1 2 3 4 5 v _______________ //| | | | | | | | | //| ---------------------->-------------------------| TextDisplay | //| display/displayInfo |_____________| //| //| import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class CrewCollege { public static final String TITLE = "Scribbling Philosophers"; public static final String DESCR = "Shows the use of the Crew class for Concurrent-read-exclusive-write access to a shared object.\n\n" + "A college consists of five philosophers and a blackboard. The philosophers spend their time between " + "thinking, looking at what others have written on the blackboard and scribbling on the blackboard " + "themselves.\n\n" + "Access to the blackboard is a bit constrained, so only one at a time may scribble. Any number of " + "philosophers may read the blackboard simultaenously, but not whilst a scribbler is scribbling -- " + "space is so tight that someone scribbling on the board completely blocks the view."; public static void main (String argv[]) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final int n_philosophers = 10; final int blackboard_size = 10; final int[] blackboard = new int[blackboard_size]; for (int i = 0; i < blackboard_size; i++) { // initially, there is blackboard[i] = -1; // garbage in the shared } // resource (blackboard) final Crew crewBlackboard = new Crew (blackboard); final Any2OneChannelInt display = Channel.any2oneInt (); final One2OneChannelInt displayInfo = Channel.one2oneInt (); final CrewPhilosopher[] phil = new CrewPhilosopher[n_philosophers]; for (int i = 0; i < n_philosophers; i++) { phil[i] = new CrewPhilosopher (i, crewBlackboard, display.out (), displayInfo.out ()); } final TimeKeeper timeKeeper = new TimeKeeper (display.out (), displayInfo.out ()); final CSProcess crewDisplay; /*if (argv.length == 1) { if (argv[0].equals("vt100")) { crewDisplay = new VT100Display (display.in (), displayInfo.in ()); } else if (argv[0].equals ("awt")) { crewDisplay = new AWTDisplay (display.in (), displayInfo.in ()); } else { crewDisplay = new CrewDisplay (display.in (), displayInfo.in ()); } } else { crewDisplay = new CrewDisplay (display.in (), displayInfo.in ()); }*/ crewDisplay = new AWTDisplay (display.in (), displayInfo.in ()); new Parallel ( new CSProcess[] { new Parallel (phil), timeKeeper, crewDisplay } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/commstime/0000755000000000000000000000000011410045036015447 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/commstime/CommsTime.java0000644000000000000000000000735611111352066020224 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class CommsTime { public static final String TITLE = "CommsTime"; public static final String DESCR = "Test of communication speed between JCSP processes. Based on OCCAM CommsTime.occ by Peter Welch, " + "University of Kent at Canterbury. Ported into Java by Oyvind Teig. Now using the JCSP library.\n" + "\n" + "A small network of four processes is created which will generate a sequence of numbers, measuring " + "the time taken to generate each 10000. This time is then divided to calculate the time per iteration, " + "the time per communication (one integer over a one-one channel) and the time for a context switch. " + "There are four communications per iteration and two context switches per communication. This test " + "forms a benchmark for the for the overheads involved.\n" + "\n" + "This version uses a PARallel delta2 component, so includes the starting and finishing of one extra" + "process per loop."; public static void main (String argv []) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); int nLoops = 10000; System.out.println (nLoops + " loops ...\n"); One2OneChannelInt a = Channel.one2oneInt (); One2OneChannelInt b = Channel.one2oneInt (); One2OneChannelInt c = Channel.one2oneInt (); One2OneChannelInt d = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new PrefixInt (0, c.in (), a.out ()), new Delta2Int (a.in (), d.out (), b.out ()), new SuccessorInt (b.in (), c.out ()), new Consume (nLoops, d.in ()) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/commstime/CommsTimeSymmetric.java0000644000000000000000000000254111111352066022110 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; class CommsTimeSymmetric { public static void main (String argv []) { System.out.println (""); System.out.println ("Test of communication between JCSP processes"); System.out.println ("Based on occam CommsTime.occ by Peter Welch, University of Kent at Canterbury"); System.out.println ("Ported into Java by Oyvind Teig"); System.out.println ("Now using the JCSP library (phw/pda1)"); System.out.println ("This version uses *symmetric* channels"); System.out.println (); SpuriousLog.start (); final int nIterations = 10000; System.out.println (nIterations + " iterations per timing ...\n"); One2OneChannelSymmetricInt a = Channel.one2oneSymmetricInt (); One2OneChannelSymmetricInt b = Channel.one2oneSymmetricInt (); One2OneChannelSymmetricInt c = Channel.one2oneSymmetricInt (); One2OneChannelSymmetricInt d = Channel.one2oneSymmetricInt (); new Parallel ( new CSProcess[] { new PrefixInt (0, c.in(), a.out()), new Delta2Int (a.in(), d.out(), b.out()), new SuccessorInt (b.in(), c.out()), new Consume (nIterations, d.in()) } ).run (); System.out.println ("\n\n\nOnly gets here if all above parallel processes fail ...\n\n\n"); } } jcsp-1.1-rc4.orig/src/jcsp-demos/commstime/SeqDelta2Int.java0000644000000000000000000001013711111352066020555 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * This process broadcasts integers arriving on its input channel in sequence * to its two output channels. * *

Process Diagram

* *
 *         ___________  out0 
 *    in  |           |--->---
 *   -->--| Delta2Int | out1
 *        |___________|--->---
 * 
*

Description

* Delta2Int is a process that broadcasts (in parallel) on its two output channels * everything that arrives on its input channel. *

Channel Protocols

* * * * * * * * * * * * * * * * * *
Input Channels
inint * All channels in this package carry integers. *
Output Channels
out0, out1int * The output Channels will carry a broadcast of whatever * integers are sent down the in Channel. *
* * @author P.H. Welch and P.D. Austin */ public final class SeqDelta2Int implements CSProcess { /** The input Channel */ private final ChannelInputInt in; /** The first output Channel */ private final ChannelOutputInt out0; /** The second output Channel */ private final ChannelOutputInt out1; /** * Construct a new Delta2Int process with the input Channel in and the output * Channels out0 and out1. The ordering of the Channels out0 and out1 make * no difference to the functionality of this process. * * @param in the input channel * @param out0 an output Channel * @param out1 an output Channel */ public SeqDelta2Int(final ChannelInputInt in, final ChannelOutputInt out0, final ChannelOutputInt out1) { this.in = in; this.out0 = out0; this.out1 = out1; } /** * The main body of this process. */ public void run() { while (true) { int value = in.read(); out0.write(value); out1.write(value); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/commstime/Consume.java0000644000000000000000000000651211111352066017731 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Consume implements CSProcess { private int nLoops; private ChannelInputInt in; public Consume (int nLoops, ChannelInputInt in) { this.nLoops = nLoops; this.in = in; } public void run () { int x = -1; int warm_up = 1000; System.out.print ("warming up ... "); for (int i = 0; i < warm_up; i++) { x = in.read (); } System.out.println ("last number received = " + x); System.out.println ("1000 cycles completed ... timing now starting ..."); while (true) { long t0 = System.currentTimeMillis (); for (int i = 0; i < nLoops; i++) { x = in.read (); } long t1 = System.currentTimeMillis (); System.out.println ("last number received = " + x); long microseconds = (t1 - t0) * 1000; long timePerLoop_us = (microseconds / ((long) nLoops)); System.out.println (" " + timePerLoop_us + " microseconds / iteration"); timePerLoop_us = (microseconds / ((long) (4*nLoops))); System.out.println (" " + timePerLoop_us + " microseconds / communication"); timePerLoop_us = (microseconds / ((long) (8*nLoops))); System.out.println (" " + timePerLoop_us + " microseconds / context switch"); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/commstime/SeqCommsTime.java0000644000000000000000000000724211111352066020667 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class SeqCommsTime { public static final String TITLE = "CommsTime"; public static final String DESCR = "Test of communication speed between JCSP processes. Based on OCCAM CommsTime.occ by Peter Welch, " + "University of Kent at Canterbury. Ported into Java by Oyvind Teig. Now using the JCSP library.\n" + "\n" + "A small network of four processes is created which will generate a sequence of numbers, measuring " + "the time taken to generate each 10000. This time is then divided to calculate the time per iteration, " + "the time per communication (one integer over a one-one channel) and the time for a context switch. " + "There are four communications per iteration and two context switches per communication. This test " + "forms a benchmark for the overheads involved.\n" + "\n" + "This version uses a SEQuential delta2 component."; public static void main (String argv []) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); int nLoops = 10000; System.out.println (nLoops + " loops ...\n"); One2OneChannelInt a = Channel.one2oneInt (); One2OneChannelInt b = Channel.one2oneInt (); One2OneChannelInt c = Channel.one2oneInt (); One2OneChannelInt d = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new PrefixInt (0, c.in (), a.out ()), new SeqDelta2Int (a.in (), d.out (), b.out ()), new SuccessorInt (b.in (), c.out ()), new Consume (nLoops, d.in ()) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/splat/0000755000000000000000000000000011410045036014575 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/splat/ns-Splat.html0000644000000000000000000000065111113065047017172 0ustar JCSP Splat

Splat

jcsp-1.1-rc4.orig/src/jcsp-demos/splat/SplatMain.java0000644000000000000000000001243611111352066017340 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.ints.*; import org.jcsp.awt.*; import java.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class SplatMain extends ActiveApplet { public static final String TITLE = "Splat"; public static final String DESCR = "Demonstrates pixel access using the active AWT components."; public static final int minWidth = 335; public static final int minHeight = 100; public static final int minBurst = 20; public static final int maxWidth = 1024; public static final int maxHeight = 768; public static final int maxBurst = 1000; public static final int squareFactor = 30; public void init () { final Dimension size = getSize (); final int standbyBurst = 100; final int standbyAcross = 4; final int standbyDown = 1; final int nAcross = getAppletInt ("nAcross", 1, size.width/squareFactor, standbyAcross); final int nDown = getAppletInt ("nDown", 1, size.height/squareFactor, standbyDown); final int burst = getAppletInt ("burst", minBurst, maxBurst, standbyBurst); final boolean detach = getAppletBoolean ("detach", false); if (detach) { // final One2OneChannelInt stopStart = Channel.one2oneInt (new OverWriteOldestBufferInt (1)); // setStopStartChannel (stopStart); final One2OneChannelInt destroy = Channel.one2oneInt (new OverWriteOldestBufferInt (1)); final One2OneChannelInt destroyAck = Channel.one2oneInt (); setDestroyChannels (destroy.out (), destroyAck.in ()); // setDestroyChannels (destroy, destroyAck, -1); // cheat for Sun's Java Plug-in final Frame frame = new Frame ("Splat"); frame.setSize (size); final Splat splat = new Splat (nAcross, nDown, burst, frame, destroy.in (), destroyAck.out ()); frame.pack (); frame.setLocation ((maxWidth - size.width)/2, (maxHeight - size.height)/2); frame.setVisible (true); frame.toFront (); setProcess (splat); } else { setProcess (new Splat (nAcross, nDown, burst, this, null, null)); } } public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.addPrompt ("squares across", 1, 50, 4); Ask.addPrompt ("squares down", 1, 50, 4); Ask.addPrompt ("burst", minBurst, maxBurst, 600); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); final int nAcross = Ask.readInt ("squares across"); final int nDown = Ask.readInt ("squares down"); final int burst = Ask.readInt ("burst"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame ("Splat"); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final Splat splat = new Splat (nAcross, nDown, burst, activeFrame, null, null); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, splat } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/splat/Splat.java0000644000000000000000000001464211111352066016534 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ class Splat implements CSProcess { private final ActiveCanvas activeCanvas; private final ActiveButton[] button; private final ActiveButton rearrange; private final SplatterControl control; private final Splatter splatter; private FrameZapper frameZapper = null; public Splat (final int nAcross, final int nDown, final int burst, final Container parent, final ChannelInputInt destroy, final ChannelOutputInt destroyAck) { parent.setLayout (new BorderLayout ()); parent.setBackground (Color.green); System.out.println ("Splat creating channels ..."); final One2OneChannel[] event = Channel.one2oneArray (SplatterControl.NUMBER, new OverWriteOldestBuffer (1)); final One2OneChannel[] configure = Channel.one2oneArray (SplatterControl.NUMBER); final One2OneChannel rearrangeEvent = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel rearrangeConfigure = Channel.one2one (); final One2OneChannel report = Channel.one2one (); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); System.out.println ("Splat created channels"); System.out.println ("Splat creating ActiveButtons ..."); button = new ActiveButton[SplatterControl.NUMBER]; for (int i = 0; i < SplatterControl.NUMBER; i++) { button[i] = new ActiveButton (configure[i].in (), event[i].out (), "XXXXXXXXXXXXX"); System.out.println (" button " + i + " " + button[i].getPreferredSize ()); } rearrange = new ActiveButton (rearrangeConfigure.in (), rearrangeEvent.out (), "XXXXXXXXXXXXX"); System.out.println ("Splat created ActiveButtons ... now adding them to the parent ..."); final Panel north = new Panel (); final Panel south = new Panel (); north.add (button[SplatterControl.RESTART]); north.add (button[SplatterControl.FREEZE]); north.add (button[SplatterControl.CLEAR]); south.add (button[SplatterControl.SPLAT]); south.add (rearrange); south.add (button[SplatterControl.UNSPLAT]); System.out.println (" Panel north: " + north.getPreferredSize ()); System.out.println (" Panel south: " + south.getPreferredSize ()); System.out.println (" Container parent: " + parent.getPreferredSize ()); parent.add ("North", north); parent.add ("South", south); System.out.println (" Container parent: " + parent.getSize ()); System.out.println ("Splat added buttons to the parent ... creating ActiveCanvas ..."); activeCanvas = new ActiveCanvas (); activeCanvas.setGraphicsChannels (toGraphics.in (), fromGraphics.out ()); activeCanvas.setSize (parent.getSize ()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. System.out.println ("Splat adding ActiveCanvas to the parent ..."); parent.add ("Center", activeCanvas); System.out.println ("Splat now creating SplatterControl ..."); control = new SplatterControl (Channel.getInputArray(event), Channel.getOutputArray(configure), report.out ()); System.out.println ("Splat now creating Splatter ..."); splatter = new Splatter (nAcross, nDown, burst, report.in (), rearrangeConfigure.out (), rearrangeEvent.in (), toGraphics.out (), fromGraphics.in ()); System.out.println ("Splat: parent's class is " + parent.getClass ()); if ((parent instanceof Frame) && (destroy != null) && (destroyAck != null)) { frameZapper = new FrameZapper ((Frame) parent, destroy, destroyAck); System.out.println ("Splat: just made FrameZapper"); } } public void run () { System.out.println ("Splat starting up the network ..."); new Parallel ( new CSProcess[] { activeCanvas, rearrange, control, splatter, (frameZapper != null) ? (CSProcess) frameZapper : (CSProcess) new Skip (), new Parallel (button) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/splat/SplatterControl.java0000644000000000000000000001355611111352066020613 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; /** * @author P.H. Welch */ class SplatterControl implements CSProcess { protected ActiveButtonControl control; protected AltingChannelInput[] event; // from buttons ... protected ChannelOutput[] configure; // to buttons ... protected ChannelOutput report; // to whoever is out there ... public final static int restart = 0; // these are the state names ... public final static int frozen = 1; public final static int clear = 2; public final static int splatting = 3; public final static int unsplatting = 4; public final static int NUMBER = 5; // this is the number of buttons public final static int RESTART = 0; // these are the button names ... public final static int FREEZE = 1; public final static int CLEAR = 2; public final static int SPLAT = 3; public final static int UNSPLAT = 4; protected String[][] label // these are the button labels ... = {new String[] { "restart", "RESTART"}, new String[] { "frozen", "FREEZE"}, new String[] { "clear", "CLEAR"}, new String[] { "splatting", "SPLAT"}, new String[] {"unsplatting", "UNSPLAT"}}; protected int[][] labelId // which label to use next ... = {new int[] {0, 0, 1, 1, 0}, // restart new int[] {1, 0, 1, 1, 1}, // frozen new int[] {1, 0, 0, 0, 1}, // clear new int[] {1, 1, 1, 0, 1}, // splatting new int[] {1, 1, 1, 1, 0}}; // unsplatting protected boolean[][] enable // next button enable status ... = {new boolean[] {false, false, true, true, false}, // restart new boolean[] { true, false, true, true, true}, // frozen new boolean[] { true, false, false, false, true}, // clear new boolean[] { true, true, true, false, true}, // splatting new boolean[] { true, true, true, true, false}}; // unsplatting protected int[][] nextState = {new int[] {0, 0, 2, 3, 0}, // restart new int[] {0, 1, 2, 3, 4}, // frozen new int[] {0, 2, 2, 2, 4}, // clear new int[] {0, 1, 2, 3, 4}, // splatting new int[] {0, 1, 2, 3, 4}}; // unsplatting protected ActiveButtonState[] makeState () { System.out.println ("SplatterControl making ActiveButtonState[] ..."); ActiveButtonState[] state = null; try { state = new ActiveButtonState[enable.length]; for (int i = 0; i < state.length; i++) { state[i] = new ActiveButtonState (labelId[i], enable[i], nextState[i]); } } catch (ActiveButtonState.BadArguments e) { System.out.println (e); System.exit (0); } System.out.println ("SplatterControl made ActiveButtonState[]"); return state; } public SplatterControl (AltingChannelInput[] event, ChannelOutput[] configure, ChannelOutput report) { System.out.println ("SplatterControl creating ..."); try { control = new ActiveButtonControl (event, configure, report, label, makeState (), 0); } catch (ActiveButtonControl.BadArguments e) { System.out.println (e); System.exit (0); } this.event = event; this.configure = configure; this.report = report; System.out.println ("SplatterControl created"); } public void run () { System.out.println ("SplatterControl starting ..."); control.run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/splat/Splat.html0000644000000000000000000000403311113065047016552 0ustar JCSP Splat

Splat

jcsp-1.1-rc4.orig/src/jcsp-demos/splat/Splatter.java0000644000000000000000000002264211111352066017246 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.image.*; import java.util.Random; /** * @author P.H. Welch */ public class Splatter implements CSProcess { protected int nAcross, nDown; final protected int burst; final private AltingChannelInput in; final private ChannelOutput rearrangeConfigure; final private AltingChannelInput rearrangeEvent; final private ChannelOutput toGraphics; final private ChannelInput fromGraphics; public Splatter (final int nAcross, final int nDown, final int burst, final AltingChannelInput in, final ChannelOutput rearrangeConfigure, final AltingChannelInput rearrangeEvent, final ChannelOutput toGraphics, final ChannelInput fromGraphics) { this.nAcross = nAcross; this.nDown = nDown; this.burst = burst; this.in = in; this.rearrangeConfigure = rearrangeConfigure; this.rearrangeEvent = rearrangeEvent; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; } // colours : red blue black // ------- --- ---- ----- final protected byte[] reds = {(byte)0xff, (byte)0x00, (byte)0x00}; final protected byte[] greens = {(byte)0x00, (byte)0x00, (byte)0x00}; final protected byte[] blues = {(byte)0x00, (byte)0xff, (byte)0x00}; final protected static byte red = 0; final protected static byte blue = 1; final protected static byte black = 2; // pixel array and key run-time parameters // --------------------------------------- protected byte[] pixels; protected int width, height, wStride, hStride, wGap, hGap; // protected methods // ----------------- protected ColorModel setColorModel () { return new IndexColorModel (2, 3, reds, greens, blues); } protected void computeGeometry () { final int dw = width/((2*nAcross) + 1); final int dh = height/((2*nDown) + 1); final int box = Math.min (dw, dh); // size of each red box // The following four constants are scaled to avoid rounding errors later. wGap = width - (nAcross*box); // (width) gap between boxes hGap = height - (nDown*box); // (height) gap between boxes wStride = (box*(nAcross + 1)) + wGap; // (width) stride between boxes hStride = (box*(nDown + 1)) + hGap; // (height) stride between boxes } protected void initialisePixels () { for (int h = 0; h < height; h++) { final int hh = h*(nDown + 1); for (int w = 0; w < width; w++) { final int ww = w*(nAcross + 1); if (((ww % wStride) > wGap) && ((hh % hStride) > hGap)) { pixels[(h*width) + w] = red; } else { pixels[(h*width) + w] = blue; } } } } protected void clearPixels () { for (int ij = 0; ij < pixels.length; ij++) { pixels[ij] = black; } } protected void splatPixels () { for (int i = 0; i < burst; i++) { pixels[range (pixels.length)] = black; } } protected void unsplatPixels () { for (int i = 0; i < burst; i++) { final int ij = range (pixels.length); final int ww = (ij % width)*(nAcross + 1); final int hh = (ij / width)*(nDown + 1); if (((ww % wStride) > wGap) && ((hh % hStride) > hGap)) { pixels[ij] = red; } else { pixels[ij] = blue; } } } final protected Random random = new Random (); final protected int range (int n) { int i = random.nextInt (); if (i < 0) { if (i == Integer.MIN_VALUE) { // guard against minint ! i = 42; } else { i = -i; } } return i % n; } public void run () { rearrangeConfigure.write (nAcross + " x " + nDown); toGraphics.write (GraphicsProtocol.GET_DIMENSION); final Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("Splatter: graphics dimension = " + graphicsDim); width = graphicsDim.width; height = graphicsDim.height; pixels = new byte[width*height]; computeGeometry (); final ColorModel model = setColorModel (); final MemoryImageSource mis = new MemoryImageSource (width, height, model, pixels, 0, width); mis.setAnimated (true); mis.setFullBufferUpdates (true); toGraphics.write (new GraphicsProtocol.MakeMISImage (mis)); final Image image = (Image) fromGraphics.read (); final DisplayList display = new DisplayList (); toGraphics.write (new GraphicsProtocol.SetPaintable (display)); fromGraphics.read (); final GraphicsCommand[] drawImage = {new GraphicsCommand.DrawImage (image, 0, 0)}; display.set (drawImage); final Thread me = Thread.currentThread (); System.out.println ("Splatter priority = " + me.getPriority ()); me.setPriority (Thread.MIN_PRIORITY); System.out.println ("Splatter priority = " + me.getPriority ()); int state = SplatterControl.restart; boolean splatting = false; final Guard[] guard = {in, rearrangeEvent, new Skip ()}; final boolean[] preCondition = {true, true, false}; final int NEW_STATE = 0; final int REARRANGE = 1; final int RUNNING = 2; final Alternative alt = new Alternative (guard); initialisePixels (); mis.newPixels (); while (true) { switch (alt.priSelect (preCondition)) { case NEW_STATE: state = ((Integer) in.read ()).intValue (); switch (state) { case SplatterControl.restart: System.out.println ("Splatter: restart"); initialisePixels (); mis.newPixels (); preCondition[RUNNING] = false; break; case SplatterControl.frozen: System.out.println ("Splatter: frozen"); preCondition[RUNNING] = false; break; case SplatterControl.clear: System.out.println ("Splatter: clear"); clearPixels (); mis.newPixels (); preCondition[RUNNING] = false; break; case SplatterControl.splatting: System.out.println ("Splatter: splatting"); preCondition[RUNNING] = true; splatting = true; break; case SplatterControl.unsplatting: System.out.println ("Splatter: unsplatting"); preCondition[RUNNING] = true; splatting = false; break; } break; case REARRANGE: rearrangeEvent.read (); nAcross = 1 + range (width/SplatMain.squareFactor); nDown = 1 + range (height/SplatMain.squareFactor); rearrangeConfigure.write (nAcross + " x " + nDown); System.out.println ("Splatter: rearranging" + " " + nAcross + " " + nDown); computeGeometry (); if (state == SplatterControl.restart) { initialisePixels (); mis.newPixels (); } break; case RUNNING: if (splatting) { splatPixels (); } else { unsplatPixels (); } mis.newPixels (); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/splat/FrameZapper.java0000644000000000000000000000610111111352066017654 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.awt.*; /** * @author P.H. Welch */ class FrameZapper implements CSProcess { private final Frame frame; private final ChannelInputInt destroy; private final ChannelOutputInt destroyAck; public FrameZapper (final Frame frame, final ChannelInputInt destroy, final ChannelOutputInt destroyAck) { this.frame = frame; this.destroy = destroy; this.destroyAck = destroyAck; } public void run () { destroy.read (); System.out.println ("FrameZapper: destroy.read () ... zapping frame ..."); // Test cheat for continued operation of detached frame (Sun's Java Plug-in) // Timer tim = new Timer (); // for (int i = 45; i >= 0; i--) { // tim.after (tim.read () + 1000); // System.out.println ("FrameZapper: counting ... " + i); // } frame.setVisible (false); frame.dispose (); System.out.println ("FrameZapper: frame zapped ... acknowledging destroy ..."); destroyAck.write (0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/flasher/0000755000000000000000000000000011410045036015076 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/flasher/FlasherControl.java0000644000000000000000000001132111113056662020673 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class FlasherControl implements CSProcess { final private long period; final private AltingChannelInput mouseEvent; final private ChannelOutput appletConfigure; public FlasherControl (final long period, final AltingChannelInput mouseEvent, final ChannelOutput appletConfigure) { this.period = period; this.mouseEvent = mouseEvent; this.appletConfigure = appletConfigure; } private class AppletColour implements ActiveApplet.Configure { private Color colour = Color.lightGray; public void setColour (Color colour) { this.colour = colour; } public void configure (java.applet.Applet applet) { applet.setBackground (colour); applet.repaint (); } } public void run () { final Random random = new Random (); final CSTimer tim = new CSTimer (); final Alternative alt = new Alternative (new Guard[] {mouseEvent, tim}); final boolean[] preCondition = {true, false}; final int MOUSE = 0; final int TIMER = 1; final AppletColour[] appletColour = {new AppletColour (), new AppletColour ()}; final AppletColour panelBlack = new AppletColour (); panelBlack.setColour (Color.black); appletConfigure.write (panelBlack); int index = 0; AppletColour appletCol = appletColour[index]; appletCol.setColour (new Color (random.nextInt ())); long timeout = tim.read (); boolean mousePresent = false; boolean running = true; while (running) { switch (alt.priSelect (preCondition)) { case MOUSE: switch (((MouseEvent) mouseEvent.read ()).getID ()) { case MouseEvent.MOUSE_ENTERED: if (! mousePresent) { mousePresent = true; timeout = tim.read () + period; tim.setAlarm (timeout); appletConfigure.write (appletCol); preCondition[TIMER] = true; } break; case MouseEvent.MOUSE_EXITED: if (mousePresent) { mousePresent = false; appletConfigure.write (panelBlack); preCondition[TIMER] = false; } break; } break; case TIMER: // System.out.println ("FlasherControl: tick"); timeout += period; tim.setAlarm (timeout); index = 1 - index; appletCol = appletColour[index]; appletCol.setColour (new Color (random.nextInt ())); appletConfigure.write (appletCol); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/flasher/FlasherNetwork.java0000644000000000000000000000536211113056662020714 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; public class FlasherNetwork implements CSProcess { final private long period; final private ActiveApplet activeApplet; public FlasherNetwork (final long period, final ActiveApplet activeApplet) { this.period = period; this.activeApplet = activeApplet; } public void run () { final One2OneChannel mouseEvent = Channel.one2one (); final One2OneChannel appletConfigure = Channel.one2one (); activeApplet.addMouseEventChannel (mouseEvent.out()); activeApplet.setConfigureChannel (appletConfigure.in()); new Parallel ( new CSProcess[] { activeApplet, new FlasherControl (period, mouseEvent.in(), appletConfigure.out()) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/flasher/ns-Flasher.html0000644000000000000000000000136511111407145017774 0ustar JCSP Flasher

Flasher

This just demonstrates sensitivity to mouse entry/exit events on the applet at the same time as performing a background computation.  Move the mouse pointer into the applet panel and it will start flashing.  Move it out and the panel goes black.

The period of the flashing is set by the period applet parameter.  The flashing colours are mostly pastel - not too violent. jcsp-1.1-rc4.orig/src/jcsp-demos/flasher/FlasherApplet.java0000644000000000000000000000471411113056662020510 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; public class FlasherApplet extends ActiveApplet { public static final int minPeriod = 300; // milliseconds public static final int maxPeriod = 1000; // milliseconds public static final int defaultPeriod = 500; // milliseconds public void init () { final int period = getAppletInt ("period", minPeriod, maxPeriod, defaultPeriod); setProcess (new FlasherNetwork (period, this)); // setProcess (new FlasherNetworkSSD (period, this)); } } jcsp-1.1-rc4.orig/src/jcsp-demos/flasher/Flasher.html0000644000000000000000000000430011111407145017346 0ustar JCSP Flasher

Flasher

This just demonstrates sensitivity to mouse entry/exit events on the applet at the same time as performing a background computation.  Move the mouse pointer into the applet panel and it will start flashing.  Move it out and the panel goes black.

The period of the flashing is set by the period applet parameter.  The flashing colours are mostly pastel - not too violent. jcsp-1.1-rc4.orig/src/jcsp-demos/flasher/FlasherNetworkSSD.java0000644000000000000000000001047211113056662021264 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; public class FlasherNetworkSSD implements CSProcess { final private long period; final private ActiveApplet activeApplet; public FlasherNetworkSSD (final long period, final ActiveApplet activeApplet) { this.period = period; this.activeApplet = activeApplet; } public void run () { final One2OneChannel mouseEvent = Channel.one2one (); final One2OneChannel appletConfigure = Channel.one2one (); final One2OneChannelInt stopStart = Channel.one2oneInt (); final One2OneChannelInt destroy = Channel.one2oneInt (); final One2OneChannelInt destroyAck = Channel.one2oneInt (); activeApplet.addMouseEventChannel (mouseEvent.out()); activeApplet.setConfigureChannel (appletConfigure.in()); activeApplet.setStopStartChannel (stopStart.out()); activeApplet.setDestroyChannels (destroy.out(), destroyAck.in()); // activeApplet.setDestroyChannels (destroy.out(), destroyAck.in(), -1); new Parallel ( new CSProcess[] { activeApplet, new FlasherControl (period, mouseEvent.in(), appletConfigure.out()), new CSProcess () { public void run () { while (true) { switch (stopStart.in().read ()) { case ActiveApplet.STOP: System.out.println ("FlasherNetworkSSD: ActiveApplet.STOP received"); break; case ActiveApplet.START: System.out.println ("FlasherNetworkSSD: ActiveApplet.START received"); break; default: System.out.println ("FlasherNetworkSSD: ActiveApplet. received"); break; } } } }, new CSProcess () { public void run () { while (true) { switch (destroy.in().read ()) { case ActiveApplet.DESTROY: System.out.println ("FlasherNetworkSSD: ActiveApplet.DESTROY received"); destroyAck.out().write (0); break; default: System.out.println ("FlasherNetworkSSD: ActiveApplet. received"); break; } } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/0000755000000000000000000000000011410045036014415 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongKeyControl.java0000644000000000000000000000615011113056662020206 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.awt.event.*; public class PongKeyControl implements CSProcess { private final ChannelInput keyboard; private final ChannelOutputInt leftMove; private final ChannelOutputInt rightMove; public PongKeyControl (final ChannelInput keyboard, final ChannelOutputInt leftMove, final ChannelOutputInt rightMove) { this.keyboard = keyboard; this.leftMove = leftMove; this.rightMove = rightMove; } public void run () { System.out.println ("PongKeyControl starting ..."); while (true) { final KeyEvent keyEvent = (KeyEvent) keyboard.read (); if (keyEvent.getID () == KeyEvent.KEY_PRESSED) { switch (keyEvent.getKeyCode ()) { case KeyEvent.VK_A: leftMove.write (PongPaddle.UP); break; case KeyEvent.VK_Z: leftMove.write (PongPaddle.DOWN); break; case KeyEvent.VK_K: rightMove.write (PongPaddle.UP); break; case KeyEvent.VK_M: rightMove.write (PongPaddle.DOWN); break; } } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongPaddle.java0000644000000000000000000003356311113056662017316 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.util.*; import java.awt.*; public class PongPaddle implements CSProcess { public final static int WIDTH = 10; public final static int HIT = 0; public final static int MISS = 1; public final static int UP = 0; public final static int DOWN = 1; private final static int SECONDS = 1000; // JCSP Timer units are milliseconds private final static int[] FACTOR_HEIGHT = {3, 5, 7, 9}; private final static int[] HEIGHT_INTERVAL = {8*SECONDS, 5*SECONDS, 2*SECONDS, SECONDS/2}; private final static int DELTA_HEIGHT = 2; private final static int MIN_HEIGHT = 20; private final static int WOBBLE_INTERVAL = 10; // milliseconds private final static int WOBBLE_COUNT = 2000; // i.e. 20 seconds private final static int WOBBLE_CHANCE = 10; // percent private final static int UNIT_DELTA_Y = 4; private final static int MAX_DELTA_FACTOR = 3; private final static int MIN_DELTA_FACTOR = -MAX_DELTA_FACTOR; private final static int[] DELTA_WEIGHT = {-6, -3, -1, 0, 1, 3, 6}; private final boolean leftPaddle; private final int speed; private final AltingChannelInputInt move; private final AltingChannelInput fromBalls; private final ChannelOutputInt toBalls; private final ChannelOutputInt toScorer; private final AltingChannelInput fromControl; private final DisplayList displayList; public PongPaddle (boolean leftPaddle, int speed, AltingChannelInputInt move, AltingChannelInput fromBalls, ChannelOutputInt toBalls, ChannelOutputInt toScorer, AltingChannelInput fromControl, DisplayList displayList) { this.leftPaddle = leftPaddle; this.speed = speed; this.move = move; this.fromBalls = fromBalls; this.toBalls = toBalls; this.toScorer = toScorer; this.fromControl = fromControl; this.displayList = displayList; } private final static class Graphic implements GraphicsCommand.Graphic { public Color colour, background; public int x, y, width, height, backgroundHeight; // invariant : (0 <= y < maxY) where (maxY == (backgroundHeight - height)) public void doGraphic (java.awt.Graphics g, java.awt.Component c) { g.setColor (background); g.fillRect (x, 0, width, backgroundHeight); g.setColor (colour); g.fillRect (x, y, width, height); } } private Random random; private final int range (int n) { // returns a random integer in the range [0, n - 1] int i = random.nextInt (); // needed since random.nextInt () not in JDK1.1 :-( if (i < 0) { if (i == Integer.MIN_VALUE) { // guard against minint ! i = 42; } else { i = -i; } } return i % n; } private boolean wobbleFlag = false; private int wobbleCount = WOBBLE_COUNT; private final int computeInterval (final int height, final int[] threshold) { if (wobbleFlag) { wobbleCount--; if (wobbleCount == 0) { wobbleFlag = false; wobbleCount = WOBBLE_COUNT; } return WOBBLE_INTERVAL; } for (int i = threshold.length - 1; i >= 0; i--) { if (height <= threshold[i]) return HEIGHT_INTERVAL[i]; } return HEIGHT_INTERVAL[0]; // won't get here! } public void run () { System.out.println ("Paddle " + leftPaddle + " running ..."); final CSTimer moveTimer = new CSTimer (); long moveInterval = (long) (((float) SECONDS)/((float) speed) + 0.5); long moveTimeout = 0; final CSTimer heightTimer = new CSTimer (); final Alternative alt = new Alternative ( new Guard[] {move, fromBalls, fromControl, moveTimer, heightTimer} ); final boolean[] preCondition = {true, true, true, false, true}; final int MOVE = 0; final int BALLS = 1; final int CONTROL = 2; final int MOVE_TIMEOUT = 3; final int HEIGHT_TIMEOUT = 4; final Dimension graphicsDim = (Dimension) fromControl.read (); System.out.println ("Paddle " + leftPaddle + ": " + graphicsDim); final int displaySlot = displayList.extend (GraphicsCommand.NULL); System.out.println ("Paddle " + leftPaddle + ": displaySlot = " + displaySlot); fromControl.read (); // let control continue final int[] threshold = new int[FACTOR_HEIGHT.length]; for (int i = 0; i < FACTOR_HEIGHT.length; i++) { threshold[i] = graphicsDim.height/FACTOR_HEIGHT[i]; } final int MAX_HEIGHT = threshold[0]; Graphic oldGraphic = new Graphic (); Graphic newGraphic = new Graphic (); GraphicsCommand oldCommand = new GraphicsCommand.General (oldGraphic); GraphicsCommand newCommand = new GraphicsCommand.General (newGraphic); System.out.println ("Paddle " + leftPaddle + ": priority = " + PriParallel.getPriority ()); PriParallel.setPriority (Thread.MAX_PRIORITY); System.out.println ("Paddle " + leftPaddle + ": priority = " + PriParallel.getPriority ()); random = new Random (moveTimer.read () + moveTimer.hashCode ()); while (true) { toScorer.write (0); // initialise data for new paddle ... newGraphic.colour = Color.red; newGraphic.width = WIDTH; newGraphic.height = MAX_HEIGHT; newGraphic.background = Color.white; newGraphic.backgroundHeight = graphicsDim.height; newGraphic.x = leftPaddle ? 0 : graphicsDim.width - WIDTH; newGraphic.y = (graphicsDim.height - newGraphic.height)/2; oldGraphic.colour = newGraphic.colour; oldGraphic.width = newGraphic.width; oldGraphic.height = newGraphic.height; oldGraphic.background = newGraphic.background; oldGraphic.backgroundHeight = newGraphic.backgroundHeight; oldGraphic.x = newGraphic.x; displayList.change (newCommand, displaySlot); Graphic tmpGraphic = oldGraphic; oldGraphic = newGraphic; newGraphic = tmpGraphic; GraphicsCommand tmpCommand = oldCommand; oldCommand = newCommand; newCommand = tmpCommand; int maxY = graphicsDim.height - newGraphic.height; int deltaHeight = -DELTA_HEIGHT; System.out.println ("Paddle " + leftPaddle + ": initialX,Y = " + newGraphic.x + ", " + newGraphic.y); System.out.println ("Paddle " + leftPaddle + ": initialW,H = " + newGraphic.width + ", " + newGraphic.height); int deltaFactor = 0; int deltaY = deltaFactor*UNIT_DELTA_Y; preCondition[MOVE_TIMEOUT] = false; int heightInterval = computeInterval (oldGraphic.height, threshold); System.out.println ("Paddle " + leftPaddle + ": heightInterval = " + heightInterval); long heightTimeout = heightTimer.read() + heightInterval; heightTimer.setAlarm (heightTimeout); boolean playing = true; while (playing) { boolean paddleMove = false; boolean paddleHeight = false; boolean paddleColour = false; switch (alt.fairSelect (preCondition)) { case MOVE: switch (move.read ()) { case UP: if (deltaFactor == -1) { preCondition[MOVE_TIMEOUT] = false; deltaFactor = 0; } else if (deltaFactor == 0) { moveTimeout = moveTimer.read (); preCondition[MOVE_TIMEOUT] = true; deltaFactor = 1; deltaY = DELTA_WEIGHT[deltaFactor + MAX_DELTA_FACTOR]*UNIT_DELTA_Y; paddleMove = true; } else if (deltaFactor < MAX_DELTA_FACTOR) { deltaFactor++; deltaY = DELTA_WEIGHT[deltaFactor + MAX_DELTA_FACTOR]*UNIT_DELTA_Y; paddleMove = true; } break; case DOWN: if (deltaFactor == 1) { preCondition[MOVE_TIMEOUT] = false; deltaFactor = 0; } else if (deltaFactor == 0) { moveTimeout = moveTimer.read () + moveInterval; moveTimer.setAlarm (moveTimeout); preCondition[MOVE_TIMEOUT] = true; deltaFactor = -1; deltaY = DELTA_WEIGHT[deltaFactor + MAX_DELTA_FACTOR]*UNIT_DELTA_Y; paddleMove = true; } else if (deltaFactor > MIN_DELTA_FACTOR) { deltaFactor--; deltaY = DELTA_WEIGHT[deltaFactor + MAX_DELTA_FACTOR]*UNIT_DELTA_Y; paddleMove = true; } break; } break; case BALLS: final PongBall.Info ball = (PongBall.Info) fromBalls.read (); if ((oldGraphic.y <= ball.y) && (ball.y < oldGraphic.y + oldGraphic.height)) { toBalls.write (HIT); toScorer.write (ball.zing); newGraphic.colour = (oldGraphic.colour == Color.red) ? Color.blue : Color.red; newGraphic.height = oldGraphic.height; newGraphic.y = oldGraphic.y; paddleColour = true; } else { toBalls.write (MISS); toScorer.write (-(2*ball.zing)/3); } break; case CONTROL: fromControl.read (); playing = false; break; case MOVE_TIMEOUT: paddleMove = true; break; case HEIGHT_TIMEOUT: newGraphic.colour = oldGraphic.colour; newGraphic.height = oldGraphic.height + deltaHeight; if (newGraphic.height <= MIN_HEIGHT) { newGraphic.height = MIN_HEIGHT; deltaHeight = -deltaHeight; } else if (newGraphic.height >= MAX_HEIGHT) { newGraphic.height = MAX_HEIGHT; deltaHeight = -deltaHeight; } maxY = graphicsDim.height - newGraphic.height; newGraphic.y = oldGraphic.y + ((oldGraphic.height - newGraphic.height)/2); if (newGraphic.y < 0) { newGraphic.y = 0; } else if (newGraphic.y >= maxY) { newGraphic.y = maxY; } if (!wobbleFlag) wobbleFlag = (range (100) < WOBBLE_CHANCE); heightInterval = computeInterval (newGraphic.height, threshold); // System.out.println ("Paddle " + leftPaddle + " height = " + newGraphic.height + // " : heightInterval = " + heightInterval + // " : wobbleFlag = " + wobbleFlag); heightTimeout += heightInterval; heightTimer.setAlarm (heightTimeout); paddleHeight = true; break; } if (paddleMove) { newGraphic.colour = oldGraphic.colour; newGraphic.height = oldGraphic.height; newGraphic.y = oldGraphic.y - deltaY; if ((newGraphic.y < 0) && (deltaY > 0)) { newGraphic.y = 0; preCondition[MOVE_TIMEOUT] = false; deltaFactor = 0; } else if ((newGraphic.y > maxY) && (deltaY < 0)) { newGraphic.y = maxY; preCondition[MOVE_TIMEOUT] = false; deltaFactor = 0; } else { moveTimeout += moveInterval; moveTimer.setAlarm (moveTimeout); } } if (paddleMove || paddleColour || paddleHeight) { displayList.change (newCommand, displaySlot); tmpGraphic = oldGraphic; oldGraphic = newGraphic; newGraphic = tmpGraphic; tmpCommand = oldCommand; oldCommand = newCommand; newCommand = tmpCommand; } } System.out.println ("Paddle " + leftPaddle + ": dead"); displayList.change (GraphicsCommand.NULL, displaySlot); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/Pong.html0000644000000000000000000000633611111407145016217 0ustar JCSP MultiPong

MultiPong

Left player controls:  A = [UP] Z = [DOWN]              Right player controls:  K = [UP] M = [DOWN]

There are 3 paddle move speeds.  Tapping [UP] from stationery starts the paddle moving upwards.  A second [UP] increases the speed and a third [UP] gets maximum speed.  Tapping [DOWN] reverses this process.  Tapping [DOWN] from stationery starts the paddle moving downwards and so on.  The paddles slowly shrink in size ... but will grow back.  Watch out for the wobbles that occasionally strike.

Scoring.  You win points for hitting balls and lose them (but not so many) for missing.  Faster moving balls carry more points (in relation to the square of the speed).  The size, shape and colour of the balls do not matter (in this version).  Can you keep your score positive?

Bad eyesight?  Then, keep the mouse pointer outside the playing area!

Keystrokes being ignored?  Sometimes keyboard focus gets lost, even though the browser window is highlighted.  Move the mouse pointer into (or out from) the playing area to force a regain of focus ... jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongBall.java0000644000000000000000000002172111113056662016770 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.util.*; import java.awt.*; public class PongBall implements CSProcess { private final int id; private final int speed; private final int life; private final Barrier dead; private final ChannelOutput toLeftPaddle; private final ChannelInputInt fromLeftPaddle; private final ChannelOutput toRightPaddle; private final ChannelInputInt fromRightPaddle; private final ChannelInput fromControl; private final ChannelOutput toControl; private final DisplayList displayList; private Random random; public PongBall (final int id, final int speed, final int life, final Barrier dead, final ChannelOutput toLeftPaddle, final ChannelInputInt fromLeftPaddle, final ChannelOutput toRightPaddle, final ChannelInputInt fromRightPaddle, final ChannelInput fromControl, final ChannelOutput toControl, final DisplayList displayList) { this.id = id; this.speed = speed; this.life = life*speed; this.dead = dead; this.toLeftPaddle = toLeftPaddle; this.fromLeftPaddle = fromLeftPaddle; this.toRightPaddle = toRightPaddle; this.fromRightPaddle = fromRightPaddle; this.fromControl = fromControl; this.toControl = toControl; this.displayList = displayList; } public final static class Info { public int zing, y; } private final static class Graphic implements GraphicsCommand.Graphic { public Color colour; public int x, y, width, height; public void doGraphic (java.awt.Graphics g, java.awt.Component c) { g.setColor (colour); g.fillOval (x, y, width, height); } } private final int range (int n) { // returns a random integer in the range [0, n - 1] int i = random.nextInt (); // needed since random.nextInt () not in JDK1.1 :-( if (i < 0) { if (i == Integer.MIN_VALUE) { // guard against minint ! i = 42; } else { i = -i; } } return i % n; } private final int delta (int n) { // returns a random integer in the range [-n, n] excluding 0 int i = range (2*n) - n; if (i == 0) i = n; return i; } final CSTimer tim = new CSTimer (); private final void countdown (final long seconds) { final long interval = 250; // milli-seconds for (int t = 0; t < seconds; t += interval) { tim.sleep (interval); toControl.write (null); // get permission to continue ... } } public void run () { // System.out.println ("Ball " + id + " running ..."); final Dimension graphicsDim = (Dimension) fromControl.read (); final long seed = id + ((Long) fromControl.read ()).longValue (); this.random = new Random (seed); // System.out.println ("Ball " + id + ": " + graphicsDim); // System.out.println ("Ball " + id + ": seed = " + seed); final int displaySlot = displayList.extend (GraphicsCommand.NULL); // System.out.println ("Ball " + id + ": displaySlot = " + displaySlot); Graphic newGraphic = new Graphic (); Graphic oldGraphic = new Graphic (); GraphicsCommand newCommand = new GraphicsCommand.General (newGraphic); GraphicsCommand oldCommand = new GraphicsCommand.General (oldGraphic); final Info info = new Info (); // System.out.println ("PongBall " + id + ": priority = " + PriParallel.getPriority ()); PriParallel.setPriority (Thread.MAX_PRIORITY); // System.out.println ("PongBall " + id + ": priority = " + PriParallel.getPriority ()); final long second = 1000; // JCSP Timer units are milliseconds long interval = (long) (((float) second)/((float) speed) + 0.5); // System.out.println ("Ball " + id + ": interval = " + interval); final long blackout = 5*second; while (true) { // initialise data for new ball ... int deltaX = delta (10); int deltaY = delta (10); info.zing = (deltaX*deltaX) + (deltaY*deltaY); newGraphic.colour = new Color (random.nextInt ()); newGraphic.width = range (30) + 10; newGraphic.height = range (30) + 10; final int min_x = PongPaddle.WIDTH; final int max_x = graphicsDim.width - (PongPaddle.WIDTH + newGraphic.width); final int min_y = 0; final int max_y = graphicsDim.height - newGraphic.height; // newGraphic.x = range (max_x - min_x) + min_x; // serve from anywhere newGraphic.x = (deltaX > 0) ? min_x : max_x; // serve from the baseline newGraphic.y = range (max_y); oldGraphic.colour = newGraphic.colour; oldGraphic.width = newGraphic.width; oldGraphic.height = newGraphic.height; // System.out.println ("Ball " + id + ": initialX,Y = " + newGraphic.x + ", " + newGraphic.y); // System.out.println ("Ball " + id + ": initialW,H = " + newGraphic.width + ", " + newGraphic.height); // System.out.println ("Ball " + id + ": (deltaX, deltaY) = (" + deltaX + ", " + deltaY + ")"); countdown (id*second); // bring the balls up one by one // System.out.println ("Ball " + id + ": alive"); int countdown = life; long timeout; // timeouts will drift ... but never mind ... // long timeout = tim.read (); // timeouts won't drift ... not wanted here ... while (countdown > 0) { timeout = tim.read () + interval; // timeouts will drift ... but never mind ... // timeout += interval; // timeouts won't drift ... not wanted here ... toControl.write (null); // get permission to continue (i.e. we're not frozen) displayList.change (newCommand, displaySlot); final Graphic tmpA = oldGraphic; oldGraphic = newGraphic; newGraphic = tmpA; final GraphicsCommand tmpB = oldCommand; oldCommand = newCommand; newCommand = tmpB; int x = oldGraphic.x; int y = oldGraphic.y; if ((y < 0) || (y > max_y)) { deltaY = -deltaY; } if (x < min_x) { info.y = y + oldGraphic.height/2; toLeftPaddle.write (info); if (fromLeftPaddle.read () == PongPaddle.HIT) { deltaX = -deltaX; } else { break; } } else if (x > max_x) { info.y = y + oldGraphic.height/2; toRightPaddle.write (info); if (fromRightPaddle.read () == PongPaddle.HIT) { deltaX = -deltaX; } else { break; } } newGraphic.x = x + deltaX; newGraphic.y = y + deltaY; countdown--; tim.after (timeout); } // System.out.println ("Ball " + id + ": dead"); displayList.change (GraphicsCommand.NULL, displaySlot); dead.sync (); // wait for all the other balls to die countdown (blackout); // blackout for 5 seconds ... } } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongControl.java0000644000000000000000000001443011113056662017535 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.util.*; import java.awt.*; import java.awt.event.*; public class PongControl implements CSProcess { private final ChannelOutput[] toBalls; private final AltingChannelInput fromBalls; private final ChannelOutput toFlasher; private final ChannelOutput toLeftPaddle; private final ChannelOutput toRightPaddle; private final ChannelOutput freezeConfigure; private final AltingChannelInput freezeChannel; private final ChannelOutput startConfigure; private final AltingChannelInput startChannel; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; public PongControl (final ChannelOutput[] toBalls, final AltingChannelInput fromBalls, final ChannelOutput toFlasher, final ChannelOutput toLeftPaddle, final ChannelOutput toRightPaddle, final ChannelOutput freezeConfigure, final AltingChannelInput freezeChannel, final ChannelOutput startConfigure, final AltingChannelInput startChannel, final ChannelOutput toGraphics, final ChannelInput fromGraphics) { this.toBalls = toBalls; this.fromBalls = fromBalls; this.toFlasher = toFlasher; this.toLeftPaddle = toLeftPaddle; this.toRightPaddle = toRightPaddle; this.freezeConfigure = freezeConfigure; this.freezeChannel = freezeChannel; this.startConfigure = startConfigure; this.startChannel = startChannel; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; } public void run() { System.out.println ("PongControl running ..."); toGraphics.write (GraphicsProtocol.GET_DIMENSION); final Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("PongControl: graphics dimension = " + graphicsDim); toFlasher.write (null); // wait for flasher to grab display slot 0 ... toLeftPaddle.write (graphicsDim); toLeftPaddle.write (null); toRightPaddle.write (graphicsDim); toRightPaddle.write (null); final CSTimer tim = new CSTimer (); final long seed = tim.read (); for (int i = 0; i < toBalls.length; i++) { toBalls[i].write (graphicsDim); toBalls[i].write (new Long (seed)); } PriParallel.setPriority (Thread.MAX_PRIORITY); boolean running = true; boolean frozen = true; freezeConfigure.write ("Start the game"); startConfigure.write ("New game"); final Alternative alt = new Alternative (new Guard[] {freezeChannel, startChannel, fromBalls}); final int FREEZE = 0; final int RESTART = 1; final int BALLS = 2; final boolean[] preCondition = {true, frozen, !frozen}; while (running) { switch (alt.priSelect (preCondition)) { case FREEZE: freezeChannel.read (); if (frozen) { frozen = false; preCondition[BALLS] = true; preCondition[RESTART] = false; startConfigure.write (Boolean.FALSE); startConfigure.write ("New game"); freezeConfigure.write ("FREEZE"); } else { frozen = true; preCondition[BALLS] = false; preCondition[RESTART] = true; startConfigure.write ("NEW GAME"); startConfigure.write (Boolean.TRUE); freezeConfigure.write ("RELEASE"); } toGraphics.write (GraphicsProtocol.REQUEST_FOCUS); fromGraphics.read (); break; case RESTART: startChannel.read (); frozen = false; preCondition[BALLS] = true; preCondition[RESTART] = false; startConfigure.write (Boolean.FALSE); startConfigure.write ("New game"); toLeftPaddle.write (null); toRightPaddle.write (null); freezeConfigure.write ("FREEZE"); toGraphics.write (GraphicsProtocol.REQUEST_FOCUS); fromGraphics.read (); break; case BALLS: fromBalls.read (); // just accept synchronisation from ball break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongFlasher.java0000644000000000000000000001144511113056662017504 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.util.*; import java.awt.*; public class PongFlasher implements CSProcess { private final ChannelInput fromControl; private final AltingChannelInputInt trigger; private final DisplayList displayList; public PongFlasher (final ChannelInput fromControl, final AltingChannelInputInt trigger, final DisplayList displayList) { this.fromControl = fromControl; this.trigger = trigger; this.displayList = displayList; } private final static class Graphic implements GraphicsCommand.Graphic { public Color colour= Color.black; public void doGraphic (java.awt.Graphics g, java.awt.Component c) { Dimension dim = c.getSize(); g.setColor (colour); g.fillRect (0, 0, dim.width, dim.height); } } public void run() { Graphic oldGraphic = new Graphic (); Graphic newGraphic = new Graphic (); GraphicsCommand oldCommand = new GraphicsCommand.General (oldGraphic); GraphicsCommand newCommand = new GraphicsCommand.General (newGraphic); displayList.set (newCommand); final Random random = new Random (); System.out.println ("Flasher running ..."); fromControl.read (); // let control process continue (and let the balls pick displaylist slots) final CSTimer tim = new CSTimer (); final Thread me = Thread.currentThread (); me.setPriority (Thread.MAX_PRIORITY); final long second = 1000; // JCSP Timer units are milliseconds long interval = -1; // negative ==> not flashing final Alternative alt = new Alternative (new Guard[] {trigger, tim}); final boolean[] preCondition = {true, interval >= 0}; final int TRIGGER = 0; final int TIMER = 1; long timeout = 0; boolean mousePresent = false; boolean running = true; while (running) { final Graphic tmpGraphic = oldGraphic; oldGraphic = newGraphic; newGraphic = tmpGraphic; final GraphicsCommand tmpCommand = oldCommand; oldCommand = newCommand; newCommand = tmpCommand; switch (alt.priSelect (preCondition)) { case TRIGGER: interval = trigger.read (); if (interval >= 0) { timeout = tim.read () + interval; tim.setAlarm (timeout); newGraphic.colour = new Color (random.nextInt ()); preCondition[TIMER] = true; } else { newGraphic.colour = Color.black; preCondition[TIMER] = false; } break; case TIMER: timeout += interval; tim.setAlarm (timeout); newGraphic.colour = new Color (random.nextInt ()); break; } displayList.change (newCommand, 0); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongScorer.java0000644000000000000000000000605511113056662017356 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; public class PongScorer implements CSProcess { private final AltingChannelInputInt[] fromPaddle; private final ChannelOutput[] configureLabel; public PongScorer (final AltingChannelInputInt[] fromPaddle, final ChannelOutput[] configureLabel) { this.fromPaddle = fromPaddle; this.configureLabel = configureLabel; } public void run () { final Alternative alt = new Alternative (fromPaddle); int left = 0; int right = 0; configureLabel[0].write ("0"); configureLabel[1].write ("0"); while (true) { switch (alt.fairSelect ()) { case 0: final int scoreLeft = fromPaddle[0].read (); left = (scoreLeft == 0) ? 0 : left + scoreLeft; configureLabel[0].write ((new Integer (left)).toString ()); break; case 1: final int scoreRight = fromPaddle[1].read (); right = (scoreRight == 0) ? 0 : right + scoreRight; configureLabel[1].write ((new Integer (right)).toString ()); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/ns-Pong.html0000644000000000000000000000343611111407145016633 0ustar JCSP MultiPong

MultiPong

Left player controls:  A = [UP] Z = [DOWN]              Right player controls:  K = [UP] M = [DOWN]

There are 3 paddle move speeds.  Tapping [UP] from stationery starts the paddle moving upwards.  A second [UP] increases the speed and a third [UP] gets maximum speed.  Tapping [DOWN] reverses this process.  Tapping [DOWN] from stationery starts the paddle moving downwards and so on.  The paddles slowly shrink in size ... but will grow back.  Watch out for the wobbles that occasionally strike.

Scoring.  You win points for hitting balls and lose them (but not so many) for missing.  Faster moving balls carry more points (in relation to the square of the speed).  The size, shape and colour of the balls do not matter (in this version).  Can you keep your score positive?

Bad eyesight?  Then, keep the mouse pointer outside the playing area!

Keystrokes being ignored?  Sometimes keyboard focus gets lost, even though the browser window is highlighted.  Move the mouse pointer into (or out from) the playing area to force a regain of focus ... jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongMouseControl.java0000644000000000000000000000704411113056662020551 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.util.*; import java.awt.*; import java.awt.event.*; public class PongMouseControl implements CSProcess { public static final int FLASH_INTERVAL = 500; // milli-seconds public static final int FLASH_OFF = -1; private final ChannelOutputInt toFlasher; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; final private ChannelInput mouseEvent; public PongMouseControl (final ChannelOutputInt toFlasher, final ChannelOutput toGraphics, final ChannelInput fromGraphics, final ChannelInput mouseEvent) { this.toFlasher = toFlasher; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; this.mouseEvent = mouseEvent; } public void run() { // System.out.println ("PongMouseControl running ..."); PriParallel.setPriority (Thread.MAX_PRIORITY); boolean mousePresent = false; while (true) { switch (((MouseEvent) mouseEvent.read ()).getID ()) { case MouseEvent.MOUSE_ENTERED: // System.out.println ("PongMouseControl: MouseEvent.MOUSE_ENTERED"); toFlasher.write (FLASH_INTERVAL); break; case MouseEvent.MOUSE_EXITED: // System.out.println ("PongMouseControl: MouseEvent.MOUSE_EXITED"); toFlasher.write (FLASH_OFF); break; } toGraphics.write (GraphicsProtocol.REQUEST_FOCUS); fromGraphics.read (); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongNetwork.java0000644000000000000000000002243311113056662017550 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; public class PongNetwork implements CSProcess { private final ActiveCanvas activeCanvas; private final PongControl control; private final PongBall[] balls; private final PongKeyControl keyControl; private final PongPaddle leftPaddle; private final PongPaddle rightPaddle; private final PongFlasher flasher; private final PongMouseControl mouseControl; // private final FocusControl focusControl; // private final FocusControl2 focusControl2; private final PongScorer scorer; private final ActiveButton startButton; private final ActiveButton freezeButton; private final ActiveLabel[] infoLabel; public PongNetwork (final int nBalls, final int ballSpeed, final int paddleSpeed, final int life, final Container parent) { parent.setLayout (new BorderLayout ()); final DisplayList displayList = new DisplayList (); // displayList.setMinRefreshInterval (10); // System.out.println ("PongNetwork: displayList.setMinRefreshInterval (10) ..."); // channels final One2OneChannel mouseChannel = Channel.one2one (new OverWriteOldestBuffer (10)); final One2OneChannel mouseMotionChannel = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel focusChannel = Channel.one2one (new OverWriteOldestBuffer (10)); final One2OneChannel keyChannel = Channel.one2one (new OverWriteOldestBuffer (10)); final One2OneChannel[] toBalls = Channel.one2oneArray (nBalls); final Any2OneChannel fromBalls = Channel.any2one (); final One2OneChannel control2Flasher = Channel.one2one (); final One2OneChannelInt mouse2Flasher = Channel.one2oneInt (); final One2OneChannel control2LeftPaddle = Channel.one2one (); final One2OneChannel control2RightPaddle = Channel.one2one (); final One2OneChannelInt leftMove = Channel.one2oneInt (); final One2OneChannelInt rightMove = Channel.one2oneInt (); final Any2OneChannel toGraphics = Channel.any2one (); final One2OneChannel fromGraphics = Channel.one2one (); final Any2OneChannel balls2LeftPaddle = Channel.any2one (); final One2OneChannelInt leftPaddle2Balls = Channel.one2oneInt (); final Any2OneChannel balls2RightPaddle = Channel.any2one (); final One2OneChannelInt rightPaddle2Balls = Channel.one2oneInt (); final One2OneChannelInt[] toScorer = Channel.one2oneIntArray (2); final Barrier dead = new Barrier (nBalls); // processes activeCanvas = new ActiveCanvas (); // activeCanvas.addFocusEventChannel (focusChannel); activeCanvas.addKeyEventChannel (keyChannel.out()); activeCanvas.addMouseEventChannel (mouseChannel.out()); activeCanvas.setBackground (Color.black); activeCanvas.setPaintable (displayList); activeCanvas.setGraphicsChannels (toGraphics.in(), fromGraphics.out()); activeCanvas.setSize (parent.getSize ()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. System.out.println ("PongNetwork adding ActiveCanvas to the parent ..."); parent.add ("Center", activeCanvas); // buttons and menus final Panel south = new Panel (); south.setBackground (Color.green); final One2OneChannel startChannel = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel startConfigure = Channel.one2one (); startButton = new ActiveButton (startConfigure.in(), startChannel.out(), "XXXXXXXXXXXXXXXXXXXXXX"); startButton.setBackground (Color.white); startButton.setEnabled (false); south.add (startButton); south.add (new Label (" ", Label.CENTER)); // padding final One2OneChannel freezeChannel = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel freezeConfigure = Channel.one2one (); freezeButton = new ActiveButton (freezeConfigure.in(), freezeChannel.out(), "XXXXXXXXXXXXXXXXXXXXXX"); freezeButton.setBackground (Color.white); freezeButton.setEnabled (true); south.add (freezeButton); parent.add ("South", south); // labels final Panel north = new Panel (); north.setBackground (Color.green); final String[] infoTitle = {"Left", "Right"}; final String[] infoWidth = {"XXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXX"}; final One2OneChannel[] infoConfigure = Channel.one2oneArray (infoTitle.length); infoLabel = new ActiveLabel[infoTitle.length]; for (int i = 0; i < infoTitle.length; i++) { infoLabel[i] = new ActiveLabel (infoConfigure[i].in(), infoWidth[i]); infoLabel[i].setAlignment (Label.CENTER); infoLabel[i].setBackground (Color.white); north.add (new Label (infoTitle[i], Label.CENTER)); north.add (infoLabel[i]); } parent.add ("North", north); // balls balls = new PongBall[nBalls]; for (int i = 0; i < nBalls; i++) { balls[i] = new PongBall ( i, ballSpeed, life, dead, balls2LeftPaddle.out(), leftPaddle2Balls.in(), balls2RightPaddle.out(), rightPaddle2Balls.in(), toBalls[i].in(), fromBalls.out(), displayList ); } // keystrokes manager keyControl= new PongKeyControl (keyChannel.in(), leftMove.out(), rightMove.out()); // paddles leftPaddle = new PongPaddle ( true, paddleSpeed, leftMove.in(), balls2LeftPaddle.in(), leftPaddle2Balls.out(), toScorer[0].out(), control2LeftPaddle.in(), displayList ); rightPaddle = new PongPaddle ( false, paddleSpeed, rightMove.in(), balls2RightPaddle.in(), rightPaddle2Balls.out(), toScorer[1].out(), control2RightPaddle.in(), displayList ); // focusControl = new FocusControl (focusChannel, toGraphics, fromGraphics); // focusControl2 = new FocusControl2 (startChannel, toGraphics, fromGraphics); // scorer scorer = new PongScorer (Channel.getInputArray (toScorer), Channel.getOutputArray (infoConfigure)); // background flasher and its (mouse) controller flasher = new PongFlasher (control2Flasher.in(), mouse2Flasher.in(), displayList); mouseControl = new PongMouseControl (mouse2Flasher.out(), toGraphics.out(), fromGraphics.in(), mouseChannel.in()); // main game controller control = new PongControl ( Channel.getOutputArray (toBalls), fromBalls.in(), control2Flasher.out(), control2LeftPaddle.out(), control2RightPaddle.out(), freezeConfigure.out(), freezeChannel.in(), startConfigure.out(), startChannel.in(), toGraphics.out(), fromGraphics.in() ); } public void run () { System.out.println ("PongNetwork starting up ..."); new Parallel ( new CSProcess[] { activeCanvas, control, new Parallel (balls), keyControl, leftPaddle, rightPaddle, scorer, flasher, mouseControl, freezeButton, startButton, new Parallel (infoLabel), } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/pong/PongMain.java0000644000000000000000000001110411113056662016774 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import org.jcsp.demos.util.Ask; public class PongMain extends ActiveApplet { public static final int minWidth = 300; public static final int maxWidth = 1024; public static final int maxHeight = 768; public static final int minHeight = 100; public static final int minBalls = 1; public static final int maxBalls = 100; public static final int defaultBalls = 100; public static final int minSpeed = 15; public static final int maxSpeed = 100; public static final int defaultSpeed = 35; public static final int minPaddleSpeed = 15; public static final int maxPaddleSpeed = 100; public static final int defaultPaddleSpeed = 35; public static final int minLife = 5; public static final int maxLife = 100; public static final int defaultLife = 50; public void init () { final int nBalls = getAppletInt ("balls", minBalls, maxBalls, defaultBalls); final int speed = getAppletInt ("speed", minSpeed, maxSpeed, defaultSpeed); final int paddleSpeed = getAppletInt ("paddleSpeed", minPaddleSpeed, maxPaddleSpeed, defaultPaddleSpeed); final int life = getAppletInt ("life", minLife, maxLife, defaultLife); setProcess (new PongNetwork (nBalls, speed, paddleSpeed, life, this)); } public static void main (String[] args) { System.out.println ("\nPong starting ...\n"); final int width = Ask.Int ("width = ", minWidth, maxWidth); final int height = Ask.Int ("height = ", minHeight, maxHeight); System.out.println (); final int nBalls = Ask.Int ("balls = ", minBalls, maxBalls); final int speed = Ask.Int ("speed (ball movements per second) = ", minSpeed, maxSpeed); final int paddleSpeed = Ask.Int ("paddleSpeed (paddle movements per second) = ", minPaddleSpeed, maxPaddleSpeed); final int life = Ask.Int ("life (seconds per ball) = ", minLife, maxLife); System.out.println (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame ("Multi Pong"); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final PongNetwork pongNetwork = new PongNetwork (nBalls, speed, paddleSpeed, life, activeFrame); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, pongNetwork } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/0000755000000000000000000000000011410045042015261 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/FrameDeMux.java0000644000000000000000000000522211111352066020127 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author Quickstone Technologies Limited */ class FrameDeMux implements CSProcess { private final ChannelInput in; private final ChannelOutput[] out; public FrameDeMux (final ChannelInput in, final ChannelOutput[] out) { this.in = in; this.out = out; } public void run () { System.out.println ("Frame DeMux: started"); while (true) { //System.out.println ("Frame DeMux: waiting for data"); ResultPacket rp = (ResultPacket)in.read (); //System.out.println ("Frame DeMux: frame " + rp.frame + " data received"); out[rp.frame % out.length].write (rp); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/ResultPacket.java0000644000000000000000000001470211111352066020543 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.io.*; import java.util.*; /** * @author Quickstone Technologies Limited */ class ResultPacket implements Externalizable { public int frame; public int offset, step; public byte[] color; private int expandedSize; public ResultPacket () { } private static final Object sync = new Object (); private static Vector v1 = new Vector (), v2 = new Vector (); private static byte[] alloc (int len, boolean scratch) { synchronized (sync) { final Vector v = scratch ? v1 : v2; if (v.size () > 0) { byte[] b = (byte[])v.remove (v.size () - 1); if (b.length != len) { //System.out.println ("ResultPacket: realloc memory (" + len + ")"); return new byte[len]; } else { //System.out.println ("ResultPacket: pooled memory (" + len + ")"); return b; } } else { //System.out.println ("ResultPacket: alloc memory (" + len + ")"); return new byte[len]; } } } private static void unalloc (byte[] b, boolean scratch) { synchronized (sync) { //System.out.println ("ResultPacket: freed memory (" + b.length + ")"); (scratch ? v1 : v2).addElement (b); } } private void writeInt (ObjectOutput out, int i) throws IOException { out.write ((byte)(i >> 24)); out.write ((byte)(i >> 16)); out.write ((byte)(i >> 8)); out.write ((byte)i); } private int readInt (ObjectInput in) throws IOException { int a = (in.read () << 24) & 0xFF000000; a |= (in.read () << 16) & 0xFF0000; a |= (in.read () << 8) & 0xFF00; return a | (in.read () & 0xFF); } public void writeExternal (ObjectOutput out) { try { writeInt (out, frame); writeInt (out, offset); writeInt (out, step); writeInt (out, color.length); byte[] buffer = alloc (((color.length + 127) >> 7) * 129, true); int bufptr = 0; int mark = 0; for (int i = 0; i < color.length - 3; i++) { byte ref = color[i]; if ((ref == color[i + 1]) && (ref == color[i + 2])) { // A block starts at I if (mark != i) { // Write out any raw data buffer[bufptr++] = (byte)((i - mark) - 1); while (mark < i) { buffer[bufptr++] = color[mark++]; } mark = i; } // Determine extent of block while ((i < color.length) && (color[i] == ref) && (i - mark < 127)) i++; // Write block buffer[bufptr++] = (byte)((i - mark) | 0x80); buffer[bufptr++] = ref; // Update the reference marker mark = i; // Decrement I because it will increment at the end of the loop i--; } else { // Check the raw data block is not overlength if (i - mark == 128) { // Write out the raw data buffer[bufptr++] = (byte)((i - mark) - 1); while (mark < i) { buffer[bufptr++] = color[mark++]; } mark = i; } } } // Tail end of the data if (mark != color.length) { buffer[bufptr++] = (byte)((color.length - mark) - 1); while (mark < color.length) { buffer[bufptr++] = color[mark++]; } } writeInt (out, bufptr); out.write (buffer, 0, bufptr); unalloc (buffer, true); //System.out.println ("Compression = " + ((bufptr * 100) / color.length) + "%"); } catch (Exception e) { System.err.println (e); //System.exit (1); } } public void readExternal (ObjectInput in) { try { frame = readInt (in); offset = readInt (in); step = readInt (in); expandedSize = readInt (in); color = alloc (((expandedSize + 127) >> 7) * 129, true); final int compressedSize = readInt (in); for (int i = 0; i < compressedSize; i++) { color[i] = (byte)in.read (); } } catch (Exception e) { System.err.println (e); //System.exit (1); } } public void expand () { final byte[] source = color; color = alloc (expandedSize, false); for (int i = 0, ptr = 0; i < expandedSize; ) { int r = source[ptr++] & 0xFF; if ((r & 0x80) == 0) { // Raw block for (int j = 0; j <= r; j++) { color[i++] = source[ptr++]; } } else { // Constant block r &= 0x7F; byte b = source[ptr++]; for (int j = 0; j < r; j++) { color[i++] = b; } } } unalloc (source, true); } public void discard () { unalloc (color, false); } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/clouds.jpg0000644000000000000000000006754110520670125017300 0ustar ÿØÿàJFIFHHÿí ¤Photoshop 3.08BIMí ResolutionHH8BIM FX Global Lighting Anglex8BIMó Print Flags 8BIM Copyright Flag8BIM'Japanese Print Flags 8BIMõColor Halftone SettingsH/fflff/ff¡™š2Z5-8BIMøColor Transfer Settingspÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè8BIMGuides@@8BIM URL overrides8BIMSlicesmîClouds®Ã8BIMICC Untagged Flag8BIMLayer ID Generator Base8BIM New Windows Thumbnail¢pTPn@†ÿØÿàJFIFHHÿîAdobed€ÿÛ„            ÿÀTp"ÿÝÿÄ?   3!1AQa"q2‘¡±B#$RÁb34r‚ÑC%’Sðáñcs5¢²ƒ&D“TdE£t6ÒUâeò³„ÃÓuãóF'”¤…´•ÄÔäô¥µÅÕåõVfv†–¦¶ÆÖæö7GWgw‡—§·Ç×ç÷5!1AQaq"2‘¡±B#ÁRÑð3$bár‚’CScs4ñ%¢²ƒ&5ÂÒD“T£dEU6teâò³„ÃÓuãóF”¤…´•ÄÔäô¥µÅÕåõVfv†–¦¶ÆÖæö'7GWgw‡—§·ÇÿÚ ?ëóú{œàæÄpHOÅeÙk$‘ ]^úì;LJa‡Q™h×Y!YŽsD5¥€HØ/"ÐÒ`˜WE63cD»Ë™ñZ¹}1®;™Xv|cÉg3Ö>L´Ïn~õ(È$44Äq˜š"Úgö’È:‹X5oÉtøô5Íkœ%À@)_‡Yiºg¿­Rÿ»é`¼¡s¢>%ϪÐZ'â­æâˆötóä³Ü Lñ…0"A„ƒõxy-}Lvïq…i·5Ë”ÃËôÌ9Äƺ+6õBxãÄiÇ‚¯,ôlÇ8­^‰àÄ…;eebõ7º½®2€•'u&‹ A5'…µ k²ÿv$_vù¸°ISn@:ÊÏìx-0çy!‡î;›#]B>ß}îvÕÿÐì1²êc†çÉï F®¢Þ ̹ÞîЈ̧ Òt’», ´ã˜‡¦òD@NSÆè ¯&ÀÈ&üŠök¶¹#hý⢖†Hæ€]ÊÀ;š!f³9ј|î ³70Xû74u{¸Ö6¨ý¹2{‘ÓFöEì2;.k1›v°4‚$ñÙtxýB¼—šœ6¸ ׂ…—ˆFÆË¼½IŽF¤³$ÅÅåÓÉá+õZæ–Á™ñÑ­sœÑ$ð oV¡f2Öíy¨9åÃ_š;º~KרÝwÊšZH=’v!$ºš÷4È:­ŽžæXÐÐAyG•Ьbäšlihã”ÙÆÆ›¦£«ÿÑÝû¥îhÞT[QµÂçºÞ6¼4“Ü$îœÇÕO.W}êÜ4ýžÆÜ0ÃØðˆ1ìt9£NÄ­zz[FAÜAhDÊÂk\Ö´û pÌ.‚†VåVë+aú/ÔÇåNâZIq™~ ÖE-ôœ@÷ò!g=ǃÀF>­Q!ãèÉ©­h:CÜ4Ÿ>>šØÜ!s¸Ö¸[íùµ@sX7•XêqKBÒêx9<ÙPÉ@ÀÆ4ØÑkC]áÝl— ÇJ·œIiß…Ž uN˜×Bªý®k€‚öê U‘0ZÆ?ÿÒèÝ‘î´1úƒöƒB³F6Ñ3 r¢æ Ô+æ1:4D¥^†Ëªp¦x*ù®­Á–|<V÷°1Å ò’5$Â`Šéf'¥:.˩̀¼’ªÙC‰%ƒpU·‚%v†”ñ ÙiŸêa}o…³‡”Û@i0²k,w¸@ñPm¾™šÆ¡ Cˆxª3á>Ce¥²ˆ¼íîxT>×cÉ/?LÜq“ ñMŽ"Ë(*ȧÐ-Úu׎ÅÕ1î3<©‘ê¸gUh{[1÷)lwb7©1}¤·B…¸Ž dÉÕKI·ÿÓì,ÌÇô†ÚÚr<<Õ7_Œ\a"5U$h[),!ßO±þí3.ÈHqv‚$è¸ht*å °´{ B¶×°º\ƃÒ‰™ W Os)ÊØvòÝ®ñnо_I{W¸êËh裊CQ«žü“:«í¤AP’Ÿ¢Ædñ:&”‘ fÛ\ÑE6ßaÐPQ*³kð@Ù7âPçò#â†ê@åX³0>²ÃÏg vä= ·š8’x_ÿÔÛSïæ¼1%¢\çÞîVéô¤s+çÄ”rd‹ô;$OÍ.©¿Ðo¥·g˜þJù¹%ùÃ9ù ïïôÿÃsßà©äz[[³åð^’± úµ¤ûf‰/IJ±öÄ—‰¤‘Síi/I?ÿÙ8BIM JPEG QualityÿîAdobed€ÿÛ„            ÿÀî"ÿÝ;ÿÄ?   3!1AQa"q2‘¡±B#$RÁb34r‚ÑC%’Sðáñcs5¢²ƒ&D“TdE£t6ÒUâeò³„ÃÓuãóF'”¤…´•ÄÔäô¥µÅÕåõVfv†–¦¶ÆÖæö7GWgw‡—§·Ç×ç÷5!1AQaq"2‘¡±B#ÁRÑð3$bár‚’CScs4ñ%¢²ƒ&5ÂÒD“T£dEU6teâò³„ÃÓuãóF”¤…´•ÄÔäô¥µÅÕåõVfv†–¦¶ÆÖæö'7GWgw‡—§·ÇÿÚ ?ìAÊùV[lBµÙoÍZ S«˜à@B{U×W¦ª³ÛÅH ÂÄ›”{-ÑWàꥈ…É¥)AJ”¥2iIL“BAI$¬ž|ÔTR‰ó•"¢’—&N˜„‚•)‰)%¯Š(ZS‘Q(¡[œ”»Å$’Ràžå>åÉ)œ”¤¨êóIL¥-ɧǔÉ)‘ri*%-|RS-ÇÅ-Þ%GD¾©–áâžJ†©õñ@©”¥*2GšR’’JR¡)â…&ÙÊR¢”¥J”¥*2žR¤Úòœá$/)åE:J^)åÜ(‰O¹%?ÿÐíHhá3m#ObÊ;ªÏ«]› jHðÒÙTï`Vdµ°«Ú4NŠÙ5wv@±›Œ„W)Ó§Š”"€‘i”JëG -J“„ ŠI$’R’I$¤’I%)$’I*I$’R’H'„”²IÃJ˜b* +FäÀJ# J©#+NXT˜áÝ»\TdêȈ'iD…#Y•Ø(ZRìl ½£ˆRm…º"†‡ FÑM *„!hZÅJÀw'‚°„i'„ÉËT’I •$’I!I$’JRI$’T’I$¥$’I)I$’JRI$’”’I$¥$’I)I$’JRI$’”’I"¦mõ]¥L>"Ò 7åf·ÀYͶë¹2Q_7½P¤Û¤Â¤mwe*ÞíÁFbÈ&é±òB2©Dò­´öQÈS$M¯ŸjNŽ×R€ÑI§U+‚PS¡ƒ R‚mt“nO$¤¥ £)ÁIJ)ÓJR•%tÉJpPR“é$²d’EKˆT +VL”Ÿ²JY$’TiK¤˜ò+ãÏdÚ§L’”’IŠ4¥JRšR”‘kÊyQ”¥*U²””e)J•l¥) ¤&””ÊOd¥GrpRK SÊŒ¥(R™Ê@¨Ê@¥I¶ržT%<”Š­”¥*2žPU¿ÿÑôG‰lY#ú›tKsJ”Xc!¥c ½•“¢Ôu`ªï¬ž&Ç(Û–i:ʨ‚´K¨N¬x)ØŒcÍ9¢>¸:&-DÖsPË|•¢Å3É<†6ÕØe?¦Q‹m(Ú8Pš ³éÈQôáRIÍòQ„”Å$é’R’I$”¥6‰PSj*HÖJ–ÈI¤) e›]Z# #TTš@ݘl¢W¡”6º‹“YÈ%EÌ'P ×"‡è’¹¾:$Ç8'{‹ ¹IK½Ò«=¢Uº!º³àˆ(!¨í (£YA:¡í#• ,d1JƒIOé¹%0Õ-Q=2œTA“ÂJ¤pS+4P5JJ¤Z$}( …i)€i”‹Håµ”ZJkè’“›E%)$’IJI$‘B’I$”¤’I©$’IJI$’R’I$”©O)“¤¥IG¨”êQ˜) še®P›Â›L&¼ýOì­±ÃESŒ…m )†hÁH¾QQA³4´M) ¹tò£)JT¥å>ò JR¥$Þœ8!‚èxB”ÊJÂpPK$à&N‚WI$’ Z)&ELJD*"…´òL—É?d‚¤ž„T¯4á2)d”¡D¤²bS•Š–M)ÊdVªR”’IJ”¥1L’—ù¥*$¨—%J´›“‡ ‡)‚•*ÒJyC”à¥J´’ ûM³JTC“ÊI ‚yP”¥*SÿÒôW1 €Ó(îð„æJ2×Î…'°£°‚¤‰*ªöAPp•jÆÈ” ‰À¬!®Xvh­ ©âK ZƲ Y«.iCpFÑMg²u ˜ßcguÃ2œ Òj‘¨Ä£†)8 °—ªÑ¢à‚ð¬ØÃ:(»–Ê’ÂêdgPà$r¢jpl”´G 4“ÂDBv¨X) ´L‚ïRB€œ"”Û”¥®R RòPõNSiZÿ@ð«ÈN p‘$[ Ê+ ®ÂS”d/'¤‚+L„ð›ÄBîPA ½Ô´; ØÙ(ÆZ ÂÚÒ{¢úz+-«DÎh:ío 5½>á-ºAE!AÁÄ¢)£ &ÛÂ#jq(Í %# ¡P¤ÖVQÊ`!Äš¤a"Þ覵ÒBJ!¬ö(l Ñh*&¿$ñ%¤5 5Ñ-¥X5ù%°#ÄŽ¶Âš µéʉ®âG ^ JǦ…c6ð•Ú¦2I$¥$’I)I$’JRI$’”œtMÝ ))v6™ Bo2ŠÓ¢ ¢t\•&;XCqHÕ6“mêœÚuTj²Šì%Hɺע V¹M®QÈ$ÙõTÚéUAÕ„Â[`•SHLHB“læB‰L‡•*Õ¹L8'˜µÂ5H…šRQ o6Šx™‡)!Hìœi\IävJPC€S”Ú¥Ö–S&%ªJQ 0¤S$¦;D¦p”\Q +%)’E …&”=Ú§k Ê(ª.82ÜB’Ž ‰R!EÚ"²déB(¦0˜©¦!%0I9 ‘bâ„Tʉ ÁjÀ©(D%¢%IC“îB'Ü…*Ò‚¥(;Špâ…&ÒÊ[÷%¹*H)AJP÷'Ü…*ßÿÓô˜IHŸhNZ„„Ä"KRµR4•ÍœÕZBÝ È•©À¢šîaCsU§5ìNiŠJ R “ ÜK`Ö…?JB+*¾„- 9ÖU¯‚`ÑW]A%GìẔxÔ`Óu@”Þˆà«n¬ PËO‚T>)„/âK2šT7¤\…*×%1L\›rT«]1*;’.E ›xT‰Bw)Ô‹l5óÝOqUéŽÇÒ%i&T\œéª‰rK”’Œ§$ZéÈL R’–!D©THJÔˆ„Ä"¢BpYHÈP-„HQru £˜M¹;š tEÌ<©oBÜ–ä©\Iƒ“î@Üœ<¤B¸“nO%9Kv‰´›ÿÔô |$¦”‚rÕÒ”ÉÒRÆL))íH„U"-•W(Ä&Øj!Âfº£Â[Rµ¼+5€)Bp¡ H‹´”bÝv¥i!®Z‚˜VήTí>I×¢ÚÕƒªTÙá^Є;+ÆEl¢Ç45Òšààu^W54ÑHŒdjÏdð«ÚÑ$[¶J›Ú¬rkZ[vêT C¸VŸVÑ⫸mv‰À­! †Ò“Q^Ù‚ÒAN YS(H¨/*%Oj^œ5Arõx+u^¶¢°ÀG*9/‹eŽGi•Z°¬0BŒ²ÅNl¤Úü‘@R4”Õ±kTã²päáÞj¾å â…+‰6äÅÈ[Êbâ•'‰žäÅÈeá-ÈÒ8™îKryN×%Jâf˜¥)%²7`TG(„(À”mU¢áO²ˆRì‚ÏÿÖôC¢H;§º}þjZb´…D¼ üÔ ÑV'”PU@O(ìp! iN†¤ i ƒ$’N¡i¥“Â}©á+U1…0š ª_DÝÒQ3Ù*K#n#²}Ç„ÐRBÀ¤SÁNÝ:ÑH‹g•IX (•¢šÏ QெZœ$´À9ï¦9@u2µÀ{*ï®;'‰,1i tÆŸl6Rsx’ÓóSxS,òNQµ´À€˜´„G4ø(a+U.ÄVëÇe5L tL‘\ZÑÛÂÂ0&@Í¡LÍ A0²'”¡ %¥:ÖÒÛ‹š‘$9eT)ƒ‚„‰N÷j‚I”à ËHøhŒ|r«‡„ûÂi mï$ù)O*¨|T½ro ]ÄØöŽ ò†_¹8)Â(%.éL¢ rtI %4¨¸è ID"ÒSÊ”¤£J´¡ÉÃÊ*H¢L×¢‡*á§…d‹b©%NuÑ ž)n©¥-†Ù¢mÒPƒ´”Áú Bà[36ôb‹­€ŠŒ™[`×U\ØIå3Ý:ø¨èž"´ÉžéRlJv©÷©¶ZäAb§¼¥êy¡Âž&æôƒ•1añR¸SÄÚÞÞUP\{¡:×4ò— 8›ûÊqaT[q=Ñ›`ŽPáM¶7$Jzœ BU %*.H.$”íq ˆF–¤i”@«°™GiÑ4¯‰g 0S1 ]“»$Šÿ×íÚ䋼C’V¸Z¼^)w$ª§iñB’ peˆ ”Vð Âpe¥…¸À©6šTÂi H–ª;‚”ˆMJ’JRIJI8 ÒKIJ„”Å%$Ђ˜š’„m Q!DÄ%j¤odöVP!8´†›™ ½2U§0wQ À­!ªj)eáGaNâ[Â×s¡³É[,)½"—¸P5š)µžH»5S @”€ÁFhH1M­M%u. ¤Jà„€R„¡Ô´'I$¤’I+RÅD…4Мµ„&*d&)#!@„R JpABàT U‚ËQiK%DÖ±D°£h¤;!AÍGÚ¢Zœ$´Å¬Y¢«VKHe¤§D¬”Zoh ½’¯>½U{+RƒLd¬—¦a3TF³Dá$5C!3›¢²æ <ˆDE"I$‘B’I$¤’I%)$’IJI$‘Ré’I+U.PO(ôR@eKT â…‡ºiJîPÑ9y*2ˆA\¦Õ%!¡BTˆS’‘‚Bœ1Ð[¢Œ²EM)É“ª0–äštQ:j¢¢g<%J°Ïp„7Ÿ¹D½±Ê¬(€´ÈwfçQ• Ò”§R-˜rxA%"è R-#œ|tPõåCz‰J•i…€©5Þ*¶©Ãœ•*Û‚ÐÅ^Ç‚Pˉå$@E¤k "5è >*a q–"5ò©±å¯L!x-°ö¦/ ·¨˜>J{$‘ݵ!$ ä)µéR’µ¥  ©¶e4¦6•<šÑ5#„ÈŽ ª §ÿÐëCÂpeM¤«„4‚`Sƒªˆ:))6•¥¼*í(õðšY"R³Q*\¦lBr£d\hœ?UPtΉR-°¦«À„FºP!p)ÃO(AÁH96“iAOÊr(Rm’@¦‘"¥ZЉ)(—#Hµ÷'܆©nJ“lå)CKv©‹fTHN™1!0jšP´R'7D¶è‰µ8jVªEµ(D!4#j¦ª@'< ¥ÀNé%’p˜)ÒºI'„’´' µN‘R´JIRД'I1!D…2˜„TQÂbá1 Z) ‹Q!4#h¤{Sm(°˜„­D"-•Äb£h¦³˜†X­9º ¸'ĬkXÐ[«Vƒ*»ÁRÅŠHƒB“@I­×U èŠ8 UK¶áÊ«btVÉdÉÊdõŠI$’R’I$”¤’I%)$’IJI$’R’I$”ºI’IK¦I$”¤à¦N’™…   ˜IIäV»EZQäÒÌò™Ü'¢çB“k ÉIÎCw’p IfJ‰2¢Š˜ÒNI$©EÜ)X¤™$”¤’I%)$’IJˆ¡¤’’îodàù §¡I´Óæ“I•AS`H© ’ŠÖXØ&@É%6bša\j(á ¼„@S ]F5RL‚_ÿÑéáL˜"4+¤´€+€Tà§h Z&º˜´b³¢ €¦Ç„€ÙiN|PÃÚT§²e/µL„»&&nKP­@NÓBSJ«ly§UÁR„ˆP-–¹H==<”Ú]i÷…ô äÅÉR­#¬ ·J œqN¤ZyP%6ñ %íB•iJT7„áÒ•*ÙJ˜2‡)ÁHªÒ$šS‚‚AV©Âd’¤®SBR’JT$’t²pÂA%2 Â`œ RRLŠ@h…¥hI$’R“D”’ºI$•¡bN‘©ŠhN’HbB‰„(ÂJaòNSSB*+BbŠb’¸ ¼jŽä§ÅdšÖ]ðaUߪ–%†H‰3¢MӔކS9ÓÂzÕœB­d#¸è«ÙÊ|VI )’)'¬RI$‚T’I$¥$’I)I$’JRI$’”’I$¥$’I)I$’JRI$’—ƒ”R¡"[÷)nA,÷&•É·%J¶DÊŠRšQRŠ›\+RIL㢄”’UªJb$·d’I%)$’IJI$’R’I$”¤’I2c£”V=I’…Z[mz+IU «̦I’%¶ÂˆØØD²¸iO(€P"Ji+À\$“D'PKÿÒë”´r«z…/Pø«Æ%¤$Ùj‘xTýXKÕC„õQ›oÔNUAañDm‰p$M´ÛHRõ•méÁ”ÚOgÕ”·y §:!I'¨Sî%¸„íz\*âl‡hœ< ‡HM&SH+„›AÊ@ª¡è‚ØHÖ˜•ä?Tä©V—riBÜTƒ’¥[5 ¢5R)˜b}³Â`äåÞ%\'¨nN‘ f S¡îR¦ÒB@RL®˜')’RéÓ'AKŽöL¤¦C„á0N) ¤”¤‚WI2I)E4'”¤$…$’P’T’I$¥&!:ARÅ2’hI J‰S)ˆILîÑ1E iFzÓâ¶M{ =¤h‰B°) i»R¡Â°kAÌ<„5ÞPOtk„*î:B’+$ÀêJd€:¥ªzÚRI঄¤’I©$’IJI$’R’I$”¤’I%)$’IJI$’R’I$”¤’I)$’IJI$’R’I$¤’I%)$’IJI$’R’I$”¤’I%)$’IJI$’R’I$”¥6@B(JÐ 5zB®¨­zax!¼×航6ݪ3A&ó]§(ƒUJ§Ìj®TA 9 eׄ¡4Sì ¶EÿÓßÕ1N‘Z.sšBr¢JALR! $iV¶’ˆ-…T&”É6ŨŒ|ª(­rm/3аƒ ÷(;R•*Ó2ÉÚ* ÁEc´@„‚’£¼¤J‰(Rm(|h‘±RÞ•*Ëa¶'ÕŽ(v$™®ÕF;²)°Â»‰.à“Ÿ¯)9ÒáWæÝT……W'TÍ|¸QÆÜm’Œ×*-~¢ëy” WFmÆ•$&<" Œ²¹LSÂb‚VH2`¥¹$ZPSÊJ”ê‘M¤<¡‡)…*Ù%¹4¥¹ Jû“ÊŒ¥¹*S)ID9) R™Jt?P½Aâ WH’`A ôMV’Z%¢4«RIJD¤¦%1RL‘K$(;„B¢B!iDà„æÊ°Bjp(!¬Z æ+%º¨¹‰Ö¶š†´®=€æèSĘÌ\ûšå\V\èZ6T «i•0–š1J:¢n;Fª¤J²d‹W SÓ %ŠÓ˜„§‰,1@ࢋ`î…ª(RI$’”’I$¥$’I)I$’JRI$’”’t’RÉÒI%)$’D)I$’*RI$‚–I:H)d“¤’–I:I)d“¤’–I:I)d“¦IJI$’R’I$”¤’I%)<Âd’S-åI¶ÔšSa®*@¡5¡0…ඨEz¨…[ø åNÑG0ËÜc„"é «»Ú¡#VPtÿÔßI$–‹œÁÊ1%Iܦ£’LN©'!R@)‘¥L(áÉ¥pH‰(eé·ê’m(å¥ º…6”‘D§‹ž!p+¡:¤ç!¹È€ƒ$Ìyû¤E¯G­Å" ]ÆtR.#R†43âÚ„Ú]i[d÷IÏóUË¡-Ò¤[7;Ué*¥:£JNÇb·UVV¹6A1n2À†¸ÊÏ Ee¡BbÌ$Þ)Ì*Ͱ)ú¡4…À³)“o lÕ*U¥'AjˆJ•lÇŒ©(H„à m"™îM*$è†l‚I)÷(îÕØJAèÒ›'DQ¤¤ð{¨¢¤ÉÓ$¥$’H)I$’JRI$’”’I$¥$’I)I$’Jd×Bœè„¤Ó3 síQ$“%ÿÐ×L¤ð +MÌRI$‚T’I$¥$’I)IÓ'©I%¢x¹IJHJp,siÜUG‰*åƒÅVx§ŽÌF<¤Lhœ”2Jx 4aaBS³˜PN J”šÙå0ä"Ù" ³jE¦ÆƒÊ˜hM%’´bÊÑ™TÌXcBa’DW­œ+-nŠ„f…¤Í£&¶LÂŒ–EBb¤˜„•HßÂÕ`… " jØÝ[ʽh »Û¢’%ŠA¤à†ð­:±ÅÌ:© d± Db æÂxYLbBv€M0œ‚ÆÅî2S"¤ÉÓ$¥$’H)I$’JRI$’”’I$¥$’I)I$’JRtÉ$¥Ã£DûÊŠI)ÿÑÝu~(.U릊£Øeh‰[œE#I#!$åªI$  •$¤Öh˜´„”²p›T’S B”…‡))štÁI¡+JÉ)íKhJÕLÑL€£¶RµRÉ'ØTJJTÂr‹D• Ô”¢N’JRI*a‘Ê `’r5Kj*c!"¥1IL´„ûT`öIL”Ç kŠžÂ S|Ó˜A)ÒR”ÚéPShîHlVJ!wš^F©Ë‰L¥öÍÎ*”Òœ•k(¸)¢BJX 5M·Tñ)ƈ©x(I10‘RáÆQb[!•6¼)g0&a-t§/•&²R:¨hÙ« ŽèáÂÎU…6ßµ0Åw¯ª$Pi0`èeÀµTuéOˆ%€ëÐà®4N«#‰Zu\ Bƒ$HfÇ [áD8'%1‘Dë¢PN Jd’hI.™$‰€ˆR¤&%F{¦Ü’˜Ø4U¬áX±Ó¢¯`$B|XæÔ·…NîŠíì«=fÑ:0È5õLäm¨V)c! þ’ˆRrn–² Ô) ƒ (á" •¾Hˆ,”V’£;² ™4ê­V«V5VkL’ø¶˜ÙÂ3E”2L¦˜¼.bSì)%Œ(–¢mHµ+E5ÞÉB5v![,Q,N¥¦6ÓuÔ V‰nˆO`ðNZ`溨Ò_WˆZ60x*ö2J’2c”\÷²Ÿ!\¶µ]ÍÕKÄC\‚–ÓàŽ*NfˆÚ)¬™MÍPE I$’R’I$”¤’I%)$’IJI$’R’I$”¤’I%)$’IOÿÒé ‘¹O²½k¸ Q…7‚•,ÜGš–†ŠÖh¬Š@Ò5HW¯åM% -Qt+EB®ã ˈ<ªöà‚ˆ¼¤Ñ»”Å¥°ŽËF»²`#…˜ÕªÄ+´ÖseƒaºÂšˆ€4N%@Yƒ$’IË‚D'IK¦)&) ¬|a>²–ˆ¡hPsQ¡1U4ß\ªÏ¬­'W!W²£)ñ“¢ç¹ž µÂ4 Iõªöcî2±“¢ç–•‚¾q”ŒSÄ‚Ã×`Ñ¡8¡Íå•L‚DWcTÃÈä)@Q’¹f4jÔ!M©…pl³„fªÕŸa…FYc²@¦ ‚böAL(0H^„à'„Â-S„ˆÚ¸!¼vG! ÁPZÎhã² Ó€U­#Tø–94­o*«Â·i:ª®SİH0Tá0"èNZ†Ð D°ê„ž±I$’JRI$’”’I$¥$’I)I$’JRI$’”’I$¥$’I)ÿÓêC Næ˜Äæ¥sˆ4Èsìaž¥…®ã…pЗ¥cžQãG =ÆeJ4‘Ý9¬Ç'k{!j`Ø)šÁH×”í0R´¡±€H„µ\°Ê¯cS¢´†±š%MÁGTð°©¡N4)€JD¨)A(‚²œ²šEµDµÌ(¥j¥˜Ó(Ñ …¢Õ R¤ JƒÞ ΧUd‚‹§Ú¥µ:ÑÂÁ?*Až)lÕ O ƒQT§cŠÛ¢d‰µÑ £¼&5¯†(XÈ ¼zÒã -¦J™`ìž0¦Ö‰Õ:ÖÒ0Äå ):Cq))”…ÔÃÍLR"¤Nª2’–„¡:xÚ˜Ì'Á100RRfŸ½?* "d©‚R˜¹A€PË`ù%Jb‘ ÒQ,HM1ÂNL"Ò´ù©‡«ƒ¥lœò¢çJgÁ%.B•a7dì””7*VëáS¨è­×Šl°N * "5R¢«fºd yPÜÜ¥Xf’ˆ)ä¡JµÓ—dÅ%JP™8EL€J åÓÕ0QT\A gU©Ñ@Óä­ÂbÄ–˜´>JŸ%`ðP5¢$´Å¢iòP5Áá_5¡>²8NZ`Ô)4¢=šp…´„àVI$)5ò ¦°Â$6™Ê;ª«QšäÂ"C`0‚×¢yì˜BûH (AÁM¥4…À¥ ÔS%IBE.ÈZX‘¢‚+¸CrpZP<*Ï«nÕW° T‘Y Ò±¼ªÎhV­îª<™…0 ±s€Nt©¸J†ª@°¢yÕGº‘i”ÇNSébÉ$’RI'„’²J@'Ú J`’rÒh’”’I$¥$’I)I$’JRI$’ŸÿÔîƒLZTÃO¢±l4lN*=Â0hN!UA®úÀ!5„uÍ„[䈒 B'3DÈVãD'6i×! À¬†öJx+¦™£°«>ž©ÅIÂKxZá…L1Ô{)55H•Å­?$în‰:{'  HDZÜÕd´BQ´R¦8N[à˜pQC“§kRM(-‡M+d£Š»&.¬:T½"¬z$…E%p-hG` H”€-@•ÀRVžÉ¬j†,×ÁFÇø ©'DO‰Q#$¥ áªÚ’¤)ª+[¢Vº‘úp¢B9nŠR´R-­Q-GÙÝ-’8JÕMc¢iG}}ÐH‚Š*ÔÏ )/*M%A8t"„»‚ƒ*%ɧT”¹*2œ•RQX™L’IÁiWu1 Qh•4 B”€LtR –C…&˜jˆÀ’SV#…e‡MUff¾EhŸt·!¦Þ›K­6äív¨!êm)Rm82¤ÚQa\ ‚tK“ÂhE „ú¦'”jI4êžBJR}JI)P$­TÀ… %¨;„AA kÅ6 Tö&.¤jš;«BÂ!E®ð€æê­9¨nj2¥©êŠBh Ö¶–Ú äE RµS€NxJÕLA‚§ÊbCD­K‘àQIBr!§p‚‚¬\Ù@Ú¤ E‚b¤F©ŠrÖ)$’+T£ª’g"¥µSiPJR¥'ä(9¤&k”œàBjm‚`e'& À ²˜Dk“B¤'i•0†Ñ¢#S df+BƒGÌ „®“B+Bf„F„ÂYSB’t“JêRp™8AJ)“¢JRdá1å%(¦N””À‚£%…AQcª‹Œê.NX‰î({ÔÜ\€ZY(¹Ê$è†\ŸK-‘y rbåe8 •'iPJQE§aE•U®EkôM!6”6¹zpôÒ h=HXª‡”ûÊ»‰¶, ý_P<§Þ›Âž6Ñ·EQ|§ Rx“z¥?¨PÚÕ8¯¸”òB†à˜¹ «Iê àU}ÊAÉ›O!( 9NP¢«bXœÈãU`†ôàŠ¶³Ø…´Ê²T u¬!jm(ŽN À­!€(n¬¢ÂpÔë[MbÑÝ Ñ<+d!Â6Ša³º›I8‘‘*# kZLÁ§w ·ªæ¥Œ‚PaYµpR ˜Îïÿ×í‚yP n•fšÖȦM)·%J%’J;Š[‘¤ZV¢€×"5ɤ.°× På0äÒ–R…™S M¬Ÿjotð›k©)5¥Kjx„­J¤SʉBõODO‡µܦ0ž Â4AD¦‘ ÚBEA˜­B®„Ò¼'jpABB–ö„Õ˸ ¼©¹Ã²D £2 xS*%8,(HMµMÃTÅ<-`Bb¤TJJX'L”¤‚©M)’JX”'"9 §¥ àaÁÁª1”Nå@…7ò¢S‚ÒÅ2r™9j“éŠAK$™:*RpS$…)E SIEFg#”fðšR7„VŽ›Â+{&@‘œ£±œ£±2K♡±ME&áI$’ ”œ&N*RqÂ]’ )I“$¥'I8 )hLB‘L’‘¢D¢˜Q„AA w5ÍVœÔ'5<¤5œØ/ ÛÚ‚æ'‚ÄCXÊŠ3š†àž–4¤TIN¥¶¾å6½Ú%¸¥J¶Èzpò«´”F¹À§O½r}Å6“iƒŠÔ kª#N¨R­0 m0„ }КBàS‡‹=D‹ÒáOBð¢^†\KÑáW]êAê¾ôáå.q6ƒÔè,N,(p§‰¶^ÜôT¨›¥q$.H-êAéR-™†ö©ÊÊ!Ф Šžœ­ºLç„aG~Š%ép«‰žï¤¡nÕ8&e8… ¶1 ËL(ÖíB<‚ ëkXÉ&¿pVì„ÂuèªÿÐëå-Ê0™[¦“=É‹” ¡Gt¢’oO½r[’¥6äF½UDcÐ! ¶Úå0Uv¸¢µÉ„2D§aF*Í:£&¼Á$ äûÐ¥Ö‘)PO(RAdJN”$„nC’ŽæÊhDŒ þÊ$BZ'-L¥¸*ÁФ,òM1\ cpN ¯½8°!›lJ‰(bÀŸp(Ò­‘*%¹EÏ’¤Zœ†JNr‰pNi*%D”‹‚i¡yÑE12žQ ]1JR(¡‰Q*IˆH £rÑ\^S‚Òê%IÊ%<,, `œ„ÉËiIŠt’S“šB’I2*]$’IJ£WÊ岚R7„V µ¼(È^ V£0 ´¢7DÂ"Sµ¥§E0S^ D”Zå$Z’I$ ™‚yILRRI%,»&JRR䨤”ÂIX¤”¦˜JK ð§2˜§¥®ð„ñÂ;“ÂÂ×pBpV€äð°¡pP(®nO d#riNAM´§-f qC'.)%!yH< —¤¥I´áÒQ˜åU¥¯ ¤$Îí!z‚+¸’oKxBÜo R-)rd0e"èJ•lɄ۔ ´Q&R¥Z]ÉÃO)RL–â†ÜR!u¤ÜŸxB’S…*Û™Ï@Žé¢"ƒ&OrŠw>PÜSÀXK)JP·'Ü"Ù¥* ÊDj•*Ó1ú„qnŠ˜0Sï>)¤j[.²Bïrz†ýQáOÿÑëT ’s”e]i*S¢JiF‘l‰M¸¦Ü’J¶AÊmrpHl±å®UQšäÒM¦¿HSªÁÊAé†+Ä›!Å-æPÊ[ŠT»‰²–õ[qRkŠ*ÛltÂ'd àâŽÙàð£+Âñ*%ªP B(œÕ\£¨œ Ò SxC)ö²”\˜9EÄ¥0’’o„âÀ€žQ¥Zcaî¢_à†Ji”©Vȼ¦Ô¦JR*Õ()ÒÑ%-8RhRÚM#OµN•¡ŒB‰Ñ9"e@JAEg;Dê%ʤŒ”(ˆXTÒkH`BŒ)štFÔ´&R”‘AX&!:d–¬BdéŠ6¥$’I)IÚèL’ILÇ£µÊ£ØH)„$6ZtE@ªµÆQ˜äÂ"ÚiÑL 5ÈÉ„/ f‡!‚¥2irT”u…4 &I J¥)JSnF•kÊR˜¹6ä©ÊSJ2›„€U²/„Ú¦”Ä¢‚˄ĨÊbRRÏBr›Š“ÂÂÁ Á…àVÖpB#UeÍP-Oikš‹BŽÔî$R8Q(þšƒš•¢‘wHò“‚\îˆT§ÜSn1Ê@ÊT—.0œPjv¤«g)À•œÕÌçjgM:&IV¸$‚I*Õ*R¢’HfŸpCO)Rm‘r‰rbSHJ•kM¹"¢L'¥båR)ä*”éHIJ”·%!1BÔ¼¥ªd’Rò™$‘µSÿÒéŠiM)+¡¤X’¢J“” xXT (InJ•i¥)CN 3tDcRB—ZrýTƒ•på0äÒ pòŸyBiSì…&Ùo*lq” Õ‚ ¿HŠ ÷U)¸Df¼(ˆe‰K)J€rE6—[9•&ß-衃„¡\eS‚ÒÄ´!9Ê"QÊbR!AÒž¶Ù—$ zoP€´ŸxM¼*ÆÄÞ¡GÙõÞ«ú”·wK…M¦<=à÷T½PœZ1\$ÜÜ)R-(±HZ?P‚˜ZAG…VÛ6(Êv“(Eä©VÊâ‘$†âŸÖKdi$™=béJdU®Êd’¤Û0ä·(%)R­žôÅÊ2”¥Jµå8rŠIRAJ¤‡!I¶Ó\Ÿ¨AaR@‚› á8pU·J˜r lHLJ^¥(R­‹ÚPö”R¢D"„e"Ÿº‹’¥0pCTG!§…„©$’˜E©HÚ¦„”Ïvªmv¡hœ) ¶Zå0õY¯<)´¦»‰¶×£ÖõM¯FcÔr ã*nµÒ§»EQŽ2‹½0†@R†÷ÂEú!=Ü¢"Ëz}ê¾íS‡”igRTKËÔKÑáG2åT “iÎRCÜS‡Ulå)P.M2’”áBJy)%+] {Õ}Пz›Lçè‚ç&/P{¥JÅÚ¤]¢TKå8„ªÃ¢)É•éËI[¼$tLfe<Žü§)$½¥(¢”’PšµZé¡:R’˜™EÈ)ˆHr2r©('ÜRS%S)$¥’L…¥tÉ$’”’I ¥$’I)I$’JRI$’ŸÿÕÖIJÛ+QÍX)R O.’I‚”©Bp–Ô-4Æ P¥´¥¢J`BmTʉ )‰žSk2§imELd¦©Âc> )A:P|‚’–N I1B­6‘¶U†ßSÅ-æPáOlä!:âx@ÞSnK…V›yH>PÁJáE¦õH)… ŸT©V“z‹œJdЕ*×1I2(]$’IKÊR™$”¼¦:%)’R¥ RI%2”¥Dé)yI0N’•)|Ú¤‘)“TåD)¸/0¦Ò R¦ .H‘Õ%00 e€¢@IEjl+М )$ѹÐxNXR #Tå«íÔŽÊ0¤<ÊD$†;R„𒔘LM+‚áŽBKt!Kƒm¯…!aU±¢—¬šbž&Öò âê¥êù¤"®+dIMº;¨K¥E¥Þ mÈ%ðœ:R¥ZBäÒS$J4¥OšyPãºiJ”’J@¨a”©I¤¤ä ô@ä©ÊOt·%ÈP$¥I¶R¢â)žGŠ@ ”n)’'T“ÀZJ“ÝIDð’Q!I(ILCRÚQ'JÔŠ xñS”Ä%j`G‚hS!D¢VQ*PSĤ‘I9 JRI%)$’I+$’IªRI$’”’I$¥$’I)I$’JRI$’ŸÿÖÛ S Sk”-'8EÄ‹B [JK¸PlH5¶m q#…„ARÖSÂAÒŒ¨’ʉD)ŠI$’ ´ðI<¦E I$’R’)$’–J)ÒSQ#ÁL€™ ¦§„óä¢ ”TÉ&”¢R%/)JP”¸N””¤¥&O)¤$¥&”Љ"S))OŠ€%$”ÊD§P‚5§ñIL’I$)JLJIŒ¥JdŠ@¡‚T¥*S0S‚‡)ä¡I´ „࡜9 i”„!‡x§Rx’j˜¸¨n JT®&[’ÞI’šQ¥' H( §)p£‰0'7Á3(€ˆA(K;¥)¾A„Bˆ`D'o‚N:¦R䇨e;ФÂ@ ”¾®Š.°¡¤œ8™‹ P¡÷O p…q3õJoP¨»!J´å<¸¡… JJIÊq¢€0¥2HI)Іâœ8”Ú]k¦.  Q©ÖÊ3)|ê[l Cj3@@¤+s¡!ª’A5rÐ% ãDC¢ƒ¢;"#„‚x<"µd“ÂIZi‰ Ç ôî—Á+U,’xJµRÉðe>É Z©‚g=±Ê‰JÕLxPr‘×EJpZVI$“¤’I¥’I$¤’I%)$’IJI$’R’I$”¤’I%)$’IOÿ×éöÂhEp «¶ÒXµN¤•*ØÇŠ‹‚!nŠ1â•*ѤœˆL r1 R‘’‘Âe8Q!ZVI$‘B’I$¼ÅHp˜¤¦¥)&Š”„Ò’•¯ŠIôJJP„à&JRS$¥D•RS2S(îH¹%/ª}$¥*E®ãžÂ*¶!I-”•jJ;¥)h’­RR’”¥(¥Z¤žS$¥ñID¤¤‰(SîALJJaªt”¼¤šd¥/)Jd’¥-%:I"¥IN d’S6MÅ¥Kze.âfç(JbéLJ •j”¨’¢\!‘t¦(ƒª’*T&N˜„P 0N’”S4î0’HPåLaH94® ÷JSšRS ByC9rT«e»Å"à¡)‰F”Jó$I$3L )xK„Û”K¥*Jä„ÒTO’p•!˜N¢‚EK´•0¢Ñ¢›AL+ƒ&©‚˜ &®HªH@©î=’K0TBÜ{§R’ò”(o nIK¹ª0ŸriIK™(„êšQ5^ÎPö«v »†º'‚°„a¦uO±KT‰!=jÛaFçÅ1I, I’j”’I"¥’I$”¤’I)$’IJI$’SÿÑí…HcOd`B#|•ƒ2À ßf> •ö¸%-<‰Mã+¸žk#²‰iðVí îQ­1fˆn­• ÂEa WV†æ‘Ù\-”\§‰,1k<)¹„å#sTvêŠB`ÝR´RÍgu"Í8SkL¢íÑ+U4YÕÈ*íŒ*µ­‚œ ÒrœÀM:¦<§-^BRa$”Í%)nIL $˜8%))t“JRŠ—LR”Ĥ¥å)QH ¥ÉJS$Š—”Ò”&EL¥8*¤S.É¡ S””²I$Bé$’ ‚’I$”¨JyKD”´¡:d”¨I))JHµ$’I*Ô’I’U®’IÂIY( Ó$¥@Jt´IK% $’• ©'IJçTÄhŸ„Ä¢¥“žLŠJSk) T©M)á"’•)&Ñ:*Rb1 )yJSjIKò𤒖I:I)v©(NªA¤áº!4–ò˜BàRè›D=ÉJT›f\›yQ™LJT‹eêáå¥)R­ zzê¦ ž$»ÒÞƒ¹ ä©\IQsÔw(“(Ò¸™—HCpJS)¥‰K”ðBrÕŠE9„Ĥ– Qâ!-;$¥¡(OÊPŠ˜””¡1 Z˜¤$²I$’”’I$§ÿÒD…[rTð‚›Ì2Ð öTÙs›ÉSuòxSÄÎÇ4ð«º%EÖ3jx Idâ  ‰´¢,ÒÎ$À§‰AõTšù(Ò­“˜P\ß½X‘O‰D–”á¦Tœà=A(ê´ò !3ž•+Fn…Jó.ÑÖ@ÕTy—OdèBÉ#î’I))b’I$”¤¡()ÀAKIKj[RS“–¤Š–I<% )dŠxLBT¥‚t‚H©IAI-RBÉÂ[JpRã”å0 û¡iY$å2H])L’T›^BR$•*×”¦I*U©-RN•*Ö”„´JR¤R¤%!)O¢TªY$é%J¥¥$¸IY]) ’E6ºI¥)J•kÈJBd’¥Zò’d¥%Z’I$‘etÔ’ Z—!4'I$†)D©h–‰*˜ÀM D&(©b”¦"R˜å$.’I$•$’t”´¤¤ªNŽÉ)‚!2I!–©IL yB’¼¥¹FR”¨*ÙÊc%4¥)R­BSꔥ)R–ÖT·&I*S‚šR„”ÈH’£Ç oJ”É$Ò5*MÊt€FÕK@Mµ€•ª‘í?£Éµ0jVªaòžö¥ Z©„(¸h‹ ¡$¤á )!I“¥©d”ƒT¶ˆIOÿÓëE‡ÅJU]æTŇººCLÛyHº[fвxMáO;, › $âNŠÀNi,ƒ’&€)œí©¾ÿ56]V%6ä¸l ÉÑC}¡T‹Éå! WWÚ„l3*$ÊmS©m¦mÇ‚¥ê*á:T›fû'D.S’8î™8º«jh)å)(©‰8j–©µAKè–ÓAN’•¯dÞäðR4¨r[O‚Q攕J„ÐSË’ŸB–„Ф”"¦0ž„U- ÀI<¢¥ §Ñ)L’´]2R’ RI$’”$¤¥’H¦%ªR”Ò’Je)‰L’JVà”ø&„é)y)JdÉ)”§E RS=BR()I'JQY$¡$QJI)I%)(N’!hI:H*”’I$¥$’I)I$’)X¤œ„È ¬SB‘M¢HY8O $•@I$ÒRä¨ÊrT`¤¥ÒI$”¤’I%+D´LRIK¥)’IL¥)QI%2”¥2E2£Ù8 )q÷%ø¥)ŽR¤üüÒ’R„¸N¦”´)§H-4VRÚ¦)@B×RÒl QaEÁ+E"î¢à‹ ‹ePC^OuÎd0ÝS­¶ÒTƒšÖíKjVªDAÛ¢h0‹ mÕ+U?ÿÔèeM®€‚J[ÈZÐâO¹1Pm9p@…Zóªsª:§.”©VÁÄ‚˜¸¤ãª‰Ni*%$’)ÈY(J RI$’””¦‚”ÂV ©ðŸo€L©Z©hI)JQµRÉ'Ð¥µ$,žR„ЂV)Š’‰NRÉÓ'IJI$’R’I$”¤’I%)$’IKOŠ)’IL¥<¨'” ™$£)å%Zú$šR”TºI¥4 TÊR•I%[)JTS ¦D¦”É$¥å8*)"¦r™E$T¹I2I)’bšRIKÊd“$¥ÒL¤¥$’b’—M)$’”’I$¥$’I)I$ )t“ÂP’•' %Ú; ¥õì¤R‘š4M&—h…eHVU†±L0&™'…¬+*[VEa1¨&ÚDP@ @M‘昵+NÌH„É)hMÊEÊ;‚JÑ @M¼' QU„o¬¨ Õ [S­m!Ú@NŠe¥2VªFàeKM¤©mQòJÕOÿÕÜ%1Õ9L´œÕ-Ò¢„©VȺB`Te)J‚¬®ãªI DÊJXðÕ$ã@ŠI „§•&°” H a8Tœ0Ì&ñ.áDR€Šæ•´RÚD'iÚd¦NÑMê­CX=•<µÊí6µÜ•…lÉ{£uÏ ¤«Ž,! N‰ ž©1£X3ɵÂ7¦Ð”»(GT,¬·B§é„H¥ ¼KøQ6°9³Ù4L$X{¸•ÂÔ}A3qÇuhÖgU/M4p4ß@”™AžÍ)@ÒãWN‘«HDsãS d-46kº‰Cv*¼Ö‚%3á¡"`çb ¾’†é@µ¤”ñ"ÆbÓØ¢[¢²*—AIôÂw)«´¦ÕÍ<(ë[L$§©µ…"Ç%já`Ta¶S­Å4©¢RR’JREJI$’R’I4 ¥ÒM)JV¥ÒM)­K¤’I!IJI$¥å)L’)^S$”¤…$”¥()tÉJR•%I$’JRI$’”’I%jRI$’””¤S"¥JP’t”¤’I%-)$’JRI$’”’I$¥$’d”ºpNJ\$’HZ À÷$o(”‘š4Bo(€è˜W‚˜"7U\9®L!xLOE¥< •¨¤˜¥ª‘8¡’‹`„N NŒå ÉžuQ”ðÉg¹8qC•)F•iXôfžê«N¨Ív‰¤.+ˆBŸrrå{ ”„¡È”·è¡ÞQ¤[ÿÖÛ%7)r— MÍYÆŽ‰Hh’—Qr’b%0>Sm)ƇTT¹ìœ QSj@.¬VÝ;£Ôa4¯(¯D^Šlp…- Ž×ÓTŽÊ’¬XØÕÇäˆ* !saEÚ¨'†2¥6=Íî ˜¢B)Å®<”z*›Qjt&Ê:.tAÑ ÖírAÒÔ"Ââ£×VN-‹Á(Í2¨í-rµU#˜HDz„»¤/0´!=Òt@ypL›âÖ„…€•D=Ä¢´“‘ŽŠm—¨9ò£6‚ë+JŒB( ¤ªb×B™;š R 6«[ÓQs3H<§-iJÕA«·i”Îi"U“Ù/OH„D–˜´^© ¤«Ž¨x(C¸G‰ ¥öq ÈhQt%Ä®•´ê«9«P´8A ¥´d' -”Zd%Mí ¨AñR†*XµGÔ\<”²b”¤RR“'LR’I$¤’I%):d‘RòžTRIL’M)å%)$’EJI$’R’I$”±I:hAJ”¥:b’•)Jd’Bò’dé)I’©t’I$©2tÉ)I$’JRI$’”’I$¥$’I)IÁLILÒ H †DèLŽP+’9Pjpa4„‚Ì PåH AL×¢*ú©5é¤.l)Ì!§/B”§P9E.PÉQŠ$ÖpÕ òŠþPˆR€ÆT yQ”¥$º›l!Ê@„\ mà¦.j¥¢mØe!)QM)Ô‹ÿ×ÙHj†ZŽjDÝÔyS@©E$£ºD ¥j”%ÊQ¥i\ TáEºê¤U©¥ 80‚Al±ÈÊ«\Š×„‚—”ŽTËÔR (J‚#¹P„𰬙Jtm 5M‡Uà%Ñ][u?D@ñ¢ªÓ¬|¨Îìƒe[ʃNº)¹¡ÉšÝRRP4QsTÁH¡ÕHö¢4Á ”û¡.‰ äò®¦)¤.&ä‰P˜O2›IµÒLœp•*× Be39SÛÝ…ƉOŠIˆî‚å*Š„ûA ¶J›š@„­TÇÓ…ÖV‘iÚ— mʺ£*¹ª­”—]ô©Dôc0¦ƒ›|«†©á Ôœ&°Å¬æ& ”}…Clrœ$²‘–¦D0š4N»QF’‘Ñ2 Y8I£U8‚S"™ÍILO’JY)N’JP)Ó$ˆRé&”¥.’iN’”’I$¥&)$’’I$¥“„’IJH'<$R’I$’¤ÉÒIK$’I)I$’JRI$’”’I$¥$I%*uO)$’•¹8)“ T‡)„„x%IJˆ,ŠròS) ¥.P܆\SJT›NJ%W’œ<„¸QÄ™Î!D»D2âTe )DÚœuPqR%@”ð´¬’I"…€)õI$”¾©nL’KîM¹$KÿÐ×J€¤Ó·5`!:E?$ ±NÕêa®¤å2I$’R¥.S’Rà˜rêŸr›M)JryJ‚m‘Mµ!ÂpN‹@P(…D„‚X)˜&”m3j˜(m*@¦•À¤’¦Ä TØPJDê¤ J\èšS£))(*R„ ˜@¤`é mPhD «‚ð— $PM.¤J€RjJ ”h¢Âjõ)4H ¡I†4@¨+Ó’—¢ªPšI\B*Žèh„ä$IÜÁʯkAV«aÕ>,rC±¡ Ì”WTC‚1„Ö„ú¥[ (èˆ%! êÐŽ‹BÊ©c!I°„¤J@'ZÀ O a©  IPs”Þ†S‚”ðTƒgU U#)'p„É)$’NRÉ'I%,žRI%*R”’IJI$’R’I2H\„’I%/2˜$ )t’I$©$’IK$‘L’—I$’R’I$”¤’I%)$’IJ”ò™$”ºI¥:J^Sî*)$«d]=¡-ß%Ħ©œù¦•JQ ¶RSÏš„¥))!r‰1棪I!yL’I)d’I+R’I$­JI$’R’I$ÿÿÑÚˆN”BR´œÚT')N’˜”¤©Å$¯2’‹y….èR™„“žRRÅ$’IL{§M ÂJ]8LžRS0S¨¤8M!p]1 ÀH¤˜Âb¥.R*X ©B MN™§U.P¤¨)… •)nS†§‰R¥,˜ ‚˜€¸ `(´)„Ò¸á(N”wM]LNѪsÊ“Z’@^¡  •¦Ð™¢TÀ„ H … 0˜Wˆ£Â$h [:¢¤åÂeZ¹W%>%d;•R}€'X¤±7„ÇB™ŽÑ3Œ¢ _rØŠ¢äm cZv² ÑâQ´R"aD’Q½4ƹ‚Õt¦ FuE0l'XG S[¢rÍTÚÈÑ \gµˆ*ËÚ‚æÎ½ÓYLK„“¤’I$©$’AJI$‘R’I$”¤’I%)$’I I$€””¤éBI%I$’JX¦N’JRI$’”’I$¥$’I)I$’JRI$‚”’I$¥$’I)I“¦IJI$’R“¦I%.’d’Bé’I%)$’A*I$’R’I$”¤’I%?ÿÒÚ‚R-…4Ç…¤ç1:MH¤‚¤“$’­GMT¥1Ô&jE,Âu PR’N’JZ¤JR’—)“ÊI)A<¦I$†@§•©:qÂ@JKŽSºe8iR %ÌSH18b¦ )†© Ò…ªŠ0€RôÓ†%i¬¦¤ž i+€Xéž\¸R(¦!P¤8%té»)4w@©“B˜å0áM¡5p\ð’”èšWdÝÔ¼Ðm°4"†¸*Y°ù68jxY×Ú\§„'5ÜðN‰·„ í•)²™ŽS%¥O^É«™J}²¢ÍQZ’˜úa8cSÊRRÅ7§*R€Z© ­ Ì«$BpDˆ$ûSmÅÍÑíUƒÂƒDbQ Õv¦RD{PÈÕH)$ŠdTºIJf‰ªb’DJ RI“Ê*RI$’”’I$¥$’I)IÓ%))t“$’”’I$¥$’I)I$’JRI$’”’I$¥$’H)I$™.’dé)I“¦IJI$’R’I$”¤’I%)$’IJI$’R’I$”¤’I%)$’IOÿÓÝLx^’ÒsŸpjExzI-/·¤¼A$û€á!Êðô’+ßq)áÉ §Ý / I%>äR^’J}Ì'^’J}Ñ%ái$û¨N¼%$û¿`¦8^ ’O¿… ¾~I²çè0¤ÏI&©ú!ªA|ê’iÝ|v~‹I|è’I/ÑM|à’Aú8¦_9$‚_£‚_7¤‘H~’N͉ —éE1Âù¡$ ƒôÈáMœ/˜ÒM\§Ï v_0$šWéçpªÝÂù­$Fè;?BäüÕ¯ IZdzW#îa:ð´”’ÙŽ/¼1¼/IFÈýÔ‡Í|þ’J}ÿïIxI)ú¨á|ö’b_¡ _?$œûû”+ÀÒIO½»„7}á 'ElŸsw.åx’JQ³}±!Êñ4‘Sî N¼9$Õ>àõâI"ûwÜ¢W‰¤ŠŸlIxšI)öÄ—‰¤’ŸlIxšI)öÄËÅIOµ§^&’J}±%âi$§Û^&’J}±%âi$§Û^&’J}±%âi$§Û^&’ }±2ñDSíi׉¤’ŸlL¼Q$”ûZKÅIOµ¤¼Q$”ûZKÅIOµ¤¼Q$”ûZKÅIOµ¤¼Q$”ûZKÅIOµ¤¼Q$”ÿÿÙjcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/Main.java0000644000000000000000000002370411111352066017023 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.util.*; import org.jcsp.net.*; import org.jcsp.net.tcpip.*; import org.jcsp.net.cns.*; import java.awt.*; import java.net.*; import java.awt.event.*; /** * @author Quickstone Technologies Limited */ public class Main { public static final int BUFFERING = 5;//PROD:5 private static final int DEFAULT_WIDTH = 640, DEFAULT_HEIGHT = 480; public static void main (String[] args) throws Exception { // Get the command line String cnsServer = null; int width = DEFAULT_WIDTH; int height = DEFAULT_HEIGHT; boolean fullScreen = false; for (int i = 0; i < args.length; i++) { if (args[i].equals ("-width")) { width = Integer.parseInt (args[++i]); } else if (args[i].equals ("-height")) { height = Integer.parseInt (args[++i]); } else if (args[i].equals ("-fullscreen")) { fullScreen = true; } else { cnsServer = args[i]; } } if (cnsServer == null) { /*Ask.app ( "Ray Tracer", "Implements a basic ray-tracing algorithm incorporating reflection, refraction and texture mapped " + "surfaces, distributed using a farmer/worker/harvester approach. This is the farmer and harvester " + "implementation. A set of channels are registered with a CNS which one or more workers can use to " + "join the network. This approach allows workers to dynamically join (and leave) to demonstrate " + "the performance/scaleability as the network grows."); Ask.addPrompt ("CNS address"); Ask.show ();*/ NodeKey key = Node.getInstance().init( new TCPIPAddressID( InetAddress.getLocalHost().getHostAddress(), TCPIPCNSServer.DEFAULT_CNS_PORT, true)); CNS.install(key); NodeAddressID cnsAddress = Node.getInstance().getNodeID().getAddresses()[0]; CNSService.install(key, cnsAddress); } else { Node.getInstance ().init (new TCPIPNodeFactory (cnsServer)); } // Establish the NET channels final NetAltingChannelInput workers2demux = CNS.createNet2One ("org.jcsp.demos.raytrace.demux"); final NetAltingChannelInput workerJoin = CNS.createNet2One ("org.jcsp.demos.raytrace.join"); final NetAltingChannelInput workerLeave = CNS.createNet2One ("org.jcsp.demos.raytrace.leave"); System.out.println ("Main: waiting for initial worker"); NetChannelLocation ncl = (NetChannelLocation)workerJoin.read (); final NetChannelOutput[] toWorkers = new NetChannelOutput [] { NetChannelEnd.createOne2Net (ncl) }; // Widget control channels final One2OneChannel frameControl = Channel.one2one (); // Widget event channels final One2OneChannel frameEvent = Channel.one2one (new OverWritingBuffer (10)), canvasEvent = Channel.one2one (new OverWritingBuffer (10)), mouseEvent = Channel.one2one (new OverWritingBuffer (1)), keyEvent = Channel.one2one (new OverWritingBuffer (10)); // Graphics channels final Any2OneChannel toGraphics = Channel.any2one(); final One2OneChannel fromGraphics = Channel.one2one(); // FWH network final One2OneChannel farmer2harvester = Channel.one2one (), frameDemux[] = Channel.one2oneArray (BUFFERING, new InfiniteBuffer ()), ui2farmer = Channel.one2one (); // Set up the canvas final ActiveCanvas activeCanvas = new ActiveCanvas (); activeCanvas.addComponentEventChannel (canvasEvent.out ()); activeCanvas.setGraphicsChannels(toGraphics.in(), fromGraphics.out()); activeCanvas.setSize(width, height); activeCanvas.addMouseMotionEventChannel (mouseEvent.out ()); activeCanvas.addKeyEventChannel (keyEvent.out ()); // Set up the frame final ActiveFrame activeFrame = new ActiveFrame (frameControl.in (), frameEvent.out (), "Ray Tracing Demonstration"); activeFrame.add (activeCanvas); // Try and go full screen ? if (fullScreen) { final GraphicsEnvironment graphEnv = GraphicsEnvironment.getLocalGraphicsEnvironment (); final GraphicsDevice graphDev = graphEnv.getDefaultScreenDevice (); try { if (graphDev.isFullScreenSupported ()) { activeFrame.setUndecorated (true); activeFrame.pack (); activeFrame.setVisible (true); activeFrame.toFront (); graphDev.setFullScreenWindow (activeFrame); graphDev.setDisplayMode (new DisplayMode (width, height, 32, DisplayMode.REFRESH_RATE_UNKNOWN)); } } catch (Throwable e) { System.out.println ("Full screen display failed - available modes:"); DisplayMode[] dms = graphDev.getDisplayModes (); outer: for (int i = 0; i < dms.length; i++) { if (dms[i].getBitDepth () >= 24) { for (int j = 0; j < i; j++) { if ((dms[j].getWidth () == dms[i].getWidth ()) && (dms[j].getHeight () == dms[i].getHeight ()) && (dms[j].getBitDepth () == dms[i].getBitDepth ())) continue outer; } System.out.println ("\t" + dms[i].getWidth () + "x" + dms[i].getHeight () + "x" + dms[i].getBitDepth ()); } } activeFrame.dispose (); activeFrame.setUndecorated (false); } } if (!activeFrame.isDisplayable ()) { activeFrame.pack (); activeFrame.setVisible (true); activeFrame.toFront (); } // Widget event ALT final Alternative alt = new Alternative (new Guard[] { frameEvent.in (), canvasEvent.in (), mouseEvent.in (), keyEvent.in () }); final Parallel par = new Parallel (new CSProcess[] { activeCanvas, activeFrame, new CSProcess () { public void run () { while (true) { ComponentEvent e; switch (alt.select ()) { case 0 : // FRAME e = (ComponentEvent)frameEvent.in ().read (); switch (e.getID ()) { case WindowEvent.WINDOW_CLOSING : System.out.println ("AWT: closing window"); toGraphics.out ().write (null); frameControl.out ().write (null); ui2farmer.out ().write (null); return; } break; case 1 : // CANVAS e = (ComponentEvent)canvasEvent.in ().read (); switch (e.getID ()) { case ComponentEvent.COMPONENT_RESIZED : Dimension newSize = activeCanvas.getSize (); if ((newSize.getWidth () > 4) && (newSize.getHeight () > 4)) { System.out.println ("AWT: canvas resized to " + (int)newSize.getWidth () + ", " + (int)newSize.getHeight ()); ui2farmer.out ().write (new Farmer.ResizeMessage ((int)newSize.getWidth (), (int)newSize.getHeight ())); } break; } break; case 2 : // MOUSE e = (ComponentEvent)mouseEvent.in ().read (); switch (e.getID ()) { case MouseEvent.MOUSE_MOVED : ui2farmer.out ().write (e); break; } break; case 3 : // KEY e = (ComponentEvent)keyEvent.in ().read (); switch (e.getID ()) { case KeyEvent.KEY_PRESSED : ui2farmer.out ().write (e); break; } break; } } } }, new Farmer (toWorkers, farmer2harvester.out (), ui2farmer.in (), workerJoin, workerLeave), new FrameDeMux (workers2demux, Channel.getOutputArray (frameDemux)), new Harvester (Channel.getInputArray (frameDemux), farmer2harvester.in (), toGraphics.out (), fromGraphics.in ()) }); par.run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/Picasa.ini0000644000000000000000000000003210520670125017164 0ustar [Picasa] P2category=QTL jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/Sky.java0000644000000000000000000001077311111352066016707 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.awt.*; import java.awt.image.*; import java.net.*; /** * @author Quickstone Technologies Limited */ abstract class Sky { public static int width = -1, height = -1; public static int radius; public static int centre; public static int[] data; private static class Notify implements ImageObserver { public int width = -1, height = -1; private Barrier bar; public Notify (Barrier bar) { this.bar = bar; } public boolean imageUpdate (Image img, int infoFlags, int x, int y, int width, int height) { if ((infoFlags & (ERROR | ABORT)) != 0) { System.out.println ("Sky: image size error"); bar.resign (); return false; } if ((infoFlags & WIDTH) != 0) { this.width = width; } if ((infoFlags & HEIGHT) != 0) { this.height = height; } if ((this.width == -1) || (this.height == -1)) { return true; } else { bar.resign (); return false; } } } static { try { //System.out.println ("Sky: loading image"); final Toolkit tk = Toolkit.getDefaultToolkit (); final URL url = Sky.class.getClassLoader ().getResource ("com/quickstone/jcsp/demos/raytrace/clouds.jpg"); if (url == null) throw new NullPointerException (); //System.out.println (url.toString ()); final Image img = tk.getImage (url); final Barrier bar = new Barrier (2); final Notify nfy = new Notify (bar); nfy.width = width = img.getWidth (nfy); nfy.height = height = img.getHeight (nfy); if ((width == -1) || (height == -1)) { //System.out.println ("Sky: waiting for async load to complete"); bar.sync (); width = nfy.width; height = nfy.height; } if ((width == -1) || (height == -1)) { throw new Exception (); } else { //System.out.println ("Sky: texture " + width + ", " + height); data = new int[width * height]; final PixelGrabber pg = new PixelGrabber (img, 0, 0, width, height, data, 0, width); pg.grabPixels (); } } catch (Exception e) { width = 256; height = 256; data = new int[width * height]; for (int i = 0 ; i < width * height; i++) { data[i] = i; } } finally { if (width < height) { radius = width >> 1; } else { radius = height >> 1; } centre = (width >> 1) + (height >> 1) * width; //System.out.println ("Sky: ready"); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/Worker.java0000644000000000000000000002315511111352066017410 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.net.*; import org.jcsp.net.cns.*; import org.jcsp.net.tcpip.*; import org.jcsp.util.*; import org.jcsp.demos.util.*; import java.io.*; /** * @author Quickstone Technologies Limited */ public final class Worker implements CSProcess { private final ChannelInput fromFarmer; private final ChannelOutput toHarvester; private Worker (ChannelInput fromFarmer, ChannelOutput toHarvester) { this.fromFarmer = fromFarmer; this.toHarvester = toHarvester; } public final void run () { System.out.println ("Worker: started"); final ResultPacket[] results = new ResultPacket[Main.BUFFERING]; for (int i = 0; i < Main.BUFFERING; i++) results[i] = new ResultPacket (); int currentResult = 0; final Counter frameCounter = new Counter (), dataCounter = new Counter (); while (true) { final ResultPacket result = results[currentResult]; if (++currentResult >= Main.BUFFERING) currentResult = 0; // Request some work //System.out.println ("Worker: waiting for work"); final WorkPacket work = (WorkPacket)fromFarmer.read (); // Determine the result packet result.frame = work.frame; result.offset = work.offset; result.step = work.step; int workLength = work.width * (work.height / work.step) * 3; if ((result.color == null) || (result.color.length != workLength)) { System.out.println ("Worker: allocating new result block"); result.color = new byte[workLength]; } dataCounter.dataStart (); int i = 0, j = workLength / 3, k = (j << 1); final ImageDef image = work.image; final double wh = (double)work.height, ww = (double)work.width; for (int y = work.offset; y < work.height; y += work.step) { final double _y = (double)y; double left_x = (_y * (image.view_window_x4 - image.view_window_x1)) / wh + image.view_window_x1; double left_y = (_y * (image.view_window_y4 - image.view_window_y1)) / wh + image.view_window_y1; double left_z = (_y * (image.view_window_z4 - image.view_window_z1)) / wh + image.view_window_z1; final double step_x = ((_y * (image.view_window_x3 - image.view_window_x2)) / wh + image.view_window_x2 - left_x) / ww; final double step_y = ((_y * (image.view_window_y3 - image.view_window_y2)) / wh + image.view_window_y2 - left_y) / ww; final double step_z = ((_y * (image.view_window_z3 - image.view_window_z2)) / wh + image.view_window_z2 - left_z) / ww; for (int x = 0; x < work.width; x++) { // trace the ray int c = image.trace ( image.camera_x, image.camera_y, image.camera_z, left_x - image.camera_x, left_y - image.camera_y, left_z - image.camera_z, ImageDef.AMBIENT, 0); result.color[i++] = (byte)(c >> 16); result.color[j++] = (byte)(c >> 8); result.color[k++] = (byte)c; left_x += step_x; left_y += step_y; left_z += step_z; } } frameCounter.click (); dataCounter.dataEnd (workLength); // Send to harvester //System.out.println ("Worker: writing frame " + result.frame + " to harvester"); toHarvester.write (result); } } private final Object identity_sync = new Object (); private int identity_count = 0; private final class TerminatingIdentity implements CSProcess { private final ChannelInput in; private final ChannelOutput out; public TerminatingIdentity (ChannelInput in, ChannelOutput out) { this.in = in; this.out = out; } public void run () { while (true) { Object o = in.read (); if (o == null) System.exit (1); synchronized (identity_sync) { identity_count++; } out.write (o); } } } private final class FlushingIdentity implements CSProcess { private final AltingChannelInput in, flush; private final ChannelOutput out; public FlushingIdentity (AltingChannelInput in, AltingChannelInput flush, ChannelOutput out) { this.in = in; this.flush = flush; this.out = out; } public void run () { final Alternative alt = new Alternative (new Guard[] { flush, in }); while (true) { if (alt.priSelect () == 0) { flush.read (); while (true) { synchronized (identity_sync) { if (identity_count == 0) System.exit (0); System.out.println ("Worker: " + identity_count + " frame(s) left"); } Object o = in.read (); synchronized (identity_sync) { identity_count--; } out.write (o); } } else { Object o = in.read (); synchronized (identity_sync) { identity_count--; } out.write (o); } } } } public static final void main (String[] args) throws Exception { // Get the command line if (args.length != 1) { /*Ask.app ( "Ray Tracer", "Implements a basic ray-tracing algorithm incorporating reflection, refraction and texture mapped " + "surfaces, distributed using a farmer/worker/harvester approach. This is a worker node. By specifying " + "the address of a CNS server that the farmer/harvester registered with it can join an existing network." + "This demonstration shows performance/scaleability using JCSP. Workers can join and leave at any time. " + "To leave the network, press ENTER. Do not terminate the program with CTRL+C or the worker may not " + "deregister itself with the farmer and cause a deadlock."); Ask.addPrompt ("CNS address");*/ Ask.app ( "Ray Tracer", "Implements a basic ray-tracing algorithm incorporating reflection, refraction and texture mapped " + "surfaces, distributed using a farmer/worker/harvester approach. This is a worker node. By specifying " + "the address of the interface it can join an existing network." + "This demonstration shows performance/scaleability using JCSP. Workers can join and leave at any time. " + "To leave the network, press ENTER. Do not terminate the program with CTRL+C or the worker may not " + "deregister itself with the farmer and cause a deadlock."); Ask.addPrompt ("Server address"); Ask.show (); Node.getInstance ().init (new TCPIPNodeFactory (Ask.readStr ("Server address"))); } else { Node.getInstance ().init (new TCPIPNodeFactory (args[0])); } // Establish the NET connections final NetChannelOutput toHarvester = CNS.createOne2Net ("org.jcsp.demos.raytrace.demux"); final NetChannelOutput joinNetwork = CNS.createOne2Net ("org.jcsp.demos.raytrace.join"); final NetChannelOutput leaveNetwork = CNS.createOne2Net ("org.jcsp.demos.raytrace.leave"); final NetChannelInput fromFarmer = NetChannelEnd.createNet2One (); System.out.println ("Worker: joining network"); joinNetwork.write (fromFarmer.getChannelLocation ()); final One2OneChannel farmer2worker = Channel.one2one (new InfiniteBuffer ()), worker2harvester = Channel.one2one (new InfiniteBuffer ()), flushSignal = Channel.one2one (); Worker w = new Worker (farmer2worker.in (), worker2harvester.out ()); new Parallel ( new CSProcess[] { w.new TerminatingIdentity (fromFarmer, farmer2worker.out ()), w, w.new FlushingIdentity (worker2harvester.in (), flushSignal.in (), toHarvester), new CSProcess () { public void run () { try { System.in.read (); } catch (IOException e) { } System.out.println ("Worker: leaving network"); leaveNetwork.write (fromFarmer.getChannelLocation ()); System.out.println ("Worker: flushing outstanding packets"); flushSignal.out ().write (null); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/ImagePacket.java0000644000000000000000000000424611111352066020311 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author Quickstone Technologies Limited */ class ImagePacket { public int frame; public int width, height; public int numWorkers; } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/WorkerConst.java0000644000000000000000000002003011111352066020404 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.net.*; import org.jcsp.net.cns.*; import org.jcsp.net.tcpip.*; import org.jcsp.util.*; import org.jcsp.demos.util.*; import java.util.Random; import java.io.*; /** * @author Quickstone Technologies Limited */ public final class WorkerConst implements CSProcess { private final ChannelInput fromFarmer; private final ChannelOutput toHarvester; private WorkerConst (ChannelInput fromFarmer, ChannelOutput toHarvester) { this.fromFarmer = fromFarmer; this.toHarvester = toHarvester; } public final void run () { System.out.println ("Worker: started"); final ResultPacket[] results = new ResultPacket[Main.BUFFERING]; final Counter frameCounter = new Counter(), dataCounter = new Counter (); for (int i = 0; i < Main.BUFFERING; i++) results[i] = new ResultPacket (); int currentResult = 0; final int c = new Random ().nextInt (); while (true) { final ResultPacket result = results[currentResult]; if (++currentResult >= Main.BUFFERING) currentResult = 0; // Request some work //System.out.println ("Worker: waiting for work"); final WorkPacket work = (WorkPacket)fromFarmer.read (); // Determine the result packet result.frame = work.frame; result.offset = work.offset; result.step = work.step; int workLength = work.width * (work.height / work.step) * 3; if ((result.color == null) || (result.color.length != workLength)) { System.out.println ("Worker: allocating new result block"); result.color = new byte[workLength]; } dataCounter.dataStart (); int i = 0, j = workLength / 3, k = (j << 1); for (int y = work.offset; y < work.height; y += work.step) { for (int x = 0; x < work.width; x++) { result.color[i++] = (byte)(c >> 16); result.color[j++] = (byte)(c >> 8); result.color[k++] = (byte)c; } } frameCounter.click (); dataCounter.dataEnd (workLength); // Send to harvester //System.out.println ("Worker: writing frame " + result.frame + " to harvester"); toHarvester.write (result); } } private final Object identity_sync = new Object (); private int identity_count = 0; private final class TerminatingIdentity implements CSProcess { private final ChannelInput in; private final ChannelOutput out; public TerminatingIdentity (ChannelInput in, ChannelOutput out) { this.in = in; this.out = out; } public void run () { while (true) { Object o = in.read (); if (o == null) System.exit (1); synchronized (identity_sync) { identity_count++; } out.write (o); } } } private final class FlushingIdentity implements CSProcess { private final AltingChannelInput in, flush; private final ChannelOutput out; public FlushingIdentity (AltingChannelInput in, AltingChannelInput flush, ChannelOutput out) { this.in = in; this.flush = flush; this.out = out; } public void run () { final Alternative alt = new Alternative (new Guard[] { flush, in }); while (true) { if (alt.priSelect () == 0) { flush.read (); while (true) { synchronized (identity_sync) { if (identity_count == 0) System.exit (0); System.out.println ("Worker: " + identity_count + " frame(s) left"); } Object o = in.read (); synchronized (identity_sync) { identity_count--; } out.write (o); } } else { Object o = in.read (); synchronized (identity_sync) { identity_count--; } out.write (o); } } } } public static final void main (String[] args) throws Exception { // Get the command line if (args.length != 1) { Ask.app ( "Ray Tracer", "Implements a basic ray-tracing algorithm incorporating reflection, refraction and texture mapped " + "surfaces, distributed using a farmer/worker/harvester approach. This is a worker node. By specifying " + "the address of a CNS server that the farmer/harvester registered with it can join an existing network." + "This demonstration shows performance/scaleability using JCSP. Workers can join and leave at any time. " + "To leave the network, press ENTER. Do not terminate the program with CTRL+C or the worker may not " + "deregister itself with the farmer and cause a deadlock."); Ask.addPrompt ("CNS address"); Ask.show (); Node.getInstance ().init (new TCPIPNodeFactory (Ask.readStr ("CNS address"))); } else { Node.getInstance ().init (new TCPIPNodeFactory (args[0])); } // Establish the NET connections final NetChannelEndFactory factory = new UnacknowledgedNetChannelEndFactory (); final NetChannelOutput toHarvester = factory.createOne2Net (CNS.resolve("org.jcsp.demos.raytrace.demux")); final NetChannelOutput joinNetwork = CNS.createOne2Net ("org.jcsp.demos.raytrace.join"); final NetChannelOutput leaveNetwork = CNS.createOne2Net ("org.jcsp.demos.raytrace.leave"); final NetChannelInput fromFarmer = factory.createNet2One (); System.out.println ("Worker: joining network"); joinNetwork.write (fromFarmer.getChannelLocation ()); final One2OneChannel farmer2worker = Channel.one2one (new InfiniteBuffer ()), worker2harvester = Channel.one2one (new InfiniteBuffer ()), flushSignal = Channel.one2one (); WorkerConst w = new WorkerConst (farmer2worker.in (), worker2harvester.out ()); new Parallel ( new CSProcess[] { w.new TerminatingIdentity (fromFarmer, farmer2worker.out ()), w, w.new FlushingIdentity (worker2harvester.in (), flushSignal.in (), toHarvester), new CSProcess () { public void run () { try { System.in.read (); } catch (IOException e) { } System.out.println ("Worker: leaving network"); leaveNetwork.write (fromFarmer.getChannelLocation ()); System.out.println ("Worker: flushing outstanding packets"); flushSignal.out ().write (null); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/ImageDef.java0000644000000000000000000004163711111352066017605 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.io.*; /** * @author Quickstone Technologies Limited */ final class ImageDef implements Serializable { public static final int COLOR_TRANSPARENT = -1, COLOR_MIRRORED = -2; public double[] sphere_x, sphere_y, sphere_z, sphere_r; public int[] sphere_c; public double light_x, light_y, light_z; public double floor_y; public double camera_x, camera_y, camera_z; // rays start from here public double view_window_x1, view_window_x2, view_window_x3, view_window_x4, view_window_y1, view_window_y2, view_window_y3, view_window_y4, view_window_z1, view_window_z2, view_window_z3, view_window_z4; // and sample points through here public static final int maxIterations = 10; public static final int AMBIENT = 0x808080; public static final int MINLIGHT = 0x80; public static final int LIGHTSOURCE = 0x01FFFFFF; public final int trace( final double start_x, final double start_y, final double start_z, final double vector_x, final double vector_y, final double vector_z, final int tolight, final int bounce) { final double vector_mag = vector_x * vector_x + vector_y * vector_y + vector_z * vector_z; // Check the spheres do { //pp702-703 Foley, van Dam, Feigner, Hughes double t_best = 3.4e38f; int id_best = -1; for (int i = 0; i < sphere_x.length; i++) { // fast clipping didn't help with just 6 spheres final double xd = start_x - sphere_x[i], yd = start_y - sphere_y[i], zd = start_z - sphere_z[i]; // a component is vector_mag final double b = 2 * (vector_x * xd + vector_y * yd + vector_z * zd); final double c = (xd * xd) + (yd * yd) + (zd * zd) - (sphere_r[i] * sphere_r[i]); // quadratic components of $15.17 final double rp2 = (b * b) - 4 * vector_mag * c; if (rp2 < 0) continue; // no real roots so ray doesn't touch sphere final double rp = Math.sqrt(rp2); final double t2 = (-b - rp) / (2 * vector_mag), t1 = (-b + rp) / (2 * vector_mag); double t = ((t1 < t2) && (t1 > 0)) ? t1 : t2; // closest solution to $15.17 if (t < 0) continue; // target is behind the viewer if (t < t_best) { id_best = i; t_best = t; } } if (id_best < 0) break; // no hit double x = start_x + vector_x * t_best, y = start_y + vector_y * t_best, z = start_z + vector_z * t_best; // (x, y, z) point of intersection of ray with sphere double nv_x = (x - sphere_x[id_best]) / sphere_r[id_best], nv_y = (y - sphere_y[id_best]) / sphere_r[id_best], nv_z = (z - sphere_z[id_best]) / sphere_r[id_best]; // vector normal to point of intersection switch (sphere_c[id_best]) { case ImageDef.COLOR_TRANSPARENT : { if (bounce >= maxIterations) return AMBIENT; double vl = -Math.sqrt(vector_mag); double vx = vector_x / vl, vy = vector_y / vl, vz = vector_z / vl; // normalized viewing vector double cosT = vx * nv_x + vy * nv_y + vz * nv_z; double irefr; // refractive index if (cosT > 0) { // entering the object irefr = 1.3f; } else { // leaving the object cosT = -cosT; irefr = 0.769f; nv_x = -nv_x; nv_y = -nv_y; nv_z = -nv_z; } double theta = Math.acos(cosT); double alpha = Math.sin(theta) * irefr; int illLight, illRed, illGreen, illBlue, illRefl; double rx = nv_x * 2 * cosT - vx, ry = nv_y * 2 * cosT - vy, rz = nv_z * 2 * cosT - vz; illRefl = trace(x, y, z, rx, ry, rz, AMBIENT, bounce + 1); if (alpha < 1) { // not total internal reflection alpha = Math.cos(theta + 3.14 - Math.asin(alpha)); // get the refracted light from behind the object vx = nv_x * alpha - vx; vy = nv_y * alpha - vy; vz = nv_z * alpha - vz; int illRefr = trace(x + vx, y + vy, z + vz, vx, vy, vz, AMBIENT, bounce + 1); // compose refraction and reflection components illRed = (int) (((illRefr >> 16) & 0xFF) * cosT) + (int) (((illRefl >> 16) & 0xFF) * (1 - cosT)); illGreen = (int) (((illRefr >> 8) & 0xFF) * cosT) + (int) (((illRefl >> 8) & 0xFF) * (1 - cosT)); illBlue = (int) ((illRefr & 0xFF) * cosT) + (int) ((illRefl & 0xFF) * (1 - cosT)); } else { // total internal reflection illRed = ((illRefl >> 16) & 0xFF); illGreen = ((illRefl >> 8) & 0xFF); illBlue = (illRefl & 0xFF); } // calculate the vector to a light source double lv_x = light_x - x, lv_y = light_y - y, lv_z = light_z - z, lv = Math.sqrt(lv_x * lv_x + lv_y * lv_y + lv_z * lv_z); // vector to the light from p.of.I lv_x /= lv; lv_y /= lv; lv_z /= lv; cosT = nv_x * lv_x + nv_y * lv_y + nv_z * lv_z; if (cosT < 0) { // light is behind the object (but this is transparent so ok) cosT = -cosT; } illLight = trace(x + lv_x, y + lv_y, z + lv_z, lv_x, lv_y, lv_z, LIGHTSOURCE, bounce + 1); // determine the resulting color return ( (((int) (((illLight >> 16) & 0xFF) * cosT) + (int) (illRed * (1 - cosT))) << 16) & 0xFF0000) | ((((int) (((illLight >> 8) & 0xFF) * cosT) + (int) (illGreen * (1 - cosT))) << 8) & 0xFF00) | (((int) ((illLight & 0xFF) * cosT) + (int) (illBlue * (1 - cosT))) & 0xFF); } case ImageDef.COLOR_MIRRORED : { if (bounce > maxIterations) return AMBIENT; // pp280 Hearn & Baker double vl = -Math.sqrt(vector_mag); double vx = vector_x / vl, vy = vector_y / vl, vz = vector_z / vl; // normalized viewing vector double NL = 2 * (nv_x * vx + nv_y * vy + nv_z * vz); // $14.8 vx = nv_x * NL - vx; vy = nv_y * NL - vy; vz = nv_z * NL - vz; // (vx, vy, vz) is the reflected vector // calculate the vector to a light source double lv_x = light_x - x, lv_y = light_y - y, lv_z = light_z - z, lv = Math.sqrt(lv_x * lv_x + lv_y * lv_y + lv_z * lv_z); // vector to the light from p.of.I lv_x /= lv; lv_y /= lv; lv_z /= lv; double cosT = nv_x * lv_x + nv_y * lv_y + nv_z * lv_z; final int illRefl = trace(x + vx, y + vy, z + vz, vx, vy, vz, AMBIENT, bounce + 1); if (cosT < 0) { // light is behind the object so just return the reflection return illRefl; } else { final int illLight = trace(x + lv_x, y + lv_y, z + lv_z, lv_x, lv_y, lv_z, LIGHTSOURCE, bounce + 1); // compose light and reflection return ( (((int) (((illLight >> 16) & 0xFF) * cosT) + (int) (((illRefl >> 16) & 0xFF) * (1 - cosT))) << 16) & 0xFF0000) | ((((int) (((illLight >> 8) & 0xFF) * cosT) + (int) (((illRefl >> 8) & 0xFF) * (1 - cosT))) << 8) & 0xFF00) | (((int) ((illLight & 0xFF) * cosT) + (int) ((illRefl & 0xFF) * (1 - cosT))) & 0xFF); } } default : { double lv_x = light_x - x, lv_y = light_y - y, lv_z = light_z - z, lv = Math.sqrt(lv_x * lv_x + lv_y * lv_y + lv_z * lv_z); // vector to the light from p.of.I lv_x /= lv; lv_y /= lv; lv_z /= lv; double cosT = nv_x * lv_x + nv_y * lv_y + nv_z * lv_z; if ((cosT < 0) || (bounce >= maxIterations)) { // light is behind the object (or bounce limit exceeded) // return ambient illumination of object cosT = 0; return (((MINLIGHT * (sphere_c[id_best] & 0xFF0000)) >> 8) & 0xFF0000) | (((MINLIGHT * (sphere_c[id_best] & 0xFF00)) >> 8) & 0xFF00) | (((MINLIGHT * (sphere_c[id_best] & 0xFF)) >> 8) & 0xFF); } else { int ill = trace(x + lv_x, y + lv_y, z + lv_z, lv_x, lv_y, lv_z, LIGHTSOURCE, bounce + 1); if ((ill & 0x01000000) == 0) { // light is off of a reflective surface so diminish slightly cosT *= cosT; cosT *= cosT; cosT *= cosT; } // compose light against color of object return ( ((((int) ((((ill >> 16) & 0xFF) - MINLIGHT) * cosT) + MINLIGHT) * (sphere_c[id_best] & 0xFF0000)) >> 8) & 0xFF0000) | (((((int) ((((ill >> 8) & 0xFF) - MINLIGHT) * cosT) + MINLIGHT) * (sphere_c[id_best] & 0xFF00)) >> 8) & 0xFF00) | (((((int) (((ill & 0xFF) - MINLIGHT) * cosT) + MINLIGHT) * (sphere_c[id_best] & 0xFF)) >> 8) & 0xFF); } } } } while (false); // give up if tracing to a light source if ((tolight & 0x01000000) != 0) return tolight; // check the floor (unless tracing to a light source) if (vector_y > 0) { final double t = (floor_y - start_y) / vector_y; final double x = start_x + vector_x * t, z = start_z + vector_z * t; // (x, floor_y, z) point of intersection with floor double lv_x = light_x - x, lv_y = light_y - floor_y, lv_z = light_z - z, lv = Math.sqrt(lv_x * lv_x + lv_y * lv_y + lv_z * lv_z); // vector to the light from p.of.I lv_x /= lv; lv_y /= lv; lv_z /= lv; double cosT = -lv_y; final boolean square = (((int) x & 512) ^ ((int) z & 512)) == 0; if ((cosT < 0) || (bounce >= maxIterations)) { //return square ? (((MINLIGHT << 8) * 0xFF) & 0xFF0000) : ((MINLIGHT * 0xFF) & 0xFF00); return square ? ((MINLIGHT * 0xC0) & 0xFF00) : ((MINLIGHT * 0xFF) & 0xFF00); } else { final int ill; if (((ill = trace(x, floor_y, z, lv_x, lv_y, lv_z, LIGHTSOURCE, bounce + 1)) & 0x01000000) == 0) { // light is off of a reflective surface so diminish slightly cosT *= cosT; cosT *= cosT; cosT *= cosT; } /*return square ? ((((int) ((((ill >> 16) & 0xFF) - MINLIGHT) * cosT) + MINLIGHT) * (0xFF << 8)) & 0xFF0000) : ((((int) ((((ill >> 8) & 0xFF) - MINLIGHT) * cosT) + MINLIGHT) * 0xFF) & 0xFF00);*/ return square ? ((((int) ((((ill >> 8) & 0xFF) - MINLIGHT) * cosT) + MINLIGHT) * 0xC0) & 0xFF00) : ((((int) ((((ill >> 8) & 0xFF) - MINLIGHT) * cosT) + MINLIGHT) * 0xFF) & 0xFF00); } } // hit the ceiling - map some sky onto it //return tolight; double cosA = -(vector_y / Math.sqrt (vector_mag)); // cosine of angle between ray and the vertical double vl = vector_mag - (vector_y * vector_y); if (vl <= 0) return 0xFFFFFF; // safe for sqrt and other ops double cosT = vector_z / Math.sqrt (vl); // cosine of angle between ray and forward (0, 0, 1) double sinT = Math.sqrt (1 - (cosT * cosT)); int index = (int)(cosT * cosA * Sky.radius) * Sky.width; if (vector_x > 0) { return Sky.data[index + (int)(sinT * cosA * Sky.radius) + Sky.centre]; } else { return Sky.data[index - (int)(sinT * cosA * Sky.radius) + Sky.centre]; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/Farmer.java0000644000000000000000000003065111111352066017352 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.net.*; import org.jcsp.plugNplay.*; import java.awt.event.*; import java.util.*; /** * @author Quickstone Technologies Limited */ final class Farmer implements CSProcess { private static final NetChannelEndFactory factory = new UnacknowledgedNetChannelEndFactory (); private final Random rnd = new Random (); private ChannelOutput[] toWorkers; private ProcessWrite[] writeProcs; private final Parallel parWrite; private final ChannelOutput toHarvester; private final AltingChannelInput fromUI; private final AltingChannelInput workerJoin; private final AltingChannelInput workerLeave; private int numWorkers; private final int colors[] = new int[] { 0xFF0000, 0x00FF00, 0xFFFF00, 0x0000FF, 0xFF00FF, 0x00FFFF, 0xFFFFFF, ImageDef.COLOR_MIRRORED, ImageDef.COLOR_TRANSPARENT }; private final int ball[] = new int[] { 0, 7, 2, 7, 3, 8 }; private int imageWidth, imageHeight, requestedWidth, requestedHeight; private final ImageDef[] imageDefs = new ImageDef[Main.BUFFERING]; private ImageDef imageDef; private WorkPacket[][] work; private int frameCount = 0; private double vertRotation = 0.0, horRotation = 0.0; public static final class ResizeMessage { public final int width, height; public ResizeMessage (int width, int height) { this.width = width; this.height = height; } } public Farmer (ChannelOutput[] toWorkers, ChannelOutput toHarvester, AltingChannelInput fromUI, AltingChannelInput workerJoin, AltingChannelInput workerLeave) { this.toWorkers = toWorkers; this.toHarvester = toHarvester; this.fromUI = fromUI; this.workerJoin = workerJoin; this.workerLeave = workerLeave; this.numWorkers = toWorkers.length; this.writeProcs = new ProcessWrite[numWorkers]; this.parWrite = new Parallel (); this.work = new WorkPacket[numWorkers][Main.BUFFERING]; for (int i = 0; i < numWorkers; i++) { for (int j = 0; j < Main.BUFFERING; j++) { work[i][j] = new WorkPacket (); } writeProcs[i] = new ProcessWrite (toWorkers[i]); } parWrite.addProcess (writeProcs); } private final ImageDef makeImageDef () { ImageDef image = new ImageDef (); image.sphere_x = new double[6]; image.sphere_y = new double[6]; image.sphere_z = new double[6]; image.sphere_r = new double[6]; image.sphere_c = new int[6]; for (int i = 0; i < 6; i++) { image.sphere_y[i] = 500 - (i * 50); image.sphere_r[i] = 300; image.sphere_c[i] = colors[ball[i]]; } image.light_y = -300; image.floor_y = 800; return image; } private final void updateHarvester () { final ImagePacket image = new ImagePacket (); image.width = imageWidth; image.height = imageHeight; image.frame = frameCount; image.numWorkers = numWorkers; toHarvester.write (image); for (int i = 0; i < numWorkers; i++) { for (int j = 0; j < Main.BUFFERING; j++) { work[i][j].width = imageWidth; work[i][j].height = imageHeight; work[i][j].step = numWorkers; work[i][j].offset = i; } } } private double rp_result_x, rp_result_y, rp_result_z; private final void rotatePoint (double x, double y, double z, double cosYZ, double sinYZ, double cosXZ, double sinXZ) { rp_result_y = y * cosYZ - z * sinYZ; rp_result_z = z * cosYZ + y * sinYZ; rp_result_x = x * cosXZ - rp_result_z * sinXZ; rp_result_z = rp_result_z * cosXZ + x * sinXZ; } private final void updateWorkers () { int frameNo = frameCount; imageDef = imageDefs [frameCount % Main.BUFFERING]; double ang = (double)frameNo * 6.28 / 100.0; for (int i = 0; i < imageDef.sphere_x.length; i++) { imageDef.sphere_x[i] = 800 * Math.cos (ang + (i * 6.28 / imageDef.sphere_x.length)); imageDef.sphere_z[i] = 800 * Math.sin (ang + (i * 6.28 / imageDef.sphere_x.length)); imageDef.sphere_y[i] = 500 * Math.cos ((i * 6.28 / imageDef.sphere_x.length) - ang); } imageDef.light_x = 1500 * Math.cos (-ang); imageDef.light_z = 1500 * Math.sin (-ang); double cosH = Math.cos (horRotation), sinH = Math.sin (horRotation), cosV = Math.cos (vertRotation), sinV = Math.sin (vertRotation); rotatePoint (0, 0, 2100, cosV, sinV, cosH, sinH); imageDef.camera_x = rp_result_x; imageDef.camera_y = rp_result_y; imageDef.camera_z = rp_result_z; rotatePoint (-550, -499, 1503, cosV, sinV, cosH, sinH); imageDef.view_window_x1 = rp_result_x; imageDef.view_window_y1 = rp_result_y; imageDef.view_window_z1 = rp_result_z; rotatePoint (550, -499, 1503, cosV, sinV, cosH, sinH); imageDef.view_window_x2 = rp_result_x; imageDef.view_window_y2 = rp_result_y; imageDef.view_window_z2 = rp_result_z; rotatePoint (550, 499, 1503, cosV, sinV, cosH, sinH); imageDef.view_window_x3 = rp_result_x; imageDef.view_window_y3 = rp_result_y; imageDef.view_window_z3 = rp_result_z; rotatePoint (-550, 499, 1503, cosV, sinV, cosH, sinH); imageDef.view_window_x4 = rp_result_x; imageDef.view_window_y4 = rp_result_y; imageDef.view_window_z4 = rp_result_z; for (int i = 0; i < numWorkers; i++) { work[i][frameCount % Main.BUFFERING].frame = frameCount; work[i][frameCount % Main.BUFFERING].image = imageDef; writeProcs[i].value = work[i][frameCount % Main.BUFFERING]; //toWorkers[i].write (work[i][frameCount % Main.BUFFERING]); } //long t = System.currentTimeMillis (); parWrite.run (); //System.out.println ("Farmer: update workers - " + (System.currentTimeMillis () - t) + "ms"); frameCount++; } private final void workerLeaves (NetChannelLocation ncl) { ChannelOutput toWorkers2[] = new ChannelOutput[numWorkers - 1]; WorkPacket work2[][] = new WorkPacket[numWorkers - 1][]; ProcessWrite writeProcs2[] = new ProcessWrite[numWorkers - 1]; int j = 0; for (int i = 0; i < numWorkers; i++) { if (!((NetChannelOutput)toWorkers[i]).getChannelLocation ().equals (ncl)) { toWorkers2[j] = toWorkers[i]; work2[j] = work[i]; writeProcs2[j] = writeProcs[i]; j++; } } toWorkers = toWorkers2; work = work2; writeProcs = writeProcs2; parWrite.removeAllProcesses (); parWrite.addProcess (writeProcs); numWorkers--; // recalculate size imageWidth = ((requestedWidth + (numWorkers - 1)) / numWorkers) * numWorkers; imageHeight = ((requestedHeight + (numWorkers - 1)) / numWorkers) * numWorkers; } private final void workerJoins (NetChannelLocation ncl) { ChannelOutput toWorkers2[] = new ChannelOutput[numWorkers + 1]; WorkPacket work2[][] = new WorkPacket[numWorkers + 1][]; ProcessWrite writeProcs2[] = new ProcessWrite[numWorkers + 1]; System.arraycopy (toWorkers, 0, toWorkers2, 0, numWorkers); System.arraycopy (work, 0, work2, 0, numWorkers); System.arraycopy (writeProcs, 0, writeProcs2, 0, numWorkers); toWorkers2[numWorkers] = factory.createOne2Net (ncl); work2[numWorkers] = new WorkPacket[Main.BUFFERING]; writeProcs2[numWorkers] = new ProcessWrite (toWorkers2[numWorkers]); for (int i = 0; i < Main.BUFFERING; i++) { work2[numWorkers][i] = new WorkPacket (); } toWorkers = toWorkers2; work = work2; writeProcs = writeProcs2; parWrite.addProcess (writeProcs2[numWorkers]); numWorkers++; // recalculate size imageWidth = ((requestedWidth + (numWorkers - 1)) / numWorkers) * numWorkers; imageHeight = ((requestedHeight + (numWorkers - 1)) / numWorkers) * numWorkers; } public final void run () { boolean configChanged = false; int changeLock = Main.BUFFERING + 1; System.out.println ("Farmer: started"); for (int i = 0; i < Main.BUFFERING; i++) { imageDefs[i] = makeImageDef (); } ResizeMessage rm = (ResizeMessage)fromUI.read (); requestedWidth = rm.width; requestedHeight = rm.height; imageWidth = ((requestedWidth + (numWorkers - 1)) / numWorkers) * numWorkers; imageHeight = ((requestedHeight + (numWorkers - 1)) / numWorkers) * numWorkers; updateHarvester (); for (int i = 0; i < Main.BUFFERING - 1; i++) { updateWorkers (); } main: while (true) { // Write out a load of work (non-blocking) updateWorkers (); // Check for pending UI events while (fromUI.pending ()) { Object o = fromUI.read (); if (o instanceof MouseEvent) { MouseEvent me = (MouseEvent)o; vertRotation = 1.570796 - ((double)me.getY () * 1.9 / (double)imageHeight); horRotation = (double)me.getX () * 6.28 / (double)imageWidth; } else if (o instanceof KeyEvent) { KeyEvent ke = (KeyEvent)o; char c = ke.getKeyChar (); int b = -1; if ((c >= 'A') && (c <= 'F')) { b = c - 'A'; } else if ((c >= 'a') && (c <= 'f')) { b = c - 'a'; } else if ((c >= '1') && (c <= '6')) { b = c - '1'; } if (b >= 0) { System.out.println ("Farmer: ball " + (b + 1) + " color change"); int nc = ball[b] = (ball[b] + 1) % colors.length; for (int j = 0; j < Main.BUFFERING; j++) { imageDefs[j].sphere_c[b] = colors[nc]; } } } else if (o instanceof ResizeMessage) { rm = (ResizeMessage)o; imageWidth = ((rm.width + (numWorkers - 1)) / numWorkers) * numWorkers; imageHeight = ((rm.height + (numWorkers - 1)) / numWorkers) * numWorkers; configChanged = true; } else if (o == null) { break main; } } if (changeLock == 0) { // Check for anyone wanting to join while (workerJoin.pending ()) { System.out.println ("Farmer: worker is joining"); NetChannelLocation ncl = (NetChannelLocation)workerJoin.read (); workerJoins (ncl); configChanged = true; changeLock = Main.BUFFERING + 1; break; } // Check for anyone wanting to leave while ((workerLeave.pending ()) && (numWorkers > 1)) { System.out.println ("Farmer: worker is leaving"); NetChannelLocation ncl = (NetChannelLocation)workerLeave.read (); workerLeaves (ncl); configChanged = true; changeLock = Main.BUFFERING + 1; break; } } else { changeLock--; } // Synchronize with the harvester if (configChanged) { updateHarvester (); configChanged = false; } else { toHarvester.write (null); } } System.out.println ("Farmer: poisoning workers"); for (int i = 0; i < numWorkers; i++) { toWorkers[i].write (null); } System.out.println ("Farmer: system-exit"); System.exit (0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/Counter.java0000644000000000000000000000657111111352066017561 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author Quickstone Technologies Limited */ final class Counter { private static final int NUM_SAMPLES = 50; private final long timeSample[] = new long[NUM_SAMPLES]; private final long dataSample[] = new long[NUM_SAMPLES]; private int samplePtr = 0, samples = 0; private long timeSum = 0, dataSum = 0; private long tag = 0; public final void click () { long t = System.currentTimeMillis (); if (tag == 0) { tag = t; return; } timeSum -= timeSample[samplePtr]; timeSum += (timeSample[samplePtr] = (t - tag)); if (++samplePtr == NUM_SAMPLES) samplePtr = 0; if (samples < NUM_SAMPLES) samples++; if ((samplePtr & 15) == 0) { System.out.println ("Count = " + (timeSum / samples) + "ms/frame (" + ((double)samples * 1000.0 / (double)timeSum) + " fps)"); } tag = t; } public final void dataStart () { tag = System.currentTimeMillis (); } public final void dataEnd (int bytes) { long t = System.currentTimeMillis (); timeSum -= timeSample[samplePtr]; timeSum += (timeSample[samplePtr] = (t - tag)); dataSum -= dataSample[samplePtr]; dataSum += (dataSample[samplePtr] = bytes); if (++samplePtr == NUM_SAMPLES) samplePtr = 0; if (samples < NUM_SAMPLES) samples++; if ((samplePtr & 15) == 0) { System.out.println ("Data = " + (dataSum / timeSum) + "pixels/ms"); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/WorkPacket.java0000644000000000000000000000435511111352066020212 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.io.*; /** * @author Quickstone Technologies Limited */ class WorkPacket implements Serializable { public ImageDef image; public int width, height; public int offset, step; public int frame; } jcsp-1.1-rc4.orig/src/jcsp-demos/raytrace/Harvester.java0000644000000000000000000001216211111352066020076 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.image.*; /** * @author Quickstone Technologies Limited */ class Harvester implements CSProcess { private final ChannelInput[] fromWorkers; private final ChannelInput fromFarmer; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; public Harvester (ChannelInput[] fromWorkers, ChannelInput fromFarmer, ChannelOutput toGraphics, ChannelInput fromGraphics) { this.fromWorkers = fromWorkers; this.fromFarmer = fromFarmer; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; } public void run () { System.out.println ("Harvester: started"); final Counter counter = new Counter (); final DisplayList displayList = new DisplayList (); int currentFrame = 0; int width = 0, height = 0; int[] pixels = null; MemoryImageSource mis = null; Image image = null; int numWorkers = 0, nextNumWorkers = 0, nextNumWorkersFrame = 0; toGraphics.write (new GraphicsProtocol.SetPaintable (displayList)); fromGraphics.read (); while (true) { // Synchronize with farmer //System.out.println ("Harvester: synchronize with farmer"); ImagePacket ip = (ImagePacket)fromFarmer.read (); if (ip != null) { System.out.println ("Harvester: updating image configuration"); width = ip.width; height = ip.height; pixels = new int[width * height]; mis = new MemoryImageSource (width, height, pixels, 0, width); mis.setAnimated (true); toGraphics.write (new GraphicsProtocol.MakeMISImage (mis)); image = (Image)fromGraphics.read (); displayList.set (new GraphicsCommand.DrawImage (image, 0, 0, width, height)); if (ip.numWorkers != numWorkers) { nextNumWorkers = ip.numWorkers; nextNumWorkersFrame = ip.frame; } } // Read in the work packets for the current frame if (nextNumWorkersFrame == currentFrame) { numWorkers = nextNumWorkers; } int i = 0; try { //System.out.println ("Harvester: read frame " + currentFrame + " results"); for (; i < numWorkers; i++) { ResultPacket rp = (ResultPacket)fromWorkers[currentFrame % fromWorkers.length].read (); rp.expand (); int j = rp.offset * width, x = 0; for (int kR = 0, kG = rp.color.length / 3, kB = (kG << 1); kB < rp.color.length; ) { int a = (rp.color[kR++] << 16) & 0xFF0000; a |= (rp.color[kG++] << 8) & 0xFF00; pixels[j++] = 0xFF000000 | a | (rp.color[kB++] & 0xFF); if (++x >= width) { j += (rp.step - 1) * width; x = 0; } } rp.discard (); } mis.newPixels (); } catch (ArrayIndexOutOfBoundsException e) { System.out.println ("Harvester: array index problems"); // Image has probably changed size. I don't care for elegance so just skip any outstanding packets i++; for (; i < numWorkers; i++) { fromWorkers[currentFrame % fromWorkers.length].read (); } } currentFrame++; counter.click (); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/0000755000000000000000000000000011410045035016473 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/MultiLaunchControl.java0000644000000000000000000001021311111352066023124 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class MultiLaunchControl implements CSProcess { private final int interval; private final int start; private final AltingChannelInputInt abort; private final ChannelOutputInt cancel; private final AltingChannelInputInt hold; private final ChannelOutputInt countdown; private final ChannelOutputInt fire; public MultiLaunchControl (final int interval, final int start, final AltingChannelInputInt abort, final ChannelOutputInt cancel, final AltingChannelInputInt hold, final ChannelOutputInt countdown, final ChannelOutputInt fire) { this.interval = interval; this.start = start; this.abort = abort; this.cancel = cancel; this.hold = hold; this.countdown = countdown; this.fire = fire; } public void run () { final LaunchControl launchControl = new LaunchControl (start, abort, hold, countdown, fire); final CSTimer tim = new CSTimer (); final long seconds = 1000; final Alternative alt = new Alternative (new Guard[] {tim, hold}); final int TIMEOUT = 0; final int HOLD = 1; hold.read (); // start signal while (true) { cancel.write (0); // enable abort launchControl.run (); int status = launchControl.getStatus (); cancel.write (status); // graceful if (status == LaunchControl.FIRED) abort.read (); // reset boolean waiting = true; tim.setAlarm (tim.read () + (interval*seconds)); while (waiting) { switch (alt.priSelect ()) { case TIMEOUT: waiting = false; break; case HOLD: hold.read (); fire.write (LaunchControl.HOLDING); hold.read (); fire.write (status); break; } } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/MissionControl.java0000644000000000000000000000661411111352066022332 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class MissionControl { public static final String TITLE = "Mission Control"; public static final String DESCR = "Demonstrates the handling of AWT button and timer events."; public static final int minStart = 10; public static final int maxStart = 1000; public static final int defaultStart = 300; public static final int minInterval = 10; public static final int maxInterval = 1000; public static final int defaultInterval = 10; public static void main(String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("start", minStart, maxStart, defaultStart); Ask.addPrompt ("interval", minInterval, maxInterval, defaultInterval); Ask.show (); final int start = Ask.readInt ("start"); final int interval = Ask.readInt ("interval"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame (TITLE); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); final MissionControlNetwork net = new MissionControlNetwork (interval, start, activeFrame); activeFrame.pack (); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, net } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/PanelControl.java0000644000000000000000000000631111111352066021742 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.awt.*; import java.awt.event.*; /** * @author P.H. Welch */ public class PanelControl implements CSProcess { private final AltingChannelInput fromPanel; private final ChannelOutput toPanel; private final ChannelOutputInt hold; public PanelControl (final AltingChannelInput fromPanel, final ChannelOutput toPanel, final ChannelOutputInt hold) { this.fromPanel = fromPanel; this.toPanel = toPanel; this.hold = hold; } public void run () { final PanelColour panelOff = new PanelColour (Color.lightGray); final PanelColour panelOn = new PanelColour (Color.green); boolean mousePresent = false; toPanel.write (panelOff); while (true) { switch (((MouseEvent) fromPanel.read ()).getID ()) { case MouseEvent.MOUSE_PRESSED: if (! mousePresent) { mousePresent = true; hold.write (0); toPanel.write (panelOn); } else { mousePresent = false; hold.write (0); toPanel.write (panelOff); } break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/LaunchControl.java0000644000000000000000000001411511111352066022116 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; // LaunchControl is a process to control the launch of a space rocket. // It is configured with a countdown time in seconds -- this must be above // a minimum threshold, MIN_COUNTDOWN, else the launch is immediately aborted. // There are two control lines, abort and hold, that respectively abort // or hold the launch if signalled. The hold is released by a second // signal on the same line. // During countdown, the count is reported by outputting on the countdown // channel. // If not aborted, LaunchControl fires the rocket (by outputting on its fire // channel) when the countdown reaches zero. An ABORTED launch is also // reported on this fire channel. // After a successful or aborted launch, LaunchControl terminates. // The status attribute records whether the launch was FIRED or ABORTED // and may then be inspected. /** * @author P.H. Welch */ public class LaunchControl implements CSProcess { public static final int MIN_COUNTDOWN = 10; public static final int FIRED = 0; public static final int HOLDING = 1; public static final int COUNTING = 2; public static final int ABORTED = 3; public static final int UNDEDFINED = 4; private final int start; private final AltingChannelInputInt abort; private final AltingChannelInputInt hold; private final ChannelOutputInt countdown; private final ChannelOutputInt fire; private int status = UNDEDFINED; public LaunchControl (final int start, final AltingChannelInputInt abort, final AltingChannelInputInt hold, final ChannelOutputInt countdown, final ChannelOutputInt fire) { this.start = start; this.abort = abort; this.hold = hold; this.countdown = countdown; this.fire = fire; } public int getStatus () { // inspection method return status; // (can only be used } // in between runs) public void run () { final CSTimer tim = new CSTimer (); // JCSP timers have final long oneSecond = 1000; // millisecond granularity long timeout = tim.read () + oneSecond; // compute first timeout final Alternative alt = new Alternative (new Guard[] {abort, hold, tim}); final int ABORT = 0; final int HOLD = 1; final int TICK = 2; fire.write (COUNTING); // signal rocket int count = start; boolean counting = (start >= MIN_COUNTDOWN); // abort if bad start while ((count > 0) && counting) { System.out.println ("********** LaunchControl: tick"); countdown.write (count); // public address system tim.setAlarm (timeout); // set next timeout switch (alt.priSelect ()) { case ABORT: // abort signalled abort.read (); // clear the signal counting = false; break; case HOLD: // hold signalled long timeLeft = timeout - tim.read (); // time till next tick hold.read (); // clear the signal fire.write (HOLDING); // signal rocket hold.read (); // wait for the release timeout = tim.read () + timeLeft; // recompute next timeout fire.write (COUNTING); // signal rocket break; case TICK: // timeout expired count--; timeout += oneSecond; // compute next timeout break; } } status = (counting) ? FIRED : ABORTED; // set status attribute fire.write (status); // signal rocket (go/nogo) if (counting) countdown.write (0); // complete countdown } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/MissionControl.html0000644000000000000000000000566011113065047022357 0ustar JCSP Mission Control

Mission Control

Point and click the applet to start the countdown. Further clicks toggle between holding and countdown modes. When the countdown reaches zero, the status changes to fired and the abort button is disabled. After 10 seconds, the countdown restarts from its initial value with the abort button re-enabled.

In countdown and holding modes, the abort button may be pressed. This cancels the countdown and puts the system into aborted mode. After 10 seconds, the countdown restarts from its initial value with the abort button re-enabled.

When in the 10 second fired or aborted modes, mouse clicks toggle between that mode and holding.

IMPORTANT: if the abort button is pressed at the same time as the countdown reaches zero and control tries to fire the rocket, it's important the system resolves this command clash cleanly. In particular, the system must not deadlock nor get into a corrupt state! Exercise: prove this system is free from these hazards. Hint: use CSP. jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/LabelColour.java0000644000000000000000000000502411111352066021545 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class LabelColour implements ActiveLabel.Configure { private Color colour = Color.lightGray; public LabelColour (final Color colour) { this.colour = colour; } public LabelColour () { } public void setColour (Color colour) { this.colour = colour; } public void configure (java.awt.Label label) { label.setBackground (colour); // label.repaint (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/MissionControlNetwork.java0000644000000000000000000001550511111352066023703 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.util.ints.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class MissionControlNetwork implements CSProcess { final private int interval; final private int start; final private ActiveFrame parent; class MyActiveButton extends ActiveButton { public MyActiveButton (String s) { super (s); } public Dimension getPreferredSize () { return new Dimension (100, 100); } public Dimension getMinimumSize () { return new Dimension (100, 100); } public Dimension getMaximumSize () { return new Dimension (100, 100); } } final private ActiveButton abortButton = new ActiveButton (" abort "); final private ActiveLabel countLabel = new ActiveLabel (" "); final private ActiveLabel rocketStatus = new ActiveLabel (" Holding "); public MissionControlNetwork (final int interval, final int start, final ActiveFrame parent) { this.interval = interval; this.start = start; this.parent = parent; // panelApplet.setLayout (new GridLayout (5, 3)); parent.setLayout (new FlowLayout (FlowLayout.CENTER, 10, 75)); countLabel.setAlignment (Label.CENTER); countLabel.setBackground (Color.white); rocketStatus.setAlignment (Label.CENTER); rocketStatus.setBackground (Color.lightGray); // abortButton.requestSize (100, 100); abortButton.setEnabled (false); abortButton.setBackground (Color.orange); parent.add (abortButton); parent.add (countLabel); parent.add (rocketStatus); } public void run () { final One2OneChannel mouseEvent = Channel.one2one (); // applet panel final One2OneChannel panelConfigure = Channel.one2one (); // channels final One2OneChannel abortEvent = Channel.one2one (new OverWriteOldestBuffer (1)); // abort button final One2OneChannel abortConfigure = Channel.one2one (); // channels final One2OneChannelInt hold = Channel.one2oneInt (); // launch control final One2OneChannelInt cancel = Channel.one2oneInt (); // channels final One2OneChannelInt abort = Channel.one2oneInt (new OverWriteOldestBufferInt (1)); final One2OneChannelInt countdown = Channel.one2oneInt (); final One2OneChannelInt fire = Channel.one2oneInt (); final One2OneChannel countdown2 = Channel.one2one (); final One2OneChannel fire2 = Channel.one2one (); parent.addMouseEventChannel (mouseEvent.out ()); parent.setConfigureChannel (panelConfigure.in ()); abortButton.addEventChannel (abortEvent.out ()); abortButton.setConfigureChannel (abortConfigure.in ()); countLabel.setConfigureChannel (countdown2.in ()); rocketStatus.setConfigureChannel (fire2.in ()); new Parallel ( new CSProcess[] { parent, new PanelControl (mouseEvent.in(), panelConfigure.out (), hold.out ()), abortButton, new AbortControl (abortEvent.in (), abortConfigure.out (), cancel.in (), abort.out ()), countLabel, rocketStatus, new MultiLaunchControl (interval, start, abort.in (), cancel.out (), hold.in (), countdown.out (), fire.out ()), new CSProcess () { public void run () { final LabelColour white = new LabelColour (Color.white); while (true) { int n = countdown.in ().read (); countdown2.out ().write (white); countdown2.out ().write ((new Integer (n)).toString ()); } } }, new CSProcess () { public void run () { final LabelColour rocketGreen = new LabelColour (Color.green); final LabelColour rocketLightGray = new LabelColour (Color.lightGray); final LabelColour rocketOrange = new LabelColour (Color.orange); while (true) { switch (fire.in().read ()) { case LaunchControl.FIRED: fire2.out().write (rocketGreen); fire2.out().write ("Fired"); break; case LaunchControl.COUNTING: fire2.out().write (rocketGreen); fire2.out().write ("Counting"); break; case LaunchControl.HOLDING: fire2.out().write (rocketLightGray); fire2.out().write ("Holding"); break; case LaunchControl.ABORTED: fire2.out().write (rocketOrange); fire2.out().write ("Aborted"); break; } } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/PanelColour.java0000644000000000000000000000503111111352066021563 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class PanelColour implements ActiveApplet.Configure { private Color colour = Color.lightGray; public PanelColour (final Color colour) { this.colour = colour; } public PanelColour () { } public void setColour (Color colour) { this.colour = colour; } public void configure (java.applet.Applet applet) { applet.setBackground (colour); applet.repaint (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/AbortControl.java0000644000000000000000000000754011111352066021757 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class AbortControl implements CSProcess { private final AltingChannelInput fromButton; private final ChannelOutput toButton; private final AltingChannelInputInt cancel; private final ChannelOutputInt abort; public AbortControl (final AltingChannelInput fromButton, final ChannelOutput toButton, final AltingChannelInputInt cancel, final ChannelOutputInt abort) { this.fromButton = fromButton; this.toButton = toButton; this.cancel = cancel; this.abort = abort; } public void run () { final Alternative alt = new Alternative (new Guard[] {fromButton, cancel}); final int BUTTON = 0; final int CANCEL = 1; while (true) { cancel.read (); // get ready for next launch while (fromButton.pending ()) fromButton.read (); // debounce toButton.write ("ABORT"); toButton.write (Boolean.TRUE); // enable the button switch (alt.priSelect ()) { case BUTTON: // abort button pressed abort.write (0); // try to abort the rocket toButton.write (Boolean.FALSE); // disable the button toButton.write ("abort"); fromButton.read (); // clear the signal cancel.read (); // acknowledgement of the abort break; case CANCEL: // the rocket has been fired cancel.read (); // clear the signal abort.write (0); // acknowledge the firing toButton.write (Boolean.FALSE); // disable the button toButton.write ("abort"); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/missionControl/ns-MissionControl.html0000644000000000000000000000272711113065047022776 0ustar JCSP Mission Control

Mission Control

Point and click the applet to start the countdown. Further clicks toggle between holding and countdown modes. When the countdown reaches zero, the status changes to fired and the abort button is disabled. After 10 seconds, the countdown restarts from its initial value with the abort button re-enabled.

In countdown and holding modes, the abort button may be pressed. This cancels the countdown and puts the system into aborted mode. After 10 seconds, the countdown restarts from its initial value with the abort button re-enabled.

When in the 10 second fired or aborted modes, mouse clicks toggle between that mode and holding.

IMPORTANT: if the abort button is pressed at the same time as the countdown reaches zero and control tries to fire the rocket, it's important the system resolves this command clash cleanly. In particular, the system must not deadlock nor get into a corrupt state! Exercise: prove this system is free from these hazards. Hint: use CSP. jcsp-1.1-rc4.orig/src/jcsp-demos/infect/0000755000000000000000000000000011410045036014722 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/infect/Infect.html0000644000000000000000000001256211113065047017032 0ustar JCSP Infect

Infect

The central canvas shows a growth medium in which an infectious organism can grow. It represnts a two-dimensional space of cells mapped on to a toroidal world - i.e. the left and right edges are adjacent, likewise the top and bottom edges.  Each cell (pixel) in the canvas can be in one of three states:

  • healthy (green)
  • infected (red - how many is reported in the top left info label)
  • immune (blue - how many is reported in the top right info label)
The medium evolves in cycles.  In each cycle:
  • if a healthy cell is nect to an infected one, there is a rate% chance that it will become infected.  The value of rate is controlled by the slider on the left (and reported in the bottom left info label)..
  • an infected cell may cease being infectious and become immune - it's still sick but it won't infect anyone.  The chance (%) of its remaining infectious is governed by the top right slider (and reported in the bottom middle info label).
  • an immune cell may recover and become healthy again.  The chance (%) of an immune cell retaining its immunity is controlled by the bottom right slider (and reported in the bottom right info label).  There is a very small chance that an immune cell may spontaenously become infectious again - this is not under user control.
Initially, the model is active and all cells are healthy (green).  Other user controls are as follows:
  • [LEFT MOUSE CLICK] introduces infection.
  • [RIGHT MOUSE CLICK] immunises healthy cells (but does not change infected ones).
  • [MIDDLE MOUSE CLICK] makes immune cells healthy (but does not change infected ones).
DRAGGING with the mouse button is PRESSED repeats the above CLICK operations over the cells it passes.

Pressing [SHIFT] at the same time as a mouse CLICK sprays the action over a much wider area - the spray pattern is random and changes each time.  It is not necessary to keep the [SHIFT] key depressed whilst DRAGGING.

Pressing [CTRL] at the same time as a mouse CLICK locks (logically) the mouse button down.  The mouse button can now be released and the system will respond to mouse movements as though it was being DRAGGED (i.e. as though the button was held down).  The next mouse click (on any button) release this lock.  [Note: this only applies to the LEFT and RIGHT buttons.  JDK 1.1/1.2/1.3 all report the [CTRL] key pressed on the MIDDLE button regardless as to whether it really is pressed.]

Presing [SHIFT] and [CTRL] at the same time as a mouse CLICK combines the above effects.

Finally, there are [FREEZE/IUNFREEZE] and [RESET] buttons.  The [RESET], which clears the medium back to all healthy cells, is only enabled if the system is frozen.

Challenge: with the initial settings of the slider rates, start an infection in the middle and try to eradicate it by spraying.  Now try it with an infection from a corner region.  Reduce the inititial immune persistence rate from 99% to 98%.  Can you still eradicate it?

Experiment: with different settings of the sliders.  The original version of this model had the two right-side sliders at zero.

Enjoy! jcsp-1.1-rc4.orig/src/jcsp-demos/infect/ns-Infect.html0000644000000000000000000001007211113065047017442 0ustar JCSP Infect

Infect

The central canvas shows a growth medium in which an infectious organism can grow. It represnts a two-dimensional space of cells mapped on to a toroidal world - i.e. the left and right edges are adjacent, likewise the top and bottom edges.  Each cell (pixel) in the canvas can be in one of three states:

  • healthy (green)
  • infected (red - how many is reported in the top left info label)
  • immune (blue - how many is reported in the top right info label)
The medium evolves in cycles.  In each cycle:
  • if a healthy cell is nect to an infected one, there is a rate% chance that it will become infected.  The value of rate is controlled by the slider on the left (and reported in the bottom left info label)..
  • an infected cell may cease being infectious and become immune - it's still sick but it won't infect anyone.  The chance (%) of its remaining infectious is governed by the top right slider (and reported in the bottom middle info label).
  • an immune cell may recover and become healthy again.  The chance (%) of an immune cell retaining its immunity is controlled by the bottom right slider (and reported in the bottom right info label).  There is a very small chance that an immune cell may spontaenously become infectious again - this is not under user control.
Initially, the model is active and all cells are healthy (green).  Other user controls are as follows:
  • [LEFT MOUSE CLICK] introduces infection.
  • [RIGHT MOUSE CLICK] immunises healthy cells (but does not change infected ones).
  • [MIDDLE MOUSE CLICK] makes immune cells healthy (but does not change infected ones).
DRAGGING with the mouse button is PRESSED repeats the above CLICK operations over the cells it passes.

Pressing [SHIFT] at the same time as a mouse CLICK sprays the action over a much wider area - the spray pattern is random and changes each time.  It is not necessary to keep the [SHIFT] key depressed whilst DRAGGING.

Pressing [CTRL] at the same time as a mouse CLICK locks (logically) the mouse button down.  The mouse button can now be released and the system will respond to mouse movements as though it was being DRAGGED (i.e. as though the button was held down).  The next mouse click (on any button) release this lock.  [Note: this only applies to the LEFT and RIGHT buttons.  JDK 1.1/1.2/1.3 all report the [CTRL] key pressed on the MIDDLE button regardless as to whether it really is pressed.]

Presing [SHIFT] and [CTRL] at the same time as a mouse CLICK combines the above effects.

Finally, there are [FREEZE/IUNFREEZE] and [RESET] buttons.  The [RESET], which clears the medium back to all healthy cells, is only enabled if the system is frozen.

Challenge: with the initial settings of the slider rates, start an infection in the middle and try to eradicate it by spraying.  Now try it with an infection from a corner region.  Reduce the inititial immune persistence rate from 99% to 98%.  Can you still eradicate it?

Experiment: with different settings of the sliders.  The original version of this model had the two right-side sliders at zero.

Enjoy! jcsp-1.1-rc4.orig/src/jcsp-demos/infect/InfectionControl.java0000644000000000000000000001334711111352066021056 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; /** * @author P.H. Welch */ class InfectionControl implements CSProcess { protected ActiveButtonControl control; protected AltingChannelInput[] event; // from buttons ... protected ChannelOutput[] configure; // to buttons ... protected ChannelOutput report; // to whoever is out there ... public final static int reset = 0; // these are the state names ... public final static int centre = 1; public final static int random = 2; public final static int running = 3; public final static int frozen = 4; public final static int NUMBER = 4; // this is the number of buttons public final static int RESET = 0; // these are the button names ... public final static int RANDOM = 1; public final static int CENTRE = 2; public final static int FREEZE = 3; protected String[][] label // these are the button labels ... = {new String[] {"reset", "RESET"}, new String[] {"random", "RANDOM"}, new String[] {"centre", "CENTRE"}, new String[] {"start", "START", "FREEZE", "UNFREEZE"}, new String[] {"dummy"}}; protected int[][] labelId // which label to use next ... = {new int[] {0, 1, 1, 0, 0}, // reset new int[] {1, 0, 0, 1, 0}, // centre new int[] {1, 1, 0, 1, 0}, // random new int[] {0, 0, 0, 2, 0}, // running new int[] {1, 0, 0, 3, 0}}; // frozen protected boolean[][] enable // next button enable status ... = {new boolean[] {false, true, true, false, true}, // reset new boolean[] { true, false, false, true, true}, // centre new boolean[] { true, true, false, true, true}, // random new boolean[] {false, false, false, true, true}, // running new boolean[] { true, false, false, true, true}}; // frozen protected int[][] nextState = {new int[] {0, 2, 1, 0, 0}, // reset new int[] {0, 1, 1, 3, 1}, // centre new int[] {0, 2, 2, 3, 2}, // random new int[] {3, 3, 3, 4, 0}, // running new int[] {0, 4, 4, 3, 4}}; // frozen protected ActiveButtonState[] makeState () { System.out.println ("InfectionControl making ActiveButtonState[] ..."); ActiveButtonState[] state = null; try { state = new ActiveButtonState[enable.length]; for (int i = 0; i < state.length; i++) { state[i] = new ActiveButtonState (labelId[i], enable[i], nextState[i]); } } catch (ActiveButtonState.BadArguments e) { System.out.println (e); System.exit (0); } System.out.println ("InfectionControl made ActiveButtonState[]"); return state; } public InfectionControl (AltingChannelInput[] event, ChannelOutput[] configure, ChannelOutput report) { System.out.println ("InfectionControl creating ..."); try { control = new ActiveButtonControl (event, configure, report, label, makeState (), 0); } catch (ActiveButtonControl.BadArguments e) { System.out.println (e); System.exit (0); } this.event = event; this.configure = configure; this.report = report; System.out.println ("InfectionControl created"); } public void run () { System.out.println ("InfectionControl starting ..."); control.run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/infect/InfectMain.java0000644000000000000000000001014711111352066017607 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class InfectMain extends ActiveApplet { public static final String TITLE = "Infection"; public static final String DESCR = "Shows a thread-safe simulation strategy with the simulation thread polling the event channels that " + "control it. User interface controls generate the events for these channels. Whenever no data is " + "available on a channel the simulation thread generates the next frame. The simulation is a cellular " + "automata representing the spread of an infection. The slider controls the rate of spread."; public static final int minWidth = 350; public static final int maxWidth = 1024; public static final int minHeight = 350; public static final int maxHeight = 768; public static final int minRate = 0; public static final int maxRate = 100; public static final int standbyRate = 35; public void init () { final int rate = getAppletInt ("rate", minRate, maxRate, standbyRate); setProcess (new InfectNetwork (rate, this)); } public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.addPrompt ("rate", minRate, maxRate, standbyRate); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); final int rate = Ask.readInt ("rate"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame (TITLE); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final InfectNetwork infect = new InfectNetwork (rate, activeFrame); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, infect } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/infect/Tree.java0000644000000000000000000000431711111352066016473 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ public interface Tree { public final int nStates = 3; public final byte green = 0; public final byte infected = 1; public final byte dead = 2; } jcsp-1.1-rc4.orig/src/jcsp-demos/infect/PseudoButton.java0000644000000000000000000000546611111352066020235 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.*; /** * @author P.H. Welch */ class PseudoButton implements CSProcess { protected ChannelInput configure; protected ChannelOutput event; protected ChannelInput feedBack; public PseudoButton (ChannelInput configure, ChannelOutput event, ChannelInput feedBack) { this.configure = configure; this.event = event; this.feedBack = feedBack; } public void run () { new Parallel ( new CSProcess[] { new BlackHole (configure), new CSProcess() { public void run () { while (true) { feedBack.read (); event.write (""); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/infect/Infection.java0000644000000000000000000003105211111352066017506 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.image.*; import java.util.Random; /** * @author P.H. Welch */ public class Infection implements CSProcess { protected int rate; private final AltingChannelInput in; private final AltingChannelInputInt scrollEvent; private final ChannelOutput feedBack, scrollConfigure, infoConfigure, rateConfigure; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; public Infection (final int rate, final AltingChannelInput in, final AltingChannelInputInt scrollEvent, final ChannelOutput scrollConfigure, final ChannelOutput infoConfigure, final ChannelOutput rateConfigure, final ChannelOutput feedBack, final ChannelOutput toGraphics, final ChannelInput fromGraphics) { this.rate = rate; this.scrollEvent = scrollEvent; this.scrollConfigure = scrollConfigure; this.infoConfigure = infoConfigure; this.rateConfigure = rateConfigure; this.in = in; this.feedBack = feedBack; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; } // colours : Tree.green Tree.infected Tree.dead // ------- ---------- ------------- --------- protected final byte[] reds = { (byte)0x00, (byte)0xff, (byte)0x00}; protected final byte[] greens = { (byte)0xff, (byte)0x00, (byte)0x00}; protected final byte[] blues = { (byte)0x00, (byte)0x00, (byte)0xff}; // pixel array and key run-time parameters // --------------------------------------- protected byte[] pixels; // pixel array of Tree matrix protected byte[][] tree, last_tree; // matrix of Trees (plus spare) // Note: we will maintain in last_tree the previous state of the trees // in this Forest. protected int width, height; protected int[] count = new int[Tree.nStates]; // how many in each state // protected methods // ----------------- protected ColorModel createColorModel () { return new IndexColorModel (2, 3, reds, greens, blues); } protected final Random random = new Random (); protected final int range (int n) { int i = random.nextInt (); if (i < 0) { if (i == Integer.MIN_VALUE) { // guard against minint ! i = 42; } else { i = -i; } } return i % n; } protected void initialisePixels () { for (int ij = 0; ij < pixels.length; ij++) { pixels[ij] = Tree.green; } for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { tree[j][i] = Tree.green; } } count[Tree.green] = height*width; count[Tree.infected] = 0; count[Tree.dead] = 0; infoConfigure.write ((new Integer (count[Tree.infected] + count[Tree.dead])).toString ()); } protected void centrePixel () { int i = width/2; int j = height/2; pixels[(j*width) + i] = Tree.infected; count[tree[j][i]]--; tree[j][i] = Tree.infected; count[Tree.infected]++; infoConfigure.write ((new Integer (count[Tree.infected] + count[Tree.dead])).toString ()); } protected void randomPixel () { int i = range (width); int j = range (height); pixels[(j*width) + i] = Tree.infected; count[tree[j][i]]--; tree[j][i] = Tree.infected; count[Tree.infected]++; infoConfigure.write ((new Integer (count[Tree.infected] + count[Tree.dead])).toString ()); } protected void pixelise () { int i0 = 0; for (int i = 0; i < tree.length; i++) { System.arraycopy (tree[i], 0, pixels, i0, width); i0 = i0 + width; } } protected void byteMatrixCopy (byte[][] from, byte[][] to) { // assume: from and to are equally sized ... for (int i = 0; i < from.length; i++) { System.arraycopy (from[i], 0, to[i], 0, from[i].length); // fast copy } } protected void infect (int i, int j) { // possibly infect Tree[i][j] if ((0 <= i) && (i < height) && (0 <= j) && (j < width)) { if (last_tree[i][j] == Tree.green) { if (range (100) < rate) { count[tree[i][j]]--; tree[i][j] = Tree.infected; count[Tree.infected]++; } } } } protected void evolve () { // evolves the forest forward byteMatrixCopy (tree, last_tree); // forward one cycle for (int i = 0; i < height; i++) { final byte[] last_row_i = last_tree[i]; final byte[] row_i = tree[i]; for (int j = 0; j < width; j++) { switch (last_row_i[j]) { case Tree.green: break; case Tree.infected: infect (i + 1, j); infect (i - 1, j); infect (i, j + 1); infect (i, j - 1); if ((i % 2) == 0) { infect (i + 1, j + 1); infect (i - 1, j - 1); } else { infect (i - 1, j + 1); infect (i + 1, j - 1); } row_i[j] = Tree.dead; count[Tree.infected]--; count[Tree.dead]++; break; case Tree.dead: row_i[j] = Tree.green; count[Tree.dead]--; count[Tree.green]++; } } } } // report sets results to the number of green, infected and dead trees // (respectively) in the forest. It assumes results has a length of 3. // // Not used any more -- since these counts are maintained automatically. protected void report (int[] results) { results[Tree.green] = 0; results[Tree.infected] = 0; results[Tree.dead] = 0; for (int i = 0; i < height; i++) { final byte[] row_i = tree[i]; for (int j = 0; j < width; j++) { results[row_i[j]]++; } } } protected String rateString () { if (rate < 10) return " " + rate; if (rate < 100) return " " + rate; return " 100"; } public void run () { infoConfigure.write ((new Integer (0)).toString ()); rateConfigure.write ((new Integer (rate)).toString ()); scrollConfigure.write (Boolean.TRUE); toGraphics.write (GraphicsProtocol.GET_DIMENSION); final Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("Infection: graphics dimension = " + graphicsDim); width = graphicsDim.width; height = graphicsDim.height; pixels = new byte[width*height]; tree = new byte[height][width]; last_tree = new byte[height][width]; final ColorModel model = createColorModel (); final MemoryImageSource mis = new MemoryImageSource (width, height, model, pixels, 0, width); mis.setAnimated (true); mis.setFullBufferUpdates (true); toGraphics.write (new GraphicsProtocol.MakeMISImage (mis)); final Image image = (Image) fromGraphics.read (); final DisplayList display = new DisplayList (); toGraphics.write (new GraphicsProtocol.SetPaintable (display)); fromGraphics.read (); final GraphicsCommand[] drawImage = {new GraphicsCommand.DrawImage (image, 0, 0)}; display.set (drawImage); final Thread me = Thread.currentThread (); System.out.println ("Infection priority = " + me.getPriority ()); me.setPriority (Thread.MIN_PRIORITY); System.out.println ("Infection priority = " + me.getPriority ()); int state = InfectionControl.reset; final int STATS_INTERVAL = 1; int countDown = STATS_INTERVAL; final Guard[] guard = {in, scrollEvent, new Skip ()}; final boolean[] preCondition = {true, true, false}; final int NEW_STATE = 0; final int SCROLL = 1; final int RUNNING = 2; final Alternative alt = new Alternative (guard); initialisePixels (); mis.newPixels (); while (true) { switch (alt.priSelect (preCondition)) { case NEW_STATE: state = ((Integer) in.read ()).intValue (); switch (state) { case InfectionControl.reset: System.out.println ("Infection: reset"); initialisePixels (); mis.newPixels (); preCondition[RUNNING] = false; break; case InfectionControl.random: System.out.println ("Infection: random"); randomPixel (); mis.newPixels (); preCondition[RUNNING] = false; break; case InfectionControl.centre: System.out.println ("Infection: centre"); centrePixel (); mis.newPixels (); preCondition[RUNNING] = false; break; case InfectionControl.running: System.out.println ("Infection: running"); preCondition[RUNNING] = true; break; case InfectionControl.frozen: System.out.println ("Infection: frozen"); preCondition[RUNNING] = false; break; } break; case SCROLL: rate = 100 - scrollEvent.read (); rateConfigure.write ((new Integer (rate)).toString ()); System.out.println ("Infection: scrolling ... " + rate); break; case RUNNING: evolve (); pixelise (); mis.newPixels (); if ((count[Tree.infected] + count[Tree.dead]) == 0) { infoConfigure.write ((new Integer (count[Tree.infected] + count[Tree.dead])).toString ()); // System.out.println ("Infection: all healthy !!!"); preCondition[RUNNING] = false; feedBack.write (Boolean.TRUE); } if (countDown == 0) { countDown = STATS_INTERVAL; infoConfigure.write ((new Integer (count[Tree.infected] + count[Tree.dead])).toString ()); // System.out.print ("Infection:"); // for (int t = 0; t < Tree.nStates; t++) { // System.out.print (" " + count[t]); // } // System.out.println (); } else { countDown--; } break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/infect/InfectNetwork.java0000644000000000000000000001575111111352066020362 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.util.ints.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ class InfectNetwork implements CSProcess { private final ActiveCanvas activeCanvas; private final ActiveScrollbar scrollBar; private final ActiveButton[] button; private final PseudoButton pseudoButton; private final ActiveLabel infoLabel; private final ActiveLabel rateLabel; private final InfectionControl control; private final Infection infection; public InfectNetwork (final int rate, final Container parent) { parent.setLayout (new BorderLayout ()); parent.setBackground (Color.blue); System.out.println ("Infect creating channels ..."); final One2OneChannel[] event = Channel.one2oneArray (InfectionControl.NUMBER + 1, new OverWriteOldestBuffer (1)); final One2OneChannel[] configure = Channel.one2oneArray (InfectionControl.NUMBER + 1); final One2OneChannelInt scrollEvent = Channel.one2oneInt (new OverWriteOldestBufferInt (1)); final One2OneChannel scrollConfigure = Channel.one2one (); final One2OneChannel report = Channel.one2one (); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); final One2OneChannel feedBack = Channel.one2one (); final One2OneChannel infoConfigure = Channel.one2one (); final One2OneChannel rateConfigure = Channel.one2one (); System.out.println ("InfectNetwork created channels"); System.out.println ("InfectNetwork creating ActiveButtons ..."); button = new ActiveButton[InfectionControl.NUMBER]; for (int i = 0; i < InfectionControl.NUMBER; i++) { button[i] = new ActiveButton (configure[i].in (), event[i].out (), "XXXXXXXXXXXXX"); button[i].setBackground (Color.white); System.out.println (" button " + i); } infoLabel = new ActiveLabel (infoConfigure.in (), "XXXXXXXXXXXXX"); infoLabel.setAlignment (Label.CENTER); infoLabel.setBackground (Color.white); rateLabel = new ActiveLabel (rateConfigure.in (), "XXXXXXXXXXXXX"); rateLabel.setAlignment (Label.CENTER); rateLabel.setBackground (Color.white); System.out.println ("InfectNetwork created ActiveButtons ... now adding them to the parent ..."); final Panel north = new Panel (); final Panel south = new Panel (); north.add (button[InfectionControl.RESET]); north.add (infoLabel); north.add (button[InfectionControl.FREEZE]); south.add (button[InfectionControl.RANDOM]); south.add (rateLabel); south.add (button[InfectionControl.CENTRE]); parent.add ("North", north); parent.add ("South", south); System.out.println ("InfectNetwork creating ActiveScrollbar ..."); scrollBar = new ActiveScrollbar (scrollConfigure.in (), scrollEvent.out (), Scrollbar.VERTICAL, 100 - rate, 25, 0, 125); scrollBar.setBackground (Color.white); System.out.println ("InfectNetwork created ActiveScrollbar ... now adding it to the parent ..."); parent.add ("West", scrollBar); System.out.println ("InfectNetwork now creating ActiveCanvas ..."); activeCanvas = new ActiveCanvas (); activeCanvas.setGraphicsChannels (toGraphics.in (), fromGraphics.out ()); activeCanvas.setSize (parent.getSize ()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. System.out.println ("InfectNetwork adding ActiveCanvas to the parent ..."); parent.add ("Center", activeCanvas); System.out.println ("InfectNetwork creating infectionControl ..."); control = new InfectionControl (Channel.getInputArray (event), Channel.getOutputArray (configure), report.out ()); System.out.println ("InfectNetwork now creating infection ..."); infection = new Infection (rate, report.in (), scrollEvent.in (), scrollConfigure.out (), infoConfigure.out (), rateConfigure.out (), feedBack.out (), toGraphics.out (), fromGraphics.in ()); System.out.println ("InfectNetwork creating pseudo button ..."); pseudoButton = new PseudoButton (configure[InfectionControl.NUMBER].in (), event[InfectionControl.NUMBER].out (), feedBack.in ()); } public void run () { System.out.println ("Infect starting up the network ..."); new Parallel ( new CSProcess[] { activeCanvas, scrollBar, pseudoButton, infoLabel, rateLabel, control, infection, new Parallel (button) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/0000755000000000000000000000000011410045043014726 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/alting/FairPlex.java0000644000000000000000000000501211111352066017305 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class FairPlex implements CSProcess { private final AltingChannelInput[] in; private final ChannelOutput out; public FairPlex (final AltingChannelInput[] in, final ChannelOutput out) { this.in = in; this.out = out; } public void run () { final Alternative alt = new Alternative (in); while (true) { final int index = alt.fairSelect (); out.write (in[index].read ()); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/StressedWriter.java0000644000000000000000000000604011111352066020566 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class StressedWriter implements CSProcess { private final ChannelOutput out; private final int channel; private final int writer; private final String id; public StressedWriter (ChannelOutput out, int channel, int writer) { this.out = out; this.channel = channel; this.writer = writer; this.id = "channel " + channel + " writer " + writer; } public void run () { int n = 0; StressedPacket stressedPacketA = new StressedPacket (writer); StressedPacket stressedPacketB = new StressedPacket (writer); while (true) { // for (int i = 0; i < writer; i++) System.out.print (" "); // System.out.println (id + " " + n); stressedPacketA.n = n; out.write (stressedPacketA); n++; // for (int i = 0; i < writer; i++) System.out.print (" "); // System.out.println (id + " " + n); stressedPacketB.n = n; out.write (stressedPacketB); n++; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/Regular.java0000644000000000000000000000533611111352066017205 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class Regular implements CSProcess { final private ChannelOutput out; final private Integer N; final private long interval; public Regular (final ChannelOutput out, final int n, final long interval) { this.out = out; N = new Integer (n); this.interval = interval; } public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read (); // read the (absolute) time while (true) { out.write (N); timeout += interval; // set the next (absolute) timeout tim.after (timeout); // wait until that (absolute) timeout } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/Polling.java0000644000000000000000000000765411111352066017215 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class Polling implements CSProcess { private final AltingChannelInput in0; private final AltingChannelInput in1; private final AltingChannelInput in2; private final AltingChannelInput in3; private final AltingChannelInput in4; private final ChannelOutput out; public Polling (final AltingChannelInput in0, final AltingChannelInput in1, final AltingChannelInput in2, final AltingChannelInput in3, final AltingChannelInput in4, final ChannelOutput out) { this.in0 = in0; this.in1 = in1; this.in2 = in2; this.in3 = in3; this.in4 = in4; this.out = out; } public void run() { final Skip skip = new Skip (); final Guard[] guards = {in0, in1, in2, in3, in4, skip}; final Alternative alt = new Alternative (guards); while (true) { switch (alt.priSelect ()) { case 0: // ... process data pending on channel in0 out.write (in0.read ()); break; case 1: // ... process data pending on channel in1 out.write (in1.read ()); break; case 2: // ... process data pending on channel in2 out.write (in2.read ()); break; case 3: // ... process data pending on channel in2 out.write (in3.read ()); break; case 4: // ... process data pending on channel in2 out.write (in4.read ()); break; case 5: // ... nothing available for the above ... // ... so get on with something else for a while ... // ... then loop around and poll again ... try {Thread.sleep (400);} catch (InterruptedException e) {} out.write ("... so getting on with something else for a while ..."); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/FairPlexTime.java0000644000000000000000000000613711111352066020135 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class FairPlexTime implements CSProcess { private final AltingChannelInput[] in; private final ChannelOutput out; private final long timeout; public FairPlexTime (final AltingChannelInput[] in, final ChannelOutput out, final long timeout) { this.in = in; this.out = out; this.timeout = timeout; } public void run () { final Guard[] guards = new Guard[in.length + 1]; System.arraycopy (in, 0, guards, 0, in.length); final CSTimer tim = new CSTimer (); final int timerIndex = in.length; guards[timerIndex] = tim; final Alternative alt = new Alternative (guards); boolean running = true; tim.setAlarm (System.currentTimeMillis () + timeout); while (running) { final int index = alt.fairSelect (); if (index == timerIndex) { running = false; } else { out.write (in[index].read ()); } } System.out.println ("Goodbye from FairPlexTime ..."); System.exit (0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/0000755000000000000000000000000011410045043015703 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/FairPlexTimeIntTest.java0000644000000000000000000000667411111352066022433 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.PrinterInt; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class FairPlexTimeIntTest { public static final String TITLE = "Fair multiplexing (fair-Alt) [with integers]"; public static final String DESCR = "Shows a fair-Alt in action. Five processes are created which generate numbers at 5ms intervals. " + "A multiplexer will use 'fairSelect' to ensure that each of the channels gets served. The output " + "shows which data was accepted by the multiplexer. The fairness ensures that the higher numbered " + "channels do not get starved. A timeout guard is also used to stop the demonstration after 10 " + "seconds. Contrast this with the Pri-Alting demonstration."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final One2OneChannelInt[] a = Channel.one2oneIntArray (5); final One2OneChannelInt b = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new RegularInt (a[0].out(), 0, 5), new RegularInt (a[1].out(), 1, 5), new RegularInt (a[2].out(), 2, 5), new RegularInt (a[3].out(), 3, 5), new RegularInt (a[4].out(), 4, 5), new FairPlexTimeInt (Channel.getInputArray(a), b.out(), 10000), new PrinterInt (b.in(), "FairPlexTimeTest ==> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/RegularInt.java0000644000000000000000000000533511111352066020634 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class RegularInt implements CSProcess { final private ChannelOutputInt out; final private int n; final private long interval; public RegularInt (final ChannelOutputInt out, final int n, final long interval) { this.out = out; this.n = n; this.interval = interval; } public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read (); // read the (absolute) time while (true) { out.write (n); timeout += interval; // set the next (absolute) timeout tim.after (timeout); // wait until that (absolute) timeout } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/StressedReaderInt.java0000644000000000000000000001054211111352066022146 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class StressedReaderInt implements CSProcess { private AltingChannelInputInt[] c; private final int nWritersPerChannel; public StressedReaderInt (AltingChannelInputInt[] c, final int nWritersPerChannel) { this.c = c; this.nWritersPerChannel = nWritersPerChannel; } public void run () { final int seconds = 1000; final int initialWait = 5; System.out.println ("\nWait (" + initialWait + " seconds) for all the writers to get going ..."); CSTimer tim = new CSTimer (); long timeout = tim.read () + (initialWait*seconds); tim.after (timeout); System.out.println ("OK - that should be long enough ...\n"); int[][] n = new int[c.length][nWritersPerChannel]; for (int channel = 0; channel < c.length; channel++) { for (int i = 0; i < nWritersPerChannel; i++) { int thing = c[channel].read (); n[channel][thing % nWritersPerChannel] = thing / nWritersPerChannel; for (int chan = 0; chan < channel; chan++) System.out.print (" "); System.out.println ("channel " + channel + " writer " + (thing % nWritersPerChannel) + " read " + (thing / nWritersPerChannel)); } } Alternative alt = new Alternative (c); int counter = 0, tock = 0; while (true) { if (counter == 0) { System.out.print ("Tock " + tock + " : "); int total = 0; for (int channel = 0; channel < n.length; channel++) { System.out.print (n[channel][tock % nWritersPerChannel] + " "); for (int i = 0; i < nWritersPerChannel; i++) { total += n[channel][i]; } } System.out.println (": " + total); tock++; counter = 10000; } counter--; int channel = alt.fairSelect (); int packet = c[channel].read (); n[channel][packet % nWritersPerChannel] = packet / nWritersPerChannel; // for (int chan = 0; chan < channel; chan++) System.out.print (" "); // System.out.println ("channel " + channel + // " writer " + (packet % nWritersPerChannel) + // " read " + (packet / nWritersPerChannel)); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/PriPlexTimeInt.java0000644000000000000000000000625611111352066021440 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class PriPlexTimeInt implements CSProcess { private final AltingChannelInputInt[] in; private final ChannelOutputInt out; private final long timeout; public PriPlexTimeInt (final AltingChannelInputInt[] in, final ChannelOutputInt out, final long timeout) { this.in = in; this.out = out; this.timeout = timeout; } public void run () { final Guard[] guards = new Guard[in.length + 1]; System.arraycopy (in, 0, guards, 0, in.length); final CSTimer tim = new CSTimer (); final int timerIndex = in.length; guards[timerIndex] = tim; final Alternative alt = new Alternative (guards); boolean running = true; tim.setAlarm (System.currentTimeMillis () + timeout); while (running) { final int index = alt.priSelect (); if (index == timerIndex) { running = false; } else { out.write (in[index].read ()); } } //System.out.println ("Goodbye from PriPlexTime ..."); //System.out.println ("You'll need to ctl, sorry ..."); System.exit(0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/FairPlexTimeInt.java0000644000000000000000000000616111111352066021562 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class FairPlexTimeInt implements CSProcess { private final AltingChannelInputInt[] in; private final ChannelOutputInt out; private final long timeout; public FairPlexTimeInt (final AltingChannelInputInt[] in, final ChannelOutputInt out, final long timeout) { this.in = in; this.out = out; this.timeout = timeout; } public void run () { final Guard[] guards = new Guard[in.length + 1]; System.arraycopy (in, 0, guards, 0, in.length); final CSTimer tim = new CSTimer (); final int timerIndex = in.length; guards[timerIndex] = tim; final Alternative alt = new Alternative (guards); boolean running = true; tim.setAlarm (System.currentTimeMillis () + timeout); while (running) { final int index = alt.fairSelect (); if (index == timerIndex) { running = false; } else { out.write (in[index].read ()); } } System.out.println ("Goodbye from FairPlexTime ..."); System.exit(0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/PriPlexInt.java0000644000000000000000000000503111111352066020607 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class PriPlexInt implements CSProcess { private final AltingChannelInputInt[] in; private final ChannelOutputInt out; public PriPlexInt (final AltingChannelInputInt[] in, final ChannelOutputInt out) { this.in = in; this.out = out; } public void run () { final Alternative alt = new Alternative (in); while (true) { final int index = alt.priSelect (); out.write (in[index].read ()); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/PollingIntTest.java0000644000000000000000000000716211111352066021477 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.PrinterInt; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class PollingIntTest { public static final String TITLE = "Polling Multiplexor [with integers]"; public static final String DESCR = "Shows a pri-Alt with a skip guard being used to poll the inputs. Five processes generate numbers " + "at 1s, 2s, 3s, 4s and 5s intervals. The number generated indicates the process generating it. If " + "no data is available on a polling cycle the polling process will wait for 400ms before polling " + "again. It could however be coded to perform some useful computation between polling cycles.\n" + "\n" + "The polling is unfair although this is not noticeable with these timings. If the interval at " + "which the numbers are generated is shortened then the higher numbered processes may become starved."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final One2OneChannelInt[] a = Channel.one2oneIntArray(5); final One2OneChannelInt b = Channel.one2oneInt(); new Parallel ( new CSProcess[] { new RegularInt (a[0].out(), 1000, 1000), new RegularInt (a[1].out(), 2000, 2000), new RegularInt (a[2].out(), 3000, 3000), new RegularInt (a[3].out(), 4000, 4000), new RegularInt (a[4].out(), 5000, 5000), new PollingInt (a[0].in(), a[1].in(), a[2].in(), a[3].in(), a[4].in(), b.out()), new PrinterInt (b.in(), "PollingTest ==> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/StressedAltInt.java0000644000000000000000000000740211111352066021465 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class StressedAltInt { public static final String TITLE = "Stressed Alt [with integers]"; public static final String DESCR = "Shows the fairness of an Alt at a high level of stress from the writing channels. " + "Many writers will be writing to each of the channels (each is an Any-One channel) with no delay " + "between writes. The ALT will be well behaved under such " + "stress, still exhibiting fairness and no loss of data.\n" + "\n" + "Every 10000 cycles the reader will display the values read from each of the channels. If the Alt " + "is serving the channels fairly the numbers will all be increasing together (though maybe wrapping around " + "when the 2^31 limit for positive integers is reached). If the Alt is not serving them fairly then " + "there will be an imbalance in the rate of increase between the channels."; public static void main (String [] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final int nChannels = 8; final int nWritersPerChannel = 8; Any2OneChannelInt[] c = Channel.any2oneIntArray(nChannels); StressedWriterInt[] writers = new StressedWriterInt[nChannels*nWritersPerChannel]; for (int channel = 0; channel < nChannels; channel++) { for (int i = 0; i < nWritersPerChannel; i++) { writers[(channel*nWritersPerChannel) + i] = new StressedWriterInt (c[channel].out(), channel, i, nWritersPerChannel); } } new Parallel ( new CSProcess[] { new Parallel (writers), new StressedReaderInt (Channel.getInputArray(c), nWritersPerChannel) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/VariateInt.java0000644000000000000000000000562611111352066020631 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public final class VariateInt implements CSProcess { private final ChannelOutputInt out; private final int start, stop, n; public VariateInt (final ChannelOutputInt out, final int start, final int stop, final int n) { this.out = out; this.start = start; this.stop = stop; this.n = n; } public void run () { final int innerCycleTime = n*start; final CSTimer tim = new CSTimer (); long timeout = tim.read (); while (true) { int interval = start; while (interval >= stop) { final int innerCycles = innerCycleTime/interval; for (int i = 0; i < innerCycles; i++) { out.write (interval); timeout += (long) interval; tim.after (timeout); } interval /= 2; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/PollingInt.java0000644000000000000000000000774511111352066020646 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class PollingInt implements CSProcess { private final AltingChannelInputInt in0; private final AltingChannelInputInt in1; private final AltingChannelInputInt in2; private final AltingChannelInputInt in3; private final AltingChannelInputInt in4; private final ChannelOutputInt out; public PollingInt (final AltingChannelInputInt in0, final AltingChannelInputInt in1, final AltingChannelInputInt in2, final AltingChannelInputInt in3, final AltingChannelInputInt in4, final ChannelOutputInt out) { this.in0 = in0; this.in1 = in1; this.in2 = in2; this.in3 = in3; this.in4 = in4; this.out = out; } public void run() { final Skip skip = new Skip (); final Guard[] guards = {in0, in1, in2, in3, in4, skip}; final Alternative alt = new Alternative (guards); while (true) { switch (alt.priSelect ()) { case 0: // ... process data pending on channel in0 out.write (in0.read ()); break; case 1: // ... process data pending on channel in1 out.write (in1.read ()); break; case 2: // ... process data pending on channel in2 out.write (in2.read ()); break; case 3: // ... process data pending on channel in2 out.write (in3.read ()); break; case 4: // ... process data pending on channel in2 out.write (in4.read ()); break; case 5: // ... nothing available for the above ... // ... so get on with something else for a while ... // ... then loop around and poll again ... try {Thread.sleep (400);} catch (InterruptedException e) {} System.out.println ("... so getting on with something else for a while ..."); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/PriPlexTimeIntTest.java0000644000000000000000000000672311111352066022277 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.PrinterInt; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class PriPlexTimeIntTest { public static final String TITLE = "Prioritised multiplexing (pri-Alt) [with integers]"; public static final String DESCR = "Shows a pri-Alt in action. Five processes are created which generate numbers at 5ms intervals. " + "A multiplexer will use 'priSelect' to serve lower numbered processes first. Contrast this with " + "the fair multiplexor. Higher numbered processes will be starved and the timeout to stop the " + "demonstration after 10 seconds may never be serviced."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final One2OneChannelInt[] a = Channel.one2oneIntArray(5); final One2OneChannelInt b = Channel.one2oneInt(); new Parallel ( // this won't see the higher new CSProcess[] { // indexed guards, including new RegularInt (a[0].out(), 0, 5), // the timeout ... probably. new RegularInt (a[1].out(), 1, 5), new RegularInt (a[2].out(), 2, 5), new RegularInt (a[3].out(), 3, 5), new RegularInt (a[4].out(), 4, 5), new PriPlexTimeInt (Channel.getInputArray(a), b.out(), 10000), new PrinterInt (b.in(), "PriPlexTimeTest ==> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/RegulateInt.java0000644000000000000000000000707011111352066021001 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public final class RegulateInt implements CSProcess { private final AltingChannelInputInt in, reset; private final ChannelOutputInt out; private final long initialInterval; public RegulateInt (final AltingChannelInputInt in, final AltingChannelInputInt reset, final ChannelOutputInt out, final long initialInterval) { this.in = in; this.reset = reset; this.out = out; this.initialInterval = initialInterval; } public void run () { final CSTimer tim = new CSTimer (); final Guard[] guards = {reset, tim, in}; // prioritised order final int RESET = 0; // index into guards final int TIM = 1; // index into guards final int IN = 2; // index into guards final Alternative alt = new Alternative (guards); int x = 0; // holding object long interval = initialInterval; long timeout = tim.read () + interval; tim.setAlarm (timeout); while (true) { switch (alt.priSelect ()) { case RESET: interval = (long) reset.read (); timeout = tim.read (); // fall through case TIM: out.write (x); timeout += interval; tim.setAlarm (timeout); break; case IN: x = in.read (); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/RegulateIntTest.java0000644000000000000000000001003611111352066021635 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.PrinterInt; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class RegulateIntTest { public static final String TITLE = "Regulated Process Behaviour [with integers]"; public static final String DESCR = "Shows how a process with periodic behaviour can use an alt to have its actions regulated externally. " + "The Regulate process creates numbers at regular intervals. Instead of sleeping for those intervals " + "it makes use of a timeout guard within an Alt. Other guards allow the timeout interval to be reset " + "and the number it outputs to be modified."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final One2OneChannelInt a = Channel.one2oneInt(); final One2OneChannelInt b = Channel.one2oneInt(); final One2OneChannelInt reset = Channel.one2oneInt(); new Parallel ( new CSProcess[] { new VariateInt (a.out(), 5000, 10, 2), new RegulateInt (a.in(), reset.in(), b.out(), 500), new PrinterInt (b.in(), "RegulateTest ==> ", "\n"), new CSProcess () { // this controls the Regulate process, switching its firing // rate between a half and one second. The switches occur // every five seconds. public void run () { final int halfSecond = 500; final int second = 1000; final CSTimer tim = new CSTimer (); long timeout = tim.read (); while (true) { timeout += 5000; tim.after (timeout); System.out.println (" <== now every second"); reset.out().write (second); timeout += 5000; tim.after (timeout); System.out.println (" <== now every half second"); reset.out().write (halfSecond); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/FairPlexInt.java0000644000000000000000000000503411111352066020741 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class FairPlexInt implements CSProcess { private final AltingChannelInputInt[] in; private final ChannelOutputInt out; public FairPlexInt (final AltingChannelInputInt[] in, final ChannelOutputInt out) { this.in = in; this.out = out; } public void run () { final Alternative alt = new Alternative (in); while (true) { final int index = alt.fairSelect (); out.write (in[index].read ()); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/ints/StressedWriterInt.java0000644000000000000000000000560211111352066022221 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class StressedWriterInt implements CSProcess { private final ChannelOutputInt out; private final int channel; private final int writer; private final int nWritersPerChannel; private final String id; public StressedWriterInt (ChannelOutputInt out, int channel, int writer, final int nWritersPerChannel) { this.out = out; this.channel = channel; this.writer = writer; this.nWritersPerChannel = nWritersPerChannel; this.id = "channel " + channel + " writer " + writer; } public void run () { int n = writer; while (true) { // for (int i = 0; i < writer; i++) System.out.print (" "); // System.out.println (id + " " + (n / nWritersPerChannel)); out.write (n); n += nWritersPerChannel; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/FairPlexTimeTest.java0000644000000000000000000000657211111352066021000 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.Printer; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class FairPlexTimeTest { public static final String TITLE = "Fair multiplexing (fair-Alt)"; public static final String DESCR = "Shows a fair-Alt in action. Five processes are created which generate numbers at 5ms intervals. " + "A multiplexer will use 'fairSelect' to ensure that each of the channels gets served. The output " + "shows which data was accepted by the multiplexer. The fairness ensures that the higher numbered " + "channels do not get starved. A timeout guard is also used to stop the demonstration after 10 " + "seconds. Contrast this with the Pri-Alting demonstration."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final One2OneChannel[] a = Channel.one2oneArray(5); final One2OneChannel b = Channel.one2one(); new Parallel ( new CSProcess[] { new Regular (a[0].out(), 0, 5), new Regular (a[1].out(), 1, 5), new Regular (a[2].out(), 2, 5), new Regular (a[3].out(), 3, 5), new Regular (a[4].out(), 4, 5), new FairPlexTime (Channel.getInputArray(a), b.out(), 10000), new Printer (b.in(), "FairPlexTimeTest ==> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/Variate.java0000644000000000000000000000567311111352066017203 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class Variate implements CSProcess { private final ChannelOutput out; private final int start, stop, n; public Variate (final ChannelOutput out, final int start, final int stop, final int n) { this.out = out; this.start = start; this.stop = stop; this.n = n; } public void run () { final int innerCycleTime = n*start; final CSTimer tim = new CSTimer (); long timeout = tim.read (); while (true) { int interval = start; while (interval >= stop) { final Integer Interval = new Integer (interval); final int innerCycles = innerCycleTime/interval; for (int i = 0; i < innerCycles; i++) { out.write (Interval); timeout += (long) interval; tim.after (timeout); } interval /= 2; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/RegulateTest.java0000644000000000000000000001000011111352066020174 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.Printer; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class RegulateTest { public static final String TITLE = "Regulated Process Behaviour"; public static final String DESCR = "Shows how a process with periodic behaviour can use an alt to have its actions regulated externally. " + "The Regulate process creates numbers at regular intervals. Instead of sleeping for those intervals " + "it makes use of a timeout guard within an Alt. Other guards allow the timeout interval to be reset " + "and the number it outputs to be modified."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final One2OneChannel a = Channel.one2one(); final One2OneChannel b = Channel.one2one(); final One2OneChannel reset = Channel.one2one(); new Parallel ( new CSProcess[] { new Variate (a.out(), 5000, 10, 2), new Regulate (a.in(), reset.in(), b.out(), 500), new Printer (b.in(), "RegulateTest ==> ", "\n"), new CSProcess () { // this controls the Regulate process, switching its firing // rate between a half and one second. The switches occur // every five seconds. public void run () { final Long halfSecond = new Long (500); final Long second = new Long (1000); final CSTimer tim = new CSTimer (); long timeout = tim.read (); while (true) { timeout += 5000; tim.after (timeout); System.out.println (" <== now every second"); reset.out().write (second); timeout += 5000; tim.after (timeout); System.out.println (" <== now every half second"); reset.out().write (halfSecond); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/PriPlex.java0000644000000000000000000000500711111352066017162 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class PriPlex implements CSProcess { private final AltingChannelInput[] in; private final ChannelOutput out; public PriPlex (final AltingChannelInput[] in, final ChannelOutput out) { this.in = in; this.out = out; } public void run () { final Alternative alt = new Alternative (in); while (true) { final int index = alt.priSelect (); out.write (in[index].read ()); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/Regulate.java0000644000000000000000000000705711111352066017356 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class Regulate implements CSProcess { private final AltingChannelInput in, reset; private final ChannelOutput out; private final long initialInterval; public Regulate (final AltingChannelInput in, final AltingChannelInput reset, final ChannelOutput out, final long initialInterval) { this.in = in; this.reset = reset; this.out = out; this.initialInterval = initialInterval; } public void run () { final CSTimer tim = new CSTimer (); final Guard[] guards = {reset, tim, in}; // prioritised order final int RESET = 0; // index into guards final int TIM = 1; // index into guards final int IN = 2; // index into guards final Alternative alt = new Alternative (guards); Object x = null; // holding object long interval = initialInterval; long timeout = tim.read () + interval; tim.setAlarm (timeout); while (true) { switch (alt.priSelect ()) { case RESET: interval = ((Long) reset.read ()).longValue (); timeout = tim.read (); // fall through case TIM: out.write (x); timeout += interval; tim.setAlarm (timeout); break; case IN: x = in.read (); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/StressedPacket.java0000644000000000000000000000431711111352066020526 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ public class StressedPacket { public final int writer; public int n; public StressedPacket (final int writer) { this.writer = writer; } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/PriPlexTime.java0000644000000000000000000000620211111352066017777 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class PriPlexTime implements CSProcess { private final AltingChannelInput[] in; private final ChannelOutput out; private final long timeout; public PriPlexTime (final AltingChannelInput[] in, final ChannelOutput out, final long timeout) { this.in = in; this.out = out; this.timeout = timeout; } public void run () { final Guard[] guards = new Guard[in.length + 1]; System.arraycopy (in, 0, guards, 0, in.length); final CSTimer tim = new CSTimer (); final int timerIndex = in.length; guards[timerIndex] = tim; final Alternative alt = new Alternative (guards); boolean running = true; tim.setAlarm (System.currentTimeMillis () + timeout); while (running) { final int index = alt.priSelect (); if (index == timerIndex) { running = false; } else { out.write (in[index].read ()); } } System.out.println ("Goodbye from PriPlexTime ..."); System.out.println ("You'll need to ctl, sorry ..."); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/PollingTest.java0000644000000000000000000000704711111352066020051 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.Printer; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class PollingTest { public static final String TITLE = "Polling Multiplexor"; public static final String DESCR = "Shows a pri-Alt with a skip guard being used to poll the inputs. Five processes generate numbers " + "at 1s, 2s, 3s, 4s and 5s intervals. The number generated indicates the process generating it. If " + "no data is available on a polling cycle the polling process will wait for 400ms before polling " + "again. It could however be coded to perform some useful computation between polling cycles.\n" + "\n" + "The polling is unfair although this is not noticeable with these timings. If the interval at " + "which the numbers are generated is shortened then the higher numbered processes may become starved."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final One2OneChannel[] a = Channel.one2oneArray(5); final One2OneChannel b = Channel.one2one(); new Parallel ( new CSProcess[] { new Regular (a[0].out(), 1, 1000), new Regular (a[1].out(), 2, 2000), new Regular (a[2].out(), 3, 3000), new Regular (a[3].out(), 4, 4000), new Regular (a[4].out(), 5, 5000), new Polling (a[0].in(), a[1].in(), a[2].in(), a[3].in(), a[4].in(), b.out()), new Printer (b.in(), "PollingTest ==> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/StressedReader.java0000644000000000000000000001054011111352066020514 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class StressedReader implements CSProcess { private final AltingChannelInput[] c; private final int nWritersPerChannel; public StressedReader (final AltingChannelInput[] c, final int nWritersPerChannel) { this.c = c; this.nWritersPerChannel = nWritersPerChannel; } public void run () { final int seconds = 1000; final int initialWait = 5; System.out.println ("\nWait (" + initialWait + " seconds) for all the writers to get going ..."); CSTimer tim = new CSTimer (); long timeout = tim.read () + (initialWait*seconds); tim.after (timeout); System.out.println ("OK - that should be long enough ...\n"); int[][] n = new int[c.length][nWritersPerChannel]; for (int channel = 0; channel < c.length; channel++) { for (int i = 0; i < nWritersPerChannel; i++) { StressedPacket stressedPacket = (StressedPacket) c[channel].read (); n[channel][stressedPacket.writer] = stressedPacket.n; for (int chan = 0; chan < channel; chan++) System.out.print (" "); System.out.println ("channel " + channel + " writer " + stressedPacket.writer + " read " + stressedPacket.n); } } Alternative alt = new Alternative (c); int counter = 0, tock = 0; while (true) { if (counter == 0) { System.out.print ("Tock " + tock + " : "); int total = 0; for (int channel = 0; channel < n.length; channel++) { System.out.print (n[channel][tock % nWritersPerChannel] + " "); for (int i = 0; i < nWritersPerChannel; i++) { total += n[channel][i]; } } System.out.println (": " + total); tock++; counter = 10000; } counter--; int channel = alt.fairSelect (); StressedPacket stressedPacket = (StressedPacket) c[channel].read (); n[channel][stressedPacket.writer] = stressedPacket.n; // for (int chan = 0; chan < channel; chan++) System.out.print (" "); // System.out.println ("channel " + channel + // " writer " + stressedPacket.writer + // " read " + stressedPacket.n); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/StressedAlt.java0000644000000000000000000000743011111352066020036 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class StressedAlt { public static final String TITLE = "Stressed Alt"; public static final String DESCR = "Shows the fairness of an Alt at a high level of stress from the writing channels. Many writers " + "will be writing to each of the channels (each is an Any-One channel) with no delay between writes. " + "The ALT will be well behaved under such stress, still exhibiting fairness and no loss of data.\n" + "\n" + "Every 10000 cycles the reader will display the values read from each of the channels. If the Alt " + "is serving the channels fairly the numbers will all be increasing together (though maybe wrapping around " + "when the 2^31 limit for positive integers is reached). If the Alt is not serving them fairly then " + "there will be an imbalance in the rate of increase between the channels."; public static void main (String [] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final int nChannels = 8; final int nWritersPerChannel = 8; //Any2OneChannel[] c = Channel.any2oneArray (nChannels, new OverWriteOldestBuffer (1)); Any2OneChannel[] c = Channel.any2oneArray (nChannels); StressedWriter[] writers = new StressedWriter[nChannels*nWritersPerChannel]; for (int channel = 0; channel < nChannels; channel++) { for (int i = 0; i < nWritersPerChannel; i++) { writers[(channel*nWritersPerChannel) + i] = new StressedWriter (c[channel].out(), channel, i); } } new Parallel ( new CSProcess[] { new Parallel (writers), new StressedReader (Channel.getInputArray(c), nWritersPerChannel) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/alting/PriPlexTimeTest.java0000644000000000000000000000663211111352066020646 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.Printer; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class PriPlexTimeTest { public static final String TITLE = "Prioritised multiplexing (pri-Alt)"; public static final String DESCR = "Shows a pri-Alt in action. Five processes are created which generate numbers at 5ms intervals. " + "A multiplexer will use 'priSelect' to serve lower numbered processes first. Contrast this with " + "the fair multiplexor. Higher numbered processes will be starved and the timeout to stop the " + "demonstration after 10 seconds may never be serviced."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final One2OneChannel[] a = Channel.one2oneArray(5); final One2OneChannel b = Channel.one2one(); new Parallel ( // this won't see the higher new CSProcess[] { // indexed guards, including new Regular (a[0].out(), 0, 5), // the timeout ... probably. new Regular (a[1].out(), 1, 5), new Regular (a[2].out(), 2, 5), new Regular (a[3].out(), 3, 5), new Regular (a[4].out(), 4, 5), new PriPlexTime (Channel.getInputArray(a), b.out(), 10000), new Printer (b.in(), "PriPlexTimeTest ==> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/outputGuards/0000755000000000000000000000000011410045036016160 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/outputGuards/SymmetricA.java0000644000000000000000000000162611111352066021107 0ustar import org.jcsp.lang.*; import java.util.Random; class SymmetricA implements CSProcess { private final AltingChannelInputInt in; private final AltingChannelOutputInt out; public SymmetricA (AltingChannelInputInt in, AltingChannelOutputInt out) { this.in = in; this.out = out; } public void run () { final Alternative alt = new Alternative (new Guard[] {in , out}); final int IN = 0, OUT = 1; final Random rand = new Random (); final CSTimer tim = new CSTimer (); int a = -1, b = -1; while (true) { int period = (rand.nextInt ()) % 16; tim.sleep (period); a++; switch (alt.fairSelect ()) { case IN: b = in.read (); System.out.println (b); break; case OUT: out.write (a); System.out.println ("\t\t" + a); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/outputGuards/PathologicalDemo.java0000644000000000000000000000105011111352066022234 0ustar import org.jcsp.lang.Channel; import org.jcsp.lang.One2OneChannelSymmetricInt; import org.jcsp.lang.CSProcess; import org.jcsp.lang.Parallel; public class PathologicalDemo { public static void main (String[] argv) { final One2OneChannelSymmetricInt c = Channel.one2oneSymmetricInt (); final One2OneChannelSymmetricInt d = Channel.one2oneSymmetricInt (); new Parallel ( new CSProcess[] { new SymmetricA (c.in (), d.out ()), new SymmetricB (d.in (), c.out ()) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/outputGuards/SymmetricB.java0000644000000000000000000000163711111352066021112 0ustar import org.jcsp.lang.*; import java.util.Random; class SymmetricB implements CSProcess { private final AltingChannelInputInt in; private final AltingChannelOutputInt out; public SymmetricB (AltingChannelInputInt in, AltingChannelOutputInt out) { this.in = in; this.out = out; } public void run () { final Alternative alt = new Alternative (new Guard[] {in , out}); final int IN = 0, OUT = 1; final Random rand = new Random (); final CSTimer tim = new CSTimer (); int a = -1, b = -1; while (true) { int period = (rand.nextInt ()) % 16; tim.sleep (period); b++; switch (alt.fairSelect ()) { case IN: a = in.read (); System.out.println ("\t\t\t" + a); break; case OUT: out.write (b); System.out.println ("\t" + b); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/fireworks/0000755000000000000000000000000011410045042015462 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/fireworks/FireNetwork.java0000644000000000000000000001136411111352066020576 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class FireNetwork implements CSProcess { private final ActiveCanvas activeCanvas; private final FireControl control; public FireNetwork (int maxParticles, int stillCount, int dragCount, int speed, int accY, int maxDeltaY, int launchDeltaX, int launchDeltaY, int scale, Container parent) { parent.setLayout (new BorderLayout ()); final DisplayList displayList = new DisplayList (); // displayList.setMinRefreshInterval (10); // System.out.println ("FireNetwork: displayList.setMinRefreshInterval (10) ..."); // final Any2OneChannel fromMouse = Channel.any2one (new OverWriteOldestBuffer (9)); final One2OneChannel fromMouse = Channel.one2one (new OverWriteOldestBuffer (9)); final One2OneChannel fromMouseMotion = Channel.one2one (new OverWriteOldestBuffer (9)); final One2OneChannel fromKeyboard = Channel.one2one (new OverWriteOldestBuffer (9)); final One2OneChannel fromCanvas = Channel.one2one (new OverWriteOldestBuffer (1)); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); activeCanvas = new ActiveCanvas (); activeCanvas.setBackground (Color.black); activeCanvas.setPaintable (displayList); activeCanvas.setGraphicsChannels (toGraphics.in (), fromGraphics.out ()); activeCanvas.addMouseEventChannel (fromMouse.out ()); activeCanvas.addMouseMotionEventChannel (fromMouseMotion.out ()); activeCanvas.addKeyEventChannel (fromKeyboard.out ()); activeCanvas.addComponentEventChannel(fromCanvas.out ()); activeCanvas.setSize (parent.getSize ()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. System.out.println ("FireNetwork adding ActiveCanvas to the parent ..."); parent.add ("Center", activeCanvas); control = new FireControl ( fromMouse.in (), fromMouseMotion.in (), fromKeyboard.in (), fromCanvas.in (), displayList, toGraphics.out (), fromGraphics.in (), maxParticles, stillCount, dragCount, speed, accY, maxDeltaY, launchDeltaX, launchDeltaY, scale ); } public void run () { System.out.println ("FireControl starting up ..."); new Parallel ( new CSProcess[] { activeCanvas, control } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/fireworks/Fireworks.html0000644000000000000000000001144711113065047020341 0ustar JCSP Fireworks

Fireworks

Point at the applet and [LEFT-MOUSE-CLICK] for a quick burst of sparks. Hold the [LEFT-MOUSE-BUTTON] down for a burst that continues whilst holding - drag the mouse and the fireworks will follow. [RIGHT-MOUSE-CLICK] to keep the show going without holding the button down - [RIGHT-MOUSE-CLICK] again to cancel. Whilst in the [RIGHT-MOUSE-CLICK] mode, [LEFT-MOUSE-BUTTON] and drag repositions the show. Note: you can drag the firework launch point off the applet panel in any direction. Freeze the action with [MIDDLE-MOUSE-CLICK] - unfreeze the same way.

Keyboard controls (use whilst in continuous show mode to see the effects):

  • 'C'/'c' - narrows/broadens (respectively) the launch cone of the firework. Pushing 'C' to its maximum produces a Roman Candle. Pushing 'c' to its minimum yields a sparkler (sparks flying in all directions with equal probability);
  • 'L'/'l' - increases/decreases (respectively) the spark launch velocity. Warning: there is no maximum imposed! Very large velocities produce a laser show.
  • 'P'/'p' - increases/decreases (respectively) the number of particles launched per second. Warning: there is no maximum imposed! However, an applet parameter restricts the total number of particles being animated (the default maximum is 15000). If more than that number become visible, the oldest ones are discarded.
  • 'S'/'s' - increases/decreases (respectively) the scale of the display. Pushing 's' to its minimum enables sky writing by dragging with the [LEFT-MOUSE-BUTTON]. Try doing this with the 'c'one control pushed to minimum and increase the 'L'aunch velocity increased to around 30,000 ...

[Note: all keyboard control values are updated on the Java Console.]

With acknowledgements to Jeff's Geoapplet ... have fun! jcsp-1.1-rc4.orig/src/jcsp-demos/fireworks/FireworksMain.java0000644000000000000000000002051111111352066021111 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * This example is loosely based on * A HREF="http://www.comp.lancs.ac.uk/computing/users/rgg/miscellaneous/Programming.html"> * Jeffrey Hider's Geoapplet * by Jeffrey L. Hider. * This JCSP demonstration is by Peter Welch. * * @author P.H. Welch */ public class FireworksMain extends ActiveApplet { public static final String TITLE = "Fireworks"; public static final String DESCR = "Demonstrates real-time user interaction using the Active AWT components and event channels. A particle " + "simulation routine runs in the background, generating the next frame at timed intervals. The timer " + "controlling these frames is a guard. Other guards are used for user events such as the mouse moving " + "or keys being pressed. This allows thread-safe control of the simulation as it runs.\n" + "\n" + "When running, click the mouse on the window to add a spray of particles. Keys S, C, L, and P control " + "the simulation."; public static final int minWidth = 300; public static final int maxWidth = 1024; public static final int maxHeight = 1024; public static final int minHeight = 100; public static final int minMaxParticles = 1000; public static final int maxMaxParticles = 50000; public static final int defaultMaxParticles = 15000; public static final int minStillCount = 10; public static final int maxStillCount = 1000; public static final int defaultStillCount = 100; public static final int minDragCount = 10; public static final int maxDragCount = 1000; public static final int defaultDragCount = 100; public static final int minSpeed = 1; public static final int maxSpeed = 100; public static final int defaultSpeed = 35; public static final int minScale = 0; public static final int maxScale = 10; public static final int defaultScale = 6; public static final int minMaxDeltaY = 1; public static final int maxMaxDeltaY = 10000; public static final int defaultMaxDeltaY = 10000; public static final int minLaunchDeltaX = 1; public static final int maxLaunchDeltaX = 10000; public static final int defaultLaunchDeltaX = 1200; public static final int minLaunchDeltaY = 1; public static final int maxLaunchDeltaY = 10000; public static final int defaultLaunchDeltaY = 1200; public static final int minAccY = 1; public static final int maxAccY = 1000; public static final int defaultAccY = 256; public void init () { final int maxParticles = getAppletInt ("maxParticles", minMaxParticles, maxMaxParticles, defaultMaxParticles); final int stillCount = getAppletInt ("stillCount", minStillCount, maxStillCount, defaultStillCount); final int dragCount = getAppletInt ("dragCount", minDragCount, maxDragCount, defaultDragCount); final int speed = getAppletInt ("speed", minSpeed, maxSpeed, defaultSpeed); final int accY = getAppletInt ("accY", minAccY, maxAccY, defaultAccY); final int maxDeltaY = getAppletInt ("maxDeltaY", minMaxDeltaY, maxMaxDeltaY, defaultMaxDeltaY); final int launchDeltaX = getAppletInt ("launchDeltaX", minLaunchDeltaX, maxLaunchDeltaX, defaultLaunchDeltaX); final int launchDeltaY = getAppletInt ("launchDeltaY", minLaunchDeltaY, maxLaunchDeltaY, defaultLaunchDeltaY); final int scale = getAppletInt ("scale", minScale, maxScale, defaultScale); setProcess ( new FireNetwork ( maxParticles, stillCount, dragCount, speed, accY, maxDeltaY, launchDeltaX, launchDeltaY, scale, this ) ); } public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); Ask.blank (); /* final int maxParticles = Ask.Int ("maxParticles = ", minMaxParticles, maxMaxParticles); final int stillCount = Ask.Int ("stillCount = ", minStillCount, maxStillCount); final int dragCount = Ask.Int ("dragCount = ", minDragCount, maxDragCount); final int speed = Ask.Int ("speed (frames per second) = ", minSpeed, maxSpeed); final int accY = Ask.Int ("accY = ", minAccY, maxAccY); final int maxDeltaY = Ask.Int ("maxDeltaY = ", minMaxDeltaY, maxMaxDeltaY); final int launchDeltaX = Ask.Int ("launchDeltaX = ", minLaunchDeltaX, maxLaunchDeltaX); final int launchDeltaY = Ask.Int ("launchDeltaY = ", minLaunchDeltaY, maxLaunchDeltaY); final int scale = Ask.Int ("scale = ", minScale, maxScale); System.out.println (); */ final int maxParticles = defaultMaxParticles; final int stillCount = defaultStillCount; final int dragCount = defaultDragCount; final int speed = defaultSpeed; final int accY = defaultAccY; final int maxDeltaY = defaultMaxDeltaY; final int launchDeltaX = defaultLaunchDeltaX; final int launchDeltaY = defaultLaunchDeltaY; final int scale = defaultScale; System.out.println ("maxParticles = " + maxParticles); System.out.println ("stillCount = " + stillCount); System.out.println ("dragCount = " + dragCount); System.out.println ("speed = " + speed); System.out.println ("accY = " + accY); System.out.println ("maxDeltaY = " + maxDeltaY); System.out.println ("launchDeltaX = " + launchDeltaX); System.out.println ("launchDeltaY = " + launchDeltaY); System.out.println ("scale = " + scale); System.out.println (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame (TITLE); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final FireNetwork fireNetwork = new FireNetwork ( maxParticles, stillCount, dragCount, speed, accY, maxDeltaY, launchDeltaX, launchDeltaY, scale, activeFrame ); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, fireNetwork } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/fireworks/FireControl.java0000644000000000000000000004237111111352066020567 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.util.*; import java.awt.*; import java.awt.event.*; /** * @author P.H. Welch */ public class FireControl implements CSProcess { private final AltingChannelInput fromMouse; // mouse events private final AltingChannelInput fromMouseMotion; // mouse & mouse motion events private final AltingChannelInput fromKeyboard; // keyboard events private final AltingChannelInput fromCanvas; // canvas resize events private final DisplayList displayList; // only one slot used private final ChannelOutput toGraphics; // only to find out the canvas dimensions private final ChannelInput fromGraphics; private final int maxParticles; // may need to be more flexible private int stillCount; // number of particles created each cycle private int dragCount; // number of particles created each drag private final int speed; // frames/second for the display private int accY; // gravity acting on each particle (scaled) private int maxDeltaY; // terminal downward velocity for particles (scaled) private int launchDeltaX; // maximum particle horizontal launch velocity (scaled) private int launchDeltaY; // maximum particle vertical launch velocity (scaled) private int launchDeltaX2; // 2 * launchDeltaX private int launchDeltaY2; // 2 * launchDeltaY private final int minBias = 4; private final int maxBias = 16; private int bias = 12; private int launchDeltaYbias; // (bias * launchDeltaY)>>2 private int scale; // log-2 mapping to actual canvas dimension private final Random random = new Random (); private final float hueMin = 0.0f; private final float hueMax = 1.0f; private final int maxColours = 768; private final Color[] colour; private int colourIndex = 0; private Dimension graphicsDim; // current drawing size public FireControl (AltingChannelInput fromMouse, AltingChannelInput fromMouseMotion, AltingChannelInput fromKeyboard, AltingChannelInput fromCanvas, DisplayList displayList, ChannelOutput toGraphics, ChannelInput fromGraphics, int maxParticles, int stillCount, int dragCount, int speed, int accY, int maxDeltaY, int launchDeltaX, int launchDeltaY, int scale) { this.fromMouse = fromMouse; this.fromMouseMotion = fromMouseMotion; this.fromKeyboard = fromKeyboard; this.fromCanvas = fromCanvas; this.displayList = displayList; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; this.maxParticles = maxParticles; this.stillCount = stillCount; this.dragCount = dragCount; this.speed = speed; this.accY = accY; this.maxDeltaY = maxDeltaY; this.launchDeltaX = launchDeltaX; this.launchDeltaY = launchDeltaY; this.launchDeltaX2 = launchDeltaX*2; this.launchDeltaY2 = launchDeltaY*2; this.launchDeltaYbias = (launchDeltaY*bias)>>2; this.scale = scale; this.colour = new Color[maxColours]; setColours (); } private void setColours () { // final float hueIncrement = (hueMax - hueMin)/((float) maxColours); // final float saturation = 0.50f; // final float brightness = 1.00f; // for (int i = 0; i < maxColours; i++) { // // this.colour[i] = new Color (random.nextInt ()); // this.colour[i] = new Color ( // hueMin + (((float) i)*hueIncrement), saturation, brightness // ); // System.out.println ("setColours : " + i + " : " + this.colour[i]); // } int up = 0; int down = 255; for (int i = 0; i < 256; i++) { colour[i] = new Color (0, down, up); up++; down--; } up = 0; down = 255; for (int i = 256; i < 512; i++) { colour[i] = new Color (up, 0, down); up++; down--; } up = 0; down = 255; for (int i = 512; i < 768; i++) { colour[i] = new Color (down, up, 0); up++; down--; } for (int i = 0; i < 768; i += 16) { colour[i] = Color.white; up++; down--; } } private final class Graphic implements GraphicsCommand.Graphic { public int scale; public Particle[] particle; public int nParticles; public void doGraphic (java.awt.Graphics g, java.awt.Component c) { Particle.setScale (scale); g.clearRect (0, 0, graphicsDim.width, graphicsDim.height); for (int i = 0; i < nParticles; i++) { particle[i].paint (g); } } } /** * returns a random integer in the range [0, n - 1] */ private final int range (int n) { int i = random.nextInt (); if (i < 0) { i = (i == Integer.MIN_VALUE) ? 42 : -i; // guard against minint ! } return i % n; } private void createParticles (int n, Point mouseLocation, Graphic graphic) { final int maxColours4 = maxColours<<4; final int x = (mouseLocation.x)< maxParticles) n = maxParticles - j; for (int i = 0; i < n; i++) { graphic.particle[j].setAttributes ( x, y, range (launchDeltaX2) - launchDeltaX, range (launchDeltaY2) - launchDeltaYbias, colour[colourIndex>>4] ); colourIndex++; if (colourIndex == maxColours4) colourIndex = 0; j++; } graphic.nParticles = j; } private void createParticles (int n, Point oldMouseLocation, Point newMouseLocation, Graphic graphic) { final int maxColours4 = maxColours<<4; final int oldX = (oldMouseLocation.x)< maxParticles) n = maxParticles - j; for (int i = 0; i < n; i++) { graphic.particle[j].setAttributes ( oldX + ((i*diffX)/n), oldY + ((i*diffY)/n), range (launchDeltaX2) - launchDeltaX, range (launchDeltaY2) - launchDeltaYbias, colour[colourIndex>>4] ); colourIndex++; if (colourIndex == maxColours4) colourIndex = 0; j++; } graphic.nParticles = j; } public void run () { toGraphics.write (GraphicsProtocol.GET_DIMENSION); graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("FireControl : graphics dimension = " + graphicsDim); Particle.setConstants (accY, maxDeltaY, scale, graphicsDim); Graphic oldGraphic = new Graphic (); oldGraphic.scale = scale; oldGraphic.particle = new Particle[maxParticles]; oldGraphic.nParticles = 0; Graphic newGraphic = new Graphic (); newGraphic.scale = scale; newGraphic.particle = new Particle[maxParticles]; newGraphic.nParticles = 0; for (int i = 0; i < maxParticles; i++) { oldGraphic.particle[i] = new Particle (); newGraphic.particle[i] = new Particle (); } GraphicsCommand oldCommand = new GraphicsCommand.General (oldGraphic); GraphicsCommand newCommand = new GraphicsCommand.General (newGraphic); final CSTimer tim = new CSTimer (); final long second = 1000; // JCSP Timer units are milliseconds long interval = (long) (((float) second)/((float) speed) + 0.5); System.out.println ("FireControl : interval = " + interval); final Guard[] guard = {tim, fromMouse, fromMouseMotion, fromKeyboard, fromCanvas }; final int TIMEOUT = 0; final int MOUSE = 1; final int MOUSE_MOTION = 2; final int KEYBOARD = 3; final int RESIZE = 4; final Alternative alt = new Alternative (guard); final boolean[] preCondition = {false, true, true, true, true}; Point mouseLocation = new Point (0, 0), oldMouseLocation = null; boolean buttonPressed = false; boolean continuous = false; tim.setAlarm (tim.read () + interval); while (true) { toGraphics.write (GraphicsProtocol.REQUEST_FOCUS); fromGraphics.read (); preCondition[TIMEOUT] = buttonPressed || continuous || (oldGraphic.nParticles > 0) || (newGraphic.nParticles > 0); switch (alt.priSelect (preCondition)) { case TIMEOUT: { if ((buttonPressed || continuous) && (newGraphic.nParticles == 0)) { createParticles (stillCount, mouseLocation, newGraphic); } int j = newGraphic.nParticles; for (int i = 0; i < oldGraphic.nParticles; i++) { if (j == maxParticles) break; if (oldGraphic.particle[i].move (newGraphic.particle[j])) j++; } newGraphic.nParticles = j; newGraphic.scale = scale; // System.out.println ("TIMEOUT : " + mouseLocation + " : " + newGraphic.nParticles); displayList.set (newCommand); final Graphic tmpA = oldGraphic; oldGraphic = newGraphic; newGraphic = tmpA; final GraphicsCommand tmpB = oldCommand; oldCommand = newCommand; newCommand = tmpB; newGraphic.nParticles = 0; tim.setAlarm (tim.read () + interval); break; } case MOUSE: { MouseEvent mouseEvent = (MouseEvent) fromMouse.read (); switch (mouseEvent.getID ()) { case MouseEvent.MOUSE_PRESSED: { if ((mouseEvent.getModifiers () & InputEvent.BUTTON2_MASK) != 0) { System.out.println ("MIDDLE MOUSE_PRESSED (freeze) : " + newGraphic.nParticles + " : " + oldGraphic.nParticles); mouseEvent = (MouseEvent) fromMouse.read (); while (mouseEvent.getID () != MouseEvent.MOUSE_PRESSED) { mouseEvent = (MouseEvent) fromMouse.read (); } System.out.println ("SOME MOUSE_PRESSED (running) : "); } else { mouseLocation = mouseEvent.getPoint (); // System.out.println ("MOUSE_PRESSED : " + mouseLocation); // createParticles (stillCount, mouseLocation, newGraphic); buttonPressed = true; if ((mouseEvent.getModifiers () & InputEvent.BUTTON3_MASK) != 0) { continuous = ! continuous; // System.out.println ("RIGHT MOUSE_PRESSED : " + continuous); } } break; } case MouseEvent.MOUSE_RELEASED: { if (buttonPressed) { mouseLocation = mouseEvent.getPoint (); // System.out.println ("MOUSE_RELEASED : " + mouseLocation + // " : " + newGraphic.nParticles + " : " + oldGraphic.nParticles); buttonPressed = false; } break; } } break; } case MOUSE_MOTION: { final MouseEvent mouseEvent = (MouseEvent) fromMouseMotion.read (); switch (mouseEvent.getID ()) { case MouseEvent.MOUSE_DRAGGED: { // System.out.println ("MOUSE_DRAGGED : buttonPressed = " + buttonPressed); if (buttonPressed) { oldMouseLocation = mouseLocation; mouseLocation = mouseEvent.getPoint (); createParticles (dragCount, oldMouseLocation, mouseLocation, newGraphic); // System.out.println ("MOUSE_DRAGGED : " + mouseLocation + " : " + newGraphic.nParticles); } break; } } break; } case KEYBOARD: { KeyEvent keyEvent = (KeyEvent) fromKeyboard.read (); if (keyEvent.getID () == KeyEvent.KEY_PRESSED) { switch (keyEvent.getKeyCode ()) { case KeyEvent.VK_P: { if ((keyEvent.getModifiers () & InputEvent.SHIFT_MASK) != 0) { stillCount = (5*stillCount)/4; dragCount = (5*dragCount)/4; } else { stillCount = (4*stillCount)/5; dragCount = (4*dragCount)/5; if (stillCount < 4) stillCount = 4; if (dragCount < 4) dragCount = 4; } System.out.println ("KEYBOARD : P " + stillCount + ", " + dragCount); break; } case KeyEvent.VK_L: { if ((keyEvent.getModifiers () & InputEvent.SHIFT_MASK) != 0) { launchDeltaX = (5*launchDeltaX)/4; launchDeltaY = (5*launchDeltaY)/4; } else { launchDeltaX = (4*launchDeltaX)/5; launchDeltaY = (4*launchDeltaY)/5; if (launchDeltaX < 4) launchDeltaX = 4; if (launchDeltaY < 4) launchDeltaY = 4; } System.out.println ("KEYBOARD : L " + launchDeltaX + ", " + launchDeltaY); launchDeltaX2 = launchDeltaX*2; launchDeltaY2 = launchDeltaY*2; launchDeltaYbias = (launchDeltaY*bias)>>2; break; } case KeyEvent.VK_C: { if ((keyEvent.getModifiers () & InputEvent.SHIFT_MASK) != 0) { if (bias < maxBias) bias++; } else { if (bias > minBias) bias--; } launchDeltaYbias = (launchDeltaY*bias)>>2; System.out.println ("KEYBOARD : C " + bias); break; } case KeyEvent.VK_S: { if ((keyEvent.getModifiers () & InputEvent.SHIFT_MASK) == 0) { if (scale < 10) { scale++; mouseLocation.x >>= 1; mouseLocation.y>>= 1; } } else { if (scale > 1) { scale--; mouseLocation.x <<= 1; mouseLocation.y <<= 1; } } System.out.println ("KEYBOARD : S " + scale); Particle.setConstants (accY, maxDeltaY, scale, graphicsDim); break; } } } break; } case RESIZE : { ComponentEvent e = (ComponentEvent)fromCanvas.read (); if (e.getID () == ComponentEvent.COMPONENT_RESIZED) { toGraphics.write (GraphicsProtocol.GET_DIMENSION); graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("FireControl : graphics dimension = " + graphicsDim); Particle.setConstants (accY, maxDeltaY, scale, graphicsDim); } break; } } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/fireworks/Particle.java0000644000000000000000000000764711111352066020113 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.awt.*; /** * @author P.H. Welch */ public class Particle { private static int accY; // gravity private static int maxDeltaY; // terminal downward velocity private static int scale; // log-2 mapping to actual canvas dimension private static int height; // canvas height (scaled up) private static int width; // canvas width (scaled up) public static void setScale (int scale) { Particle.scale = scale; } public static void setConstants (int accY, int maxDeltaY, int scale, Dimension dim) { Particle.accY = accY; Particle.maxDeltaY = maxDeltaY; // Particle.scale = scale; Particle.height = (dim.height)< maxDeltaY) this.deltaY = maxDeltaY; this.colour = colour; } public void paint (Graphics g) { g.setColor (colour); g.drawLine (oldX>>scale, oldY>>scale, X>>scale, Y>>scale); } public boolean move (Particle p) { // if ((X < 0) || (X >= width) || (Y >= height)) return false; if (((X < 0) && (deltaX < 0)) || ((X >= width) && (deltaX > 0))) return false; if ((Y >= height) && (deltaY > 0)) { deltaY = deltaY/2; if (deltaY < accY) { return false; } else { deltaY = -deltaY; } } p.setAttributes (X, Y, deltaX, deltaY, colour); return true; } public void scaleChange (int scaleDelta) { X >>= scaleDelta; Y >>= scaleDelta; oldX >>= scaleDelta; oldY >>= scaleDelta; } } jcsp-1.1-rc4.orig/src/jcsp-demos/fireworks/ns-Fireworks.html0000644000000000000000000000556111113065047020757 0ustar JCSP Fireworks

Fireworks

Point at the applet and [LEFT-MOUSE-CLICK] for a quick burst of sparks. Hold the [LEFT-MOUSE-BUTTON] down for a burst that continues whilst holding - drag the mouse and the fireworks will follow. [RIGHT-MOUSE-CLICK] to keep the show going without holding the button down - [RIGHT-MOUSE-CLICK] again to cancel. Whilst in the [RIGHT-MOUSE-CLICK] mode, [LEFT-MOUSE-BUTTON] and drag repositions the show. Note: you can drag the firework launch point off the applet panel in any direction. Freeze the action with [MIDDLE-MOUSE-CLICK] - unfreeze the same way.

Keyboard controls (use whilst in continuous show mode to see the effects):

  • 'C'/'c' - narrows/broadens (respectively) the launch cone of the firework. Pushing 'C' to its maximum produces a Roman Candle. Pushing 'c' to its minimum yields a sparkler (sparks flying in all directions with equal probability);
  • 'L'/'l' - increases/decreases (respectively) the spark launch velocity. Warning: there is no maximum imposed! Very large velocities produce a laser show.
  • 'P'/'p' - increases/decreases (respectively) the number of particles launched per second. Warning: there is no maximum imposed! However, an applet parameter restricts the total number of particles being animated (the default maximum is 15000). If more than that number become visible, the oldest ones are discarded.
  • 'S'/'s' - increases/decreases (respectively) the scale of the display. Pushing 's' to its minimum enables sky writing by dragging with the [LEFT-MOUSE-BUTTON]. Try doing this with the 'c'one control pushed to minimum and increase the 'L'aunch velocity increased to around 30,000 ...

[Note: all keyboard control values are updated on the Java Console.]

With acknowledgements to Jeff's Geoapplet ... have fun! jcsp-1.1-rc4.orig/src/jcsp-demos/bucket/0000755000000000000000000000000011410045042014724 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/bucket/BucketKeeper.java0000644000000000000000000000555711111352066020161 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class BucketKeeper implements CSProcess { private final long interval; private final Bucket[] bucket; public BucketKeeper (long interval, Bucket[] bucket) { this.interval = interval; this.bucket = bucket; } public void run () { String[] spacer = new String[bucket.length]; spacer[0] = ""; for (int i = 1; i < spacer.length; i++) spacer[i] = spacer[i - 1] + " "; final CSTimer tim = new CSTimer (); long timeout = tim.read (); int index = 0; while (true) { final int n = bucket[index].flush (); if (n == 0) { System.out.println (spacer[index] + "*** bucket " + index + " was empty ..."); } index = (index + 1) % bucket.length; timeout += interval; tim.after (timeout); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/bucket/Worker.java0000644000000000000000000000620311111352066017046 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.util.*; /** * @author P.H. Welch */ public class Worker implements CSProcess { private final int id; private final long seed; private final int maxWork; private final Bucket bucket; public Worker (int id, long seed, int maxWork, Bucket bucket) { this.id = id; this.seed = seed; this.maxWork = maxWork; this.bucket = bucket; } public void run () { final Random random = new Random (seed); // each process gets a different seed final CSTimer tim = new CSTimer (); final String working = "\t... Worker " + id + " working ..."; final String falling = "\t\t\t ... Worker " + id + " falling ..."; final String flushed = "\t\t\t\t\t\t ... Worker " + id + " flushed ..."; while (true) { System.out.println (working); // these lines represent int sleepTime = (random.nextInt() & 0x7FFFFFFF) % maxWork; tim.sleep (sleepTime); // one unit of work System.out.println (falling); bucket.fallInto (); System.out.println (flushed); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/bucket/Flusher.java0000644000000000000000000000523511111352066017211 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class Flusher implements CSProcess { private final int interval; private final Bucket bucket; public Flusher (int interval, Bucket bucket) { this.interval = interval; this.bucket = bucket; } public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read () + interval; while (true) { tim.after (timeout); System.out.println ("*** Flusher: about to flush ..."); final int n = bucket.flush (); System.out.println ("*** Flusher: number flushed = " + n); timeout += interval; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/bucket/BucketExample1.java0000644000000000000000000000710211111352066020406 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class BucketExample1 { public static final String TITLE = "Bucket Example 1"; public static final String DESCR = "Shows the use of a single bucket to control a group of worker processes. A worker process will take " + "action for some time and then fall into the bucket. Another process will periodically flush the " + "bucket, setting any workers in it working again. Such a system can be used to simulate actions which " + "must start on a clock cycle (ie when the bucket is flushed). An individual action from a worker may " + "take any length of time but the next action will not start until the next clock cycle."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); final int nWorkers = 10; final int second = 1000; // JCSP timer units are milliseconds final int interval = 5*second; final int maxWork = 10*second; final long seed = new CSTimer ().read (); final Bucket bucket = new Bucket (); final Flusher flusher = new Flusher (interval, bucket); final Worker[] workers = new Worker[nWorkers]; for (int i = 0; i < workers.length; i++) { workers[i] = new Worker (i, i + seed, maxWork, bucket); } System.out.println ("*** Flusher: interval = " + interval + " milliseconds"); new Parallel ( new CSProcess[] { flusher, new Parallel (workers) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/bucket/BucketExample2.java0000644000000000000000000000635311111352066020416 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class BucketExample2 { public static final String TITLE = "Flying Dingbats"; public static final String DESCR = "Shows the use of a number of buckets to control the actions of a number of workers (dingbats). Each " + "dingbat will perform one unit of work and then fall into one of the buckets. The bucket keeper will " + "flush one bucket per cycle, possibly setting one or more dingbats to work again."; public static void main (String[] args) { final int minDingbat = 2; final int maxDingbat = 10; final int nDingbats = (maxDingbat - minDingbat) + 1; final int nBuckets = 2*maxDingbat; final Bucket[] bucket = Bucket.create (nBuckets); final int second = 1000; // JCSP timer units are milliseconds final int tick = second; final BucketKeeper bucketKeeper = new BucketKeeper (tick, bucket); final Dingbat[] dingbats = new Dingbat[nDingbats]; for (int i = 0; i < dingbats.length; i++) { dingbats[i] = new Dingbat (i + minDingbat, bucket); } new Parallel ( new CSProcess[] { bucketKeeper, new Parallel (dingbats) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/bucket/Dingbat.java0000644000000000000000000000546511111352066017156 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public class Dingbat implements CSProcess { private final int id; private final Bucket[] bucket; public Dingbat (int id, Bucket[] bucket) { this.id = id; this.bucket = bucket; } public void run () { int logicalTime = 0; String[] spacer = new String[bucket.length]; spacer[0] = ""; for (int i = 1; i < spacer.length; i++) spacer[i] = spacer[i - 1] + " "; String message = "Hello world from " + id + " ==> time = "; while (true) { logicalTime += id; final int slot = logicalTime % bucket.length; // assume: id <= bucket.length bucket[slot].fallInto (); System.out.println (spacer[slot] + message + logicalTime); // one unit of work } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/0000755000000000000000000000000011410045035014630 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/README.txt0000644000000000000000000000061011113065047016330 0ustar These directories hold the examples used in the javadoc for the main JCSP library. The structure of these directories mirrors those in the library. Most have Main programs from which they can be compiled and run: * change into any of the directories with .java files; * javac *java; * java (i.e. run) the ones with main methods (these usually have "Main" as part of their name). jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/0000755000000000000000000000000011410045035015567 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/util/0000755000000000000000000000000011410045035016544 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/util/ChannelDataStoreTest.java0000644000000000000000000002110111111400544023417 0ustar /******************************************************************************* * * $Archive: /doc-ex/jcsp/util/ints/ChannelDataStoreTest.java $ * * $Date: 1998/07/21 14:17:11 $ * * $Revision: 1.1 $ * * (C) Copyright 1997/8 Paul Austin * University of Kent Canterbury ******************************************************************************/ // package test.jcsp; import java.text.*; import java.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.Printer; /** *

Description

* The ChannelDataStoreTest process is designed to test the ChannelDataStore * implementations provided by the jcsp library. * * @see org.jcsp.util.ZeroBuffer * @see org.jcsp.util.Buffer * @see org.jcsp.util.OverWritingBuffer * @see org.jcsp.util.OverWriteOldestBuffer * @see org.jcsp.util.InifiniteBuffer * @see org.jcsp.util.BlackHole * @see org.jcsp.util.CSTimer * @author P.D. Austin */ public class ChannelDataStoreTest implements CSProcess { /** * The main body of this process. */ public void run() { final Any2OneChannel a2o = Channel.any2one(); final One2OneChannel b = Channel.one2one (new Buffer(4)); final One2OneChannel owb = Channel.one2one (new OverWritingBuffer(4)); final One2OneChannel owob = Channel.one2one (new OverWriteOldestBuffer(4)); final One2OneChannel oflb = Channel.one2one (new OverFlowingBuffer(4)); final One2OneChannel ib = Channel.one2one (new InfiniteBuffer(1)); final BlackHoleChannel bh = new BlackHoleChannel (); final CSTimer tim = new CSTimer (); final One2OneChannel prompt = Channel.one2one(); final One2OneChannel next = Channel.one2one(); new Parallel(new CSProcess[] { new CSProcess() { public void run() { testZeroBuffer(); testBuffer(); testOverWritingBuffer(); testOverWriteOldestBuffer(); testOverFlowingBuffer(); testInfiniteBuffer(); testBlackHole(); testCSTimer(); } void testZeroBuffer() { a2o.out ().write("Starting Test (ZeroBuffer)"); for (int i = 0; i < 5; i++) { b.out ().write(new Integer (i)); } a2o.out ().write("Finished outputing (ZeroBuffer)"); prompt.out ().write(Boolean.TRUE); } void testBuffer() { next.in ().read(); a2o.out ().write("Starting Test (Buffer)"); for (int i = 0; i < 4; i++) { b.out ().write(new Integer (i)); } prompt.out ().write(Boolean.TRUE); b.out ().write(new Integer (4)); a2o.out ().write("Finished outputing (Buffer)"); prompt.out ().write(Boolean.TRUE); } void testOverWritingBuffer() { next.in ().read(); a2o.out ().write("Starting Test (OverWritingBuffer)"); for (int i = 0; i < 6; i++) { owb.out ().write(new Integer (i)); } a2o.out ().write("Finished outputing (OverWritingBuffer)"); prompt.out ().write(Boolean.TRUE); } void testOverWriteOldestBuffer() { next.in ().read(); a2o.out ().write("Starting Test (OverWriteOldestBuffer)"); for (int i = 0; i < 10; i++) { owob.out ().write(new Integer (i)); } a2o.out ().write("Finished outputing (OverWriteOldestBuffer)"); prompt.out ().write(Boolean.TRUE); } void testOverFlowingBuffer() { next.in ().read(); a2o.out ().write("Starting Test (OverFlowingBuffer)"); for (int i = 0; i < 10; i++) { oflb.out ().write(new Integer (i)); } a2o.out ().write("Finished outputing (OverFlowingBuffer)"); prompt.out ().write(Boolean.TRUE); } void testInfiniteBuffer() { next.in ().read(); a2o.out ().write("Starting Test (InfiniteBuffer)"); for (int i = 0; i < 5; i++) { ib.out ().write(new Integer (i)); } prompt.out ().write(Boolean.TRUE); for (int i = 0; i < 5; i++) { ib.out ().write(new Integer (i + 5)); } a2o.out ().write("Finished outputing (InfiniteBuffer)"); prompt.out ().write(Boolean.TRUE); } void testBlackHole() { next.in ().read(); a2o.out ().write("Starting Test (BlackHole)"); for (int i = 0; i < 5; i++) { bh.write(new Integer (i)); } a2o.out ().write("Finished outputing (BlackHole)"); prompt.out ().write(Boolean.TRUE); } void testCSTimer() { next.in ().read(); a2o.out ().write("Starting Test (CSTimer)"); a2o.out ().write("Finished outputing (CSTimer)"); prompt.out ().write(Boolean.TRUE); } }, new CSProcess() { boolean finished; public void run() { testZeroBuffer(); testBuffer(); testOverWritingBuffer(); testOverWriteOldestBuffer(); testOverFlowingBuffer(); testInfiniteBuffer(); testBlackHole(); testCSTimer(); } void testZeroBuffer() { finished = false; while (!finished) { Integer i = (Integer) b.in ().read(); a2o.out ().write(i); finished = (i.intValue() == 4); } prompt.in ().read(); a2o.out ().write("Finished Test (ZeroBuffer)"); } void testBuffer() { next.out ().write(Boolean.TRUE); finished = false; prompt.in ().read(); while (!finished) { Integer i = (Integer) b.in ().read(); a2o.out ().write(i); finished = (i.intValue() == 4); } prompt.in ().read(); a2o.out ().write("Finished Test (Buffer)"); } void testOverWritingBuffer() { next.out ().write(Boolean.TRUE); finished = false; prompt.in ().read(); while (!finished) { Integer i = (Integer) owb.in ().read(); a2o.out ().write(i); finished = (i.intValue() == 5); } a2o.out ().write("Finished Test (OverWritingBuffer)"); } void testOverWriteOldestBuffer() { next.out ().write(Boolean.TRUE); finished = false; prompt.in ().read(); while (!finished) { Integer i = (Integer) owob.in ().read(); a2o.out ().write(i); finished = (i.intValue() == 9); } a2o.out ().write("Finished Test (OverWriteOldestBuffer)"); } void testOverFlowingBuffer() { next.out ().write(Boolean.TRUE); prompt.in ().read(); while (oflb.in ().pending ()) { Integer i = (Integer) oflb.in ().read(); a2o.out ().write(i); } a2o.out ().write("Finished Test (OverFlowingBuffer)"); } void testInfiniteBuffer() { next.out ().write(Boolean.TRUE); finished = false; prompt.in ().read(); while (!finished) { Integer i = (Integer) ib.in ().read(); a2o.out ().write(i); if (i.intValue() == 4) { prompt.in ().read(); } finished = (i.intValue() == 9); } a2o.out ().write("Finished Test (InfiniteBuffer)"); } void testBlackHole() { next.out ().write(Boolean.TRUE); prompt.in ().read(); a2o.out ().write("Finished Test (BlackHole)"); } void testCSTimer() { next.out ().write(Boolean.TRUE); prompt.in ().read(); for (int i = 0; i < 5; i++) { long time = tim.read(); a2o.out ().write(DateFormat.getInstance().format(new Date(time)) + " " + time % 1000); } a2o.out ().write("Finished Test (CSTimer)"); System.exit(0); } }, new Printer(a2o.in (), "", "\n") }).run(); } /** * Executes the process. * * @param argv The parameters to the application. */ public static void main(String[] argv) { new ChannelDataStoreTest().run(); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/util/ints/0000755000000000000000000000000011410045035017521 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/util/ints/ChannelDataStoreIntTest.java0000644000000000000000000002067511105701167025076 0ustar /******************************************************************************* * * $Archive: doc-ex/jcsp/util/ints/ChannelDataStoreIntTest.java $ * * $Date: 1998/07/21 14:17:11 $ * * $Revision: 1.1 $ * * (C) Copyright 1997/8 Paul Austin * University of Kent Canterbury ******************************************************************************/ // package test.jcsp; import java.text.*; import java.util.*; import org.jcsp.lang.*; import org.jcsp.util.ints.*; import org.jcsp.plugNplay.Printer; /** *

Description

* The ChannelDataStoreIntTest process is designed to test the ChannelDataStoreInt * implementations provided by the jcsp library. * * @see org.jcsp.util.ZeroBuffer * @see org.jcsp.util.Buffer * @see org.jcsp.util.OverWritingBuffer * @see org.jcsp.util.OverWriteOldestBuffer * @see org.jcsp.util.InifiniteBuffer * @see org.jcsp.util.BlackHole * @see org.jcsp.util.CSTimer * @author P.D. Austin */ public class ChannelDataStoreIntTest implements CSProcess { /** * The main body of this process. */ public void run() { final Any2OneChannel a2o = Channel.any2one(); final One2OneChannelInt b = Channel.one2oneInt (new BufferInt(4)); final One2OneChannelInt owb = Channel.one2oneInt (new OverWritingBufferInt(4)); final One2OneChannelInt owob = Channel.one2oneInt (new OverWriteOldestBufferInt(4)); final One2OneChannelInt oflb = Channel.one2oneInt (new OverFlowingBufferInt(4)); final One2OneChannelInt ib = Channel.one2oneInt (new InfiniteBufferInt(1)); final BlackHoleChannelInt bh = new BlackHoleChannelInt (); final CSTimer tim = new CSTimer (); final One2OneChannel prompt = Channel.one2one(); final One2OneChannel next = Channel.one2one(); new Parallel(new CSProcess[] { new CSProcess() { public void run() { testZeroBuffer(); testBuffer(); testOverWritingBuffer(); testOverWriteOldestBuffer(); testOverFlowingBuffer(); testInfiniteBuffer(); testBlackHole(); testCSTimer(); } void testZeroBuffer() { a2o.out ().write("Starting Test (ZeroBuffer)"); for (int i = 0; i < 5; i++) { b.out ().write(i); } a2o.out ().write("Finished outputing (ZeroBuffer)"); prompt.out ().write(Boolean.TRUE); } void testBuffer() { next.in ().read(); a2o.out ().write("Starting Test (Buffer)"); for (int i = 0; i < 4; i++) { b.out ().write(i); } prompt.out ().write(Boolean.TRUE); b.out ().write(4); a2o.out ().write("Finished outputing (Buffer)"); prompt.out ().write(Boolean.TRUE); } void testOverWritingBuffer() { next.in ().read(); a2o.out ().write("Starting Test (OverWritingBuffer)"); for (int i = 0; i < 6; i++) { owb.out ().write(i); } a2o.out ().write("Finished outputing (OverWritingBuffer)"); prompt.out ().write(Boolean.TRUE); } void testOverWriteOldestBuffer() { next.in ().read(); a2o.out ().write("Starting Test (OverWriteOldestBuffer)"); for (int i = 0; i < 10; i++) { owob.out ().write(i); } a2o.out ().write("Finished outputing (OverWriteOldestBuffer)"); prompt.out ().write(Boolean.TRUE); } void testOverFlowingBuffer() { next.in ().read(); a2o.out ().write("Starting Test (OverFlowingBuffer)"); for (int i = 0; i < 10; i++) { oflb.out ().write(i); } a2o.out ().write("Finished outputing (OverFlowingBuffer)"); prompt.out ().write(Boolean.TRUE); } void testInfiniteBuffer() { next.in ().read(); a2o.out ().write("Starting Test (InfiniteBuffer)"); for (int i = 0; i < 5; i++) { ib.out ().write(i); } prompt.out ().write(Boolean.TRUE); for (int i = 0; i < 5; i++) { ib.out ().write(i + 5); } a2o.out ().write("Finished outputing (InfiniteBuffer)"); prompt.out ().write(Boolean.TRUE); } void testBlackHole() { next.in ().read(); a2o.out ().write("Starting Test (BlackHole)"); for (int i = 0; i < 5; i++) { bh.write(i); } a2o.out ().write("Finished outputing (BlackHole)"); prompt.out ().write(Boolean.TRUE); } void testCSTimer() { next.in ().read(); a2o.out ().write("Starting Test (CSTimer)"); a2o.out ().write("Finished outputing (CSTimer)"); prompt.out ().write(Boolean.TRUE); } }, new CSProcess() { boolean finished; public void run() { testZeroBuffer(); testBuffer(); testOverWritingBuffer(); testOverWriteOldestBuffer(); testOverFlowingBuffer(); testInfiniteBuffer(); testBlackHole(); testCSTimer(); } void testZeroBuffer() { finished = false; while (!finished) { int i = b.in ().read(); a2o.out ().write(new Integer (i)); finished = i == 4; } prompt.in ().read(); a2o.out ().write("Finished Test (ZeroBuffer)"); } void testBuffer() { next.out ().write(Boolean.TRUE); finished = false; prompt.in ().read(); while (!finished) { int i = b.in ().read(); a2o.out ().write(new Integer (i)); finished = i == 4; } prompt.in ().read(); a2o.out ().write("Finished Test (Buffer)"); } void testOverWritingBuffer() { next.out ().write(Boolean.TRUE); finished = false; prompt.in ().read(); while (!finished) { int i = owb.in ().read(); a2o.out ().write(new Integer (i)); finished = i == 5; } a2o.out ().write("Finished Test (OverWritingBuffer)"); } void testOverWriteOldestBuffer() { next.out ().write(Boolean.TRUE); finished = false; prompt.in ().read(); while (!finished) { int i = owob.in ().read(); a2o.out ().write(new Integer (i)); finished = i == 9; } a2o.out ().write("Finished Test (OverWriteOldestBuffer)"); } void testOverFlowingBuffer() { next.out ().write(Boolean.TRUE); prompt.in ().read(); while (oflb.in ().pending ()) { int i = oflb.in ().read(); a2o.out ().write(new Integer (i)); } a2o.out ().write("Finished Test (OverFlowingBuffer)"); } void testInfiniteBuffer() { next.out ().write(Boolean.TRUE); finished = false; prompt.in ().read(); while (!finished) { int i = ib.in ().read(); a2o.out ().write(new Integer (i)); if (i == 4) { prompt.in ().read(); } finished = i == 9; } a2o.out ().write("Finished Test (InfiniteBuffer)"); } void testBlackHole() { next.out ().write(Boolean.TRUE); prompt.in ().read(); a2o.out ().write("Finished Test (BlackHole)"); } void testCSTimer() { next.out ().write(Boolean.TRUE); prompt.in ().read(); for (int i = 0; i < 5; i++) { long time = tim.read(); a2o.out ().write(DateFormat.getInstance().format(new Date(time)) + " " + time % 1000); } a2o.out ().write("Finished Test (CSTimer)"); System.exit(0); } }, new Printer(a2o.in (), "", "\n") }).run(); } /** * Executes the process. * * @param argv The parameters to the application. */ public static void main(String[] argv) { new ChannelDataStoreIntTest().run(); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/0000755000000000000000000000000011410045035016510 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/ProcessManagerExample0.java0000644000000000000000000000150011105664736023674 0ustar import org.jcsp.lang.*; public class ProcessManagerExample0 { public static void pause (int time) { try {Thread.sleep (time);} catch (InterruptedException e) {} } public static void main (String[] argv) { System.out.println ("*** start the managed process"); new ProcessManager ( new CSProcess () { public void run () { while (true) { System.out.println (":-) managed process running in the background"); pause (500); } } } ).start (); System.out.println ("*** I'm still executing as well"); System.out.println ("*** I'm going to take 5 ..."); pause (5000); System.out.println ("*** I'll take another 5 ..."); pause (5000); System.out.println ("*** I'll finish now ... so the network should as well."); } }jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/FairPlex.java0000644000000000000000000000074711105664736021115 0ustar import org.jcsp.lang.*; public class FairPlex implements CSProcess { private final AltingChannelInput[] in; private final ChannelOutput out; public FairPlex (final AltingChannelInput[] in, final ChannelOutput out) { this.in = in; this.out = out; } public void run () { final Alternative alt = new Alternative (in); while (true) { final int index = alt.fairSelect (); out.write (in[index].read ()); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/AltingOutputExample.java0000644000000000000000000000134311113671251023334 0ustar import org.jcsp.lang.*; public class AltingOutputExample implements CSProcess { private final AltingChannelOutput out0, out1; public AltingOutputExample (final AltingChannelOutput out0, final AltingChannelOutput out1) { this.out0 = out0; this.out1 = out1; } public void run () { final Guard[] altChans = {out0, out1}; final Alternative alt = new Alternative (altChans); while (true) { switch (alt.select ()) { case 0: out0.write (new Integer(0)); System.out.println ("out0 written"); break; case 1: out1.write (new Integer(1)); System.out.println ("out1 written"); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/Regular.java0000644000000000000000000000130111105664736020767 0ustar import org.jcsp.lang.*; public class Regular implements CSProcess { final private ChannelOutput out; final private Integer N; final private long interval; public Regular (final ChannelOutput out, final int n, final long interval) { this.out = out; this.N = new Integer (n); this.interval = interval; } public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read (); // read the (absolute) time once only while (true) { out.write (N); timeout += interval; // set the next (absolute) timeout tim.after (timeout); // wait until that (absolute) timeout } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/AltingExample.java0000644000000000000000000000121311113671251022107 0ustar import org.jcsp.lang.*; public class AltingExample implements CSProcess { private final AltingChannelInput in0, in1; public AltingExample (final AltingChannelInput in0, final AltingChannelInput in1) { this.in0 = in0; this.in1 = in1; } public void run () { final Guard[] altChans = {in0, in1}; final Alternative alt = new Alternative (altChans); while (true) { switch (alt.select ()) { case 0: System.out.println ("in0 read " + in0.read ()); break; case 1: System.out.println ("in1 read " + in1.read ()); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/LaunchControl.java0000644000000000000000000000724011105664736022151 0ustar import org.jcsp.lang.*; // LaunchControl is a process to control the launch of a space rocket. // It is configured with a countdown time in seconds -- this must be above // a minimum threshold, MIN_COUNTDOWN, else the launch is immediately aborted. // There are two control lines, abort and hold, that respectively abort // or hold the launch if signalled. The hold is released by a second // signal on the same line. // During countdown, the count is reported by outputting on the countdown channel. // If not aborted, LaunchControl fires the rocket (by outputting on its fire // channel) when the countdown reaches zero. An ABORTED launch is also reported // on this fire channel. // After a successful or aborted launch, LaunchControl terminates. public class LaunchControl implements CSProcess { public static final int MIN_COUNTDOWN = 10; public static final int FIRED = 0; public static final int HOLDING = -1; public static final int ABORTED = -2; private final int start; private final AltingChannelInputInt abort; private final AltingChannelInputInt hold; private final ChannelOutputInt countdown; private final ChannelOutputInt fire; private int status; public LaunchControl (final int start, final AltingChannelInputInt abort, final AltingChannelInputInt hold, final ChannelOutputInt countdown, final ChannelOutputInt fire) { this.start = start; this.abort = abort; this.hold = hold; this.countdown = countdown; this.fire = fire; } public int getStatus () { // inspection method return status; // not to be used while running! } public void run () { final CSTimer tim = new CSTimer (); // JCSP timers have final long oneSecond = 1000; // millisecond granularity long timeout = tim.read () + oneSecond; // compute first timeout final Alternative alt = new Alternative (new Guard[] {abort, hold, tim}); final int ABORT = 0; final int HOLD = 1; final int TICK = 2; int count = start; boolean counting = (start >= MIN_COUNTDOWN); // abort if bad start while ((count > 0) && counting) { countdown.write (count); // public address system tim.setAlarm (timeout); // set next timeout switch (alt.priSelect ()) { case ABORT: // abort signalled abort.read (); // clear the signal counting = false; break; case HOLD: // hold signalled long timeLeft = timeout - tim.read (); // time till next tick hold.read (); // clear the signal fire.write (HOLDING); // signal rocket hold.read (); // wait for the release timeout = tim.read () + timeLeft; // recompute next timeout fire.write (HOLDING); // signal rocket break; case TICK: // timeout expired count--; timeout += oneSecond; // compute next timeout break; } } status = (counting) ? FIRED : ABORTED; // set status attribute fire.write (status); // signal rocket (go/nogo) if (counting) countdown.write (0); // complete countdown } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/Polling.java0000644000000000000000000000232311105664736020777 0ustar import org.jcsp.lang.*; public class Polling implements CSProcess { private final AltingChannelInput in0; private final AltingChannelInput in1; private final AltingChannelInput in2; private final ChannelOutput out; public Polling (final AltingChannelInput in0, final AltingChannelInput in1, final AltingChannelInput in2, final ChannelOutput out) { this.in0 = in0; this.in1 = in1; this.in2 = in2; this.out = out; } public void run() { final Skip skip = new Skip (); final Guard[] guards = {in0, in1, in2, skip}; final Alternative alt = new Alternative (guards); final CSTimer tim = new CSTimer (); Object o; while (true) { switch (alt.priSelect ()) { case 0: o = in0.read (); out.write ("\tin0 ==> " + o + "\n"); break; case 1: o = in1.read (); out.write ("\t\tin1 ==> " + o + "\n"); break; case 2: o = in2.read (); out.write ("\t\t\tin2 ==> " + o + "\n"); break; case 3: out.write ("skip ...\n"); tim.after (tim.read () + 50); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/FairPlexTime.java0000644000000000000000000000227611105664736021733 0ustar import org.jcsp.lang.*; public class FairPlexTime implements CSProcess { private final AltingChannelInput[] in; private final ChannelOutput out; private final long timeout; public FairPlexTime (final AltingChannelInput[] in, final ChannelOutput out, final long timeout) { this.in = in; this.out = out; this.timeout = timeout; } public void run () { final Guard[] guards = new Guard[in.length + 1]; System.arraycopy (in, 0, guards, 0, in.length); final CSTimer tim = new CSTimer (); final int timerIndex = in.length; guards[timerIndex] = tim; final Alternative alt = new Alternative (guards); boolean running = true; tim.setAlarm (tim.read () + timeout); while (running) { final int index = alt.fairSelect (); // final int index = alt.priSelect (); if (index == timerIndex) { running = false; } else { out.write (in[index].read ()); } } System.out.println ("\n\r\tFairPlexTime: timed out ... poisoning all channels ..."); for (int i = 0; i < in.length; i++) { in[i].poison (42); } out.poison (42); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/ParallelTest.java0000644000000000000000000000164411105664736021774 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; class ParallelTest { public static void main (String[] args) { final One2OneChannelInt[] a = Channel.one2oneIntArray (3); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new NumbersInt (a[0].out ()), new SquaresInt (a[1].out ()), new FibonacciInt (a[2].out ()), new ParaplexInt (Channel.getInputArray (a), b.out ()), new CSProcess () { public void run () { System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n"); while (true) { int[] data = (int[]) b.in ().read (); for (int i = 0; i < data.length; i++) { System.out.print ("\t\t" + data[i]); } System.out.println (); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/AltingOutputIntExample.java0000644000000000000000000000133311113671251024006 0ustar import org.jcsp.lang.*; public class AltingOutputIntExample implements CSProcess { private final AltingChannelOutputInt out0, out1; public AltingOutputIntExample (final AltingChannelOutputInt out0, final AltingChannelOutputInt out1) { this.out0 = out0; this.out1 = out1; } public void run () { final Guard[] altChans = {out0, out1}; final Alternative alt = new Alternative (altChans); while (true) { switch (alt.select ()) { case 0: out0.write (0); System.out.println ("out0 written"); break; case 1: out1.write (1); System.out.println ("out1 written"); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/LaunchControlTest.java0000644000000000000000000000563211105664736023014 0ustar import org.jcsp.lang.*; public class LaunchControlTest { public static void main (String[] args) { final int start = 50; final long seconds = 1000; final long abortTime = 30000; final long holdEvery = 11654; final long holdTime = 8651; final One2OneChannelInt countdown = Channel.one2oneInt (); final One2OneChannelInt abort = Channel.one2oneInt (); final One2OneChannelInt hold = Channel.one2oneInt (); final One2OneChannelInt fire = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new LaunchControl (start, abort.in (), hold.in (), countdown.out (), fire.out ()), new CSProcess () { public void run () { // public countdown announcements int count = start; while (count > 0) { count = countdown.in ().read (); System.out.println ("Countdown = " + count + " seconds and counting ..."); } } }, new CSProcess () { public void run () { // public status announcements boolean counting = true; while (counting) { switch (fire.in ().read ()) { case LaunchControl.HOLDING: System.out.println ("HOLDING ... Enterprise is on hold ..."); fire.in ().read (); System.out.println ("ON-LINE ... Enterprise is back on-line ..."); break; case LaunchControl.ABORTED: System.out.println ("ABORT-ABORT-ABORT ... Enterprise is standing down ..."); counting = false; break; case LaunchControl.FIRED: System.out.println ("WE HAVE LIFT-OFF ... Enterprise is go ..."); counting = false; break; } } System.exit (0); } }, new CSProcess () { public void run () { // abort safety officer CSTimer tim = new CSTimer (); long t = tim.read (); tim.after (t + abortTime); System.out.println ("Who pressed that big red button ... ?!! ... !!! ..."); abort.out ().write (0); } }, new CSProcess () { public void run () { // hold safety officer CSTimer tim = new CSTimer (); long t = tim.read () + holdEvery; while (true) { tim.after (t); System.out.println ("HOLD - HOLD - HOLD ..."); hold.out ().write (0); t += holdTime; tim.after (t); System.out.println ("RELEASE - RELEASE - RELEASE ..."); hold.out ().write (0); t += holdEvery; } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/PriorityTest.java0000644000000000000000000000641111105664736022056 0ustar /******************************************************************************* * * $Archive: /jcsp/src/test/jcsp/PriorityTest.java $ * * $Date: 1998/07/21 14:17:14 $ * * $Revision: 1.1 $ * * (C) Copyright 1997/8 Paul Austin * University of Kent Canterbury ******************************************************************************/ import org.jcsp.lang.*; /** */ public class PriorityTest implements CSProcess { public void run() { noProcesses(); //staticProcesses(); //dynamicPrccesses(); staticPriority(); //dynamicPriority(); } void noProcesses() { System.out.println("Sarting Test: noProcesses()"); new Parallel().run(); System.out.println("Finished Test: noProcesses()"); } public class StaticProcesses implements CSProcess { private int index; StaticProcesses(int index) { this.index = index; } public void run() { int priority = Thread.currentThread().getPriority(); System.out.println("Process: " + index); long count = 1; for (int i = 0; i < index; i++) { count *= priority; } System.out.println("Process: " + index + ", count = " + count); } } void staticProcesses() { System.out.println("Sarting Test: staticProcesses()"); new Parallel().run(); System.out.println("Finished Test: staticProcesses()"); } void dynamicPrccesses() { System.out.println("Sarting Test: dynamicPrccesses()"); new Parallel().run(); System.out.println("Finished Test: dynamicPrccesses()"); } public class StaticPriority implements CSProcess { private int index; StaticPriority(int index) { this.index = index; } public void run() { int priority = Thread.currentThread().getPriority(); System.out.println("Process: " + index + ", priority=" + priority); long count = 1; for (int i = 0; i < index; i++) { count *= priority; } System.out.println("Process: " + index + ", count=" + count); } } /** * Note: All this test shows is that each of the processes priority is set * to the correct value. The last process will have the priority equal to * Thread.NORM_PRIORITY. */ void staticPriority() { System.out.println("Sarting Test: staticPriority()"); CSProcess[][] procs = new CSProcess[4][]; procs[0] = new CSProcess[1]; procs[1] = new CSProcess[Thread.MAX_PRIORITY - Thread.currentThread().getPriority() + 1]; procs[2] = new CSProcess[Thread.MAX_PRIORITY - Thread.currentThread().getPriority()]; procs[3] = new CSProcess[Thread.MAX_PRIORITY - Thread.currentThread().getPriority() + 2]; for (int i = 0; i < procs.length; i++) { for (int j = 0; j < procs[i].length; j++) { procs[i][j] = new StaticPriority(procs[i].length - j); } System.out.println(" Start Data: " + i); new PriParallel(procs[i]).run(); System.out.println(" End Data: " + i); } System.out.println("Finished Test: staticPriority()"); } void dynamicPriority() { System.out.println("Sarting Test: dynamicPriority()"); new Parallel().run(); System.out.println("Finished Test: dynamicPriority()"); } public static void main(String[] argv) { new PriorityTest().run(); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/FairPlexTimeTest.java0000644000000000000000000000151111105664736022562 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; class FairPlexTimeTest { public static void main (String[] args) { final long timeout = 5000; // 5 seconds final One2OneChannel[] a = Channel.one2oneArray (5, 0); // poisonable channels (zero immunity) final One2OneChannel b = Channel.one2one (0); // poisonable channels (zero immunity) new Parallel ( new CSProcess[] { new Generate (a[0].out (), 0), new Generate (a[1].out (), 1), new Generate (a[2].out (), 2), new Generate (a[3].out (), 3), new Generate (a[4].out (), 4), new FairPlexTime (Channel.getInputArray (a), b.out (), timeout), new Printer (b.in (), "FairPlexTimeTest ==> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/BenchMark.java0000644000000000000000000000600211105701167021211 0ustar /******************************************************************************* * * $Archive: /jcsp/src/test/jcsp/BenchMark.java $ * * $Date: 1998/07/21 14:17:10 $ * * $Revision: 1.1 $ * * (C) Copyright 1997/8 Paul Austin * University of Kent Canterbury ******************************************************************************/ // package test.jcsp; import org.jcsp.lang.*; import org.jcsp.plugNplay.*; import java.util.*; /** *

Process Diagram

*

External View

*
 *  _____________
 * |             |
 * |  BenchMark  |
 * |_____________|
 * 
*

Internal View

*
 *  _______________________________
 * |                               |
 * |  ___________       _________  |
 * | |           |     |         | |
 * | |  Numbers  |-->--| Consume | |
 * | |___________|     |_________| |
 * |                               |
 * |                     BenchMark |
 * |_______________________________|
 * 
*

*

Description

* The BenchMark process is used to give an estimate of the synchronisation * overhead of Channel communication. *

* The CSProcess has two CSProcesses executing in Parallel: Numbers and Consume * The output of the Numbers process is connecting to the input of the Consume * process. *

* The Consume process reads 50 Objects from the input Channel to discard * any start-up overhead. It then times the time to read the next 5000 Objects * and then writes to the screen the time taken in total and per loop then * exits. * * @author P.D. Austin */ public class BenchMark implements CSProcess { /** * The main body of this process. */ public void run() { One2OneChannel a = Channel.one2one(); new Parallel(new CSProcess[] { new Numbers (a.out ()), new Consume (5000, a.in ()) }).run(); } /** * Main entry point for the application. */ public static void main(String argv[]) { new BenchMark().run(); } /** * The consume Process. */ protected class Consume implements CSProcess { private ChannelInput in; private int nLoops; /** * Constructs a new Consume Process */ public Consume(int nLoops, ChannelInput in) { this.in = in; this.nLoops = nLoops; } /** * The main body of this process. */ public void run() { int warmUp = 50; for(int i = 0; i < warmUp; i++) { in.read(); } Date date1 = new Date(); for(int i = 0; i < nLoops; i++) { Object o = in.read(); } Date date2 = new Date(); long microSeconds = ((date2.getTime() - date1.getTime()) * 1000); System.out.println(" " + microSeconds + " microseconds"); long timePerLoop = (microSeconds / ((long)nLoops)); System.out.println(" " + timePerLoop + " microseconds / iteration"); System.exit(0); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/RegulateTest.java0000644000000000000000000000261011105664736022002 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; class RegulateTest { public static void main (String[] args) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); final One2OneChannel c = Channel.one2one (); final One2OneChannel reset = Channel.one2one (new OverWriteOldestBuffer (1)); new Parallel ( new CSProcess[] { new Numbers (a.out ()), // generate numbers new FixedDelay (250, a.in (), b.out ()), // let them through every quarter second new Regulate (b.in (), reset.in (), c.out (), 1000), // initially sample every second new CSProcess () { public void run () { Long[] sample = {new Long (1000), new Long (250), new Long (100)}; int[] count = {10, 40, 100}; while (true) { for (int cycle = 0; cycle < sample.length; cycle++) { reset.out ().write (sample[cycle]); System.out.println ("\nSampling every " + sample[cycle] + " ms ...\n"); for (int i = 0; i < count[cycle]; i++) { Integer n = (Integer) c.in ().read (); System.out.println ("\t==> " + n); } } } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/ProcessManagerExample1.java0000644000000000000000000000176711105664736023714 0ustar import org.jcsp.lang.*; public class ProcessManagerExample1 { public static void main (String[] argv) { final ProcessManager manager = new ProcessManager ( new CSProcess () { public void run () { final CSTimer tim = new CSTimer (); long timeout = tim.read (); int count = 0; while (true) { System.out.println (count + " :-) managed process running ..."); count++; timeout += 100; tim.after (timeout); // every 1/10th of a second ... } } } ); CSTimer tim = new CSTimer (); long timeout = tim.read (); System.out.println ("\n\n\t\t\t\t\t*** start the managed process"); manager.start (); for (int i = 0; i < 10; i++) { System.out.println ("\n\n\t\t\t\t\t*** I'm still executing as well"); timeout += 1000; tim.after (timeout); // every second ... } System.out.println ("\n\n\t\t\t\t\t*** I'm finishing now!"); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/Canteen.java0000644000000000000000000000306011105664736020747 0ustar import org.jcsp.lang.*; public class Canteen implements CSProcess { private final AltingChannelInput supply; // from the cook private final AltingChannelInput request; // from a philosopher private final ChannelOutput deliver; // to a philosopher public Canteen (final AltingChannelInput supply, final AltingChannelInput request, final ChannelOutput deliver) { this.supply = supply; this.request = request; this.deliver = deliver; } public void run() { final Guard[] guard = {supply, request}; final boolean[] preCondition = new boolean[guard.length]; final int SUPPLY = 0; final int REQUEST = 1; final Alternative alt = new Alternative (guard); final int maxChickens = 20; final int maxSupply = 4; final int limitChickens = maxChickens - maxSupply; final Integer oneChicken = new Integer (1); // ready to go! int nChickens = 0; // invariant : 0 <= nChickens <= maxChickens while (true) { preCondition[SUPPLY] = (nChickens <= limitChickens); preCondition[REQUEST] = (nChickens > 0); switch (alt.priSelect (preCondition)) { case SUPPLY: nChickens += ((Integer) supply.read ()).intValue (); // <= maxSupply break; case REQUEST: Object dummy = request.read (); // we have to still input the signal deliver.write (oneChicken); // preCondition ==> (nChickens > 0) nChickens--; break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/Regulate.java0000644000000000000000000001175011113065047021134 0ustar /************************************************************************* * * * JCSP ("CSP for Java") libraries * * Copyright (C) 1996-2008 Peter Welch and Paul Austin. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, * * USA. * * * * Author contact: P.H.Welch@ukc.ac.uk * * * *************************************************************************/ // package org.jcsp.plugNplay; // // This class *is* in the above package. It is reproduced here because // this source is quoted in the documentation of org.jcsp.lang.Alternative. // The above package declaration is commented out since, otherwise, // compiling the *java files in this directory would fail (because of // an attempt to duplicate Regulate in org.jcsp.plugNplay). //{{{ javadoc /** * This process controls the flow of traffic from its in to out channels. *

Description

* Regulate produces a constant rate of output flow, regardless of * the rate of its input. At the end of each timeslice defined by the required * output rate, it outputs the last object input during that timeslice. * If nothing has come in during a timeslice, the previous output will be repeated * (note: this will be a null if nothing has ever arrived). * If the input flow is greater than the required output flow, data will be discarded. *

* The interval (in msecs) defining the output flow rate is given by a constructor * argument; but this can be changed at any time by sending a new interval (as a Long) * down its reset channel. *

Description

* See {@link Alternative#STFR here}. * * @see org.jcsp.plugNplay.FixedDelay * @see org.jcsp.plugNplay.Regular * * @author P.H.Welch * */ //}}} import org.jcsp.lang.*; public class Regulate implements CSProcess { private final AltingChannelInput in, reset; private final ChannelOutput out; private final long initialInterval; /** * Construct the process. * * @param in the input channel * @param out the output channel * @param initialInterval the initial interval between outputs (in milliseconds) * @param reset send a Long down this to change the interval between outputs (in milliseconds) */ public Regulate (final AltingChannelInput in, final AltingChannelInput reset, final ChannelOutput out, final long initialInterval) { this.in = in; this.reset = reset; this.out = out; this.initialInterval = initialInterval; } /** * The main body of this process. */ public void run () { final CSTimer tim = new CSTimer (); final Guard[] guards = {reset, tim, in}; // prioritised order final int RESET = 0; // index into guards final int TIM = 1; // index into guards final int IN = 2; // index into guards final Alternative alt = new Alternative (guards); Object x = null; // holding object long interval = initialInterval; long timeout = tim.read () + interval; tim.setAlarm (timeout); while (true) { switch (alt.priSelect ()) { case RESET: interval = ((Long) reset.read ()).longValue (); timeout = tim.read (); // fall through case TIM: out.write (x); timeout += interval; tim.setAlarm (timeout); break; case IN: x = in.read (); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/PollingTest.java0000644000000000000000000000105611105664736021641 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; class PollingTest { public static void main (String[] args) { final One2OneChannel[] a = Channel.one2oneArray (3); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new Regular (a[0].out (), 100, 100), new Regular (a[1].out (), 250, 250), new Regular (a[2].out (), 1000, 1000), new Polling (a[0].in (), a[1].in (), a[2].in (), b.out ()), new Printer (b.in ()) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/SquaresIntTest.java0000644000000000000000000000476411105701167022332 0ustar /******************************************************************************* * * $Archive: /jcsp/src/test/jcsp/BlocksTest.java $ * * $Date: 1998/07/21 14:17:10 $ * * $Revision: 1.1 $ * * (C) Copyright 1997/8 Paul Austin * University of Kent Canterbury ******************************************************************************/ // package test.jcsp; import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; import org.jcsp.util.ints.*; /** *

Process Diagram

*

External View

*
 *  ________________
 * |                |
 * | SquaresIntTest |
 * |________________|
 * 
*

Internal View

*
 *  ____________________________________________________
 * |                                                    |
 * |  ______________       ________       ____________  |
 * | |              |  a  |        |  b  |            | |
 * | |  SquaresInt  |-->--|  anon  |-->--| PrinterInt | |
 * | |______________|     |________|     |____________| |
 * |                                                    |
 * |                                         BlocksTest |
 * |____________________________________________________|
 * 
*

*

Description

* The BlocksTest process is designed to test some of the plugNplay processes. *

*

Sourcecode

* * @author P.D. Austin and P.H.Welch */ public class SquaresIntTest implements CSProcess { /** * The main body of this process. */ public void run () { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new SquaresInt (a.out ()), new CSProcess () { public void run () { // this anonymous process int n = a.in ().read (); // terminates when the numbers while (n > 0) { // overflow, deadlocking b.out ().write (n); // the pipeline of which n = a.in ().read (); // it is a component. } } }, new PrinterInt (b.in (), "Perfect squares ==> ", "\n") } ).run (); } /** * Main entry point for the application. */ public static void main (String argv[]) { new SquaresIntTest ().run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/AltingIntExample.java0000644000000000000000000000123511113671251022566 0ustar import org.jcsp.lang.*; public class AltingIntExample implements CSProcess { private final AltingChannelInputInt in0, in1; public AltingIntExample (final AltingChannelInputInt in0, final AltingChannelInputInt in1) { this.in0 = in0; this.in1 = in1; } public void run () { final Guard[] altChans = {in0, in1}; final Alternative alt = new Alternative (altChans); while (true) { switch (alt.select ()) { case 0: System.out.println ("in0 read " + in0.read ()); break; case 1: System.out.println ("in1 read " + in1.read ()); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/lang/FairPlexTest.java0000644000000000000000000000121611105664736021745 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.Printer; class FairPlexTest { public static void main (String[] args) { final One2OneChannel[] a = Channel.one2oneArray (5); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new Regular (a[0].out (), 0, 5), new Regular (a[1].out (), 1, 5), new Regular (a[2].out (), 2, 5), new Regular (a[3].out (), 3, 5), new Regular (a[4].out (), 4, 5), new FairPlex (Channel.getInputArray (a), b.out ()), new Printer (b.in (), "FairPlexTest ==> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/0000755000000000000000000000000011410045035016362 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveChoiceExample.java0000644000000000000000000000235411105664736023113 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveChoiceExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveChoice Example"); final One2OneChannel close = Channel.one2one (new OverWriteOldestBuffer (1)); final ActiveChoice choice = new ActiveChoice (null, close.out ()); final String[] menu = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; for (int i = 0; i < menu.length; i++) { choice.add (menu[i]); } root.setSize (200, 100); root.add (choice); root.setVisible (true); new Parallel ( new CSProcess[] { choice, new CSProcess () { public void run () { boolean running = true; while (running) { ItemEvent e = (ItemEvent) close.in ().read (); String item = (String) e.getItem (); System.out.println ("Selected ==> `" + item + "'"); running = (item != menu[menu.length - 1]); } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/FlasherControl.java0000644000000000000000000001132111113055740022154 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class FlasherControl implements CSProcess { final private long period; final private AltingChannelInput mouseEvent; final private ChannelOutput appletConfigure; public FlasherControl (final long period, final AltingChannelInput mouseEvent, final ChannelOutput appletConfigure) { this.period = period; this.mouseEvent = mouseEvent; this.appletConfigure = appletConfigure; } private class AppletColour implements ActiveApplet.Configure { private Color colour = Color.lightGray; public void setColour (Color colour) { this.colour = colour; } public void configure (java.applet.Applet applet) { applet.setBackground (colour); applet.repaint (); } } public void run () { final Random random = new Random (); final CSTimer tim = new CSTimer (); final Alternative alt = new Alternative (new Guard[] {mouseEvent, tim}); final boolean[] preCondition = {true, false}; final int MOUSE = 0; final int TIMER = 1; final AppletColour[] appletColour = {new AppletColour (), new AppletColour ()}; final AppletColour panelBlack = new AppletColour (); panelBlack.setColour (Color.black); appletConfigure.write (panelBlack); int index = 0; AppletColour appletCol = appletColour[index]; appletCol.setColour (new Color (random.nextInt ())); long timeout = tim.read (); boolean mousePresent = false; boolean running = true; while (running) { switch (alt.priSelect (preCondition)) { case MOUSE: switch (((MouseEvent) mouseEvent.read ()).getID ()) { case MouseEvent.MOUSE_ENTERED: if (! mousePresent) { mousePresent = true; timeout = tim.read () + period; tim.setAlarm (timeout); appletConfigure.write (appletCol); preCondition[TIMER] = true; } break; case MouseEvent.MOUSE_EXITED: if (mousePresent) { mousePresent = false; appletConfigure.write (panelBlack); preCondition[TIMER] = false; } break; } break; case TIMER: // System.out.println ("FlasherControl: tick"); timeout += period; tim.setAlarm (timeout); index = 1 - index; appletCol = appletColour[index]; appletCol.setColour (new Color (random.nextInt ())); appletConfigure.write (appletCol); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveCheckboxMenuItemExample.java0000644000000000000000000000543211105664736025113 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveCheckboxMenuItemExample { public static void main (String argv[]) { final ActiveClosingFrame activeClosingFrame = new ActiveClosingFrame ("ActiveCheckboxMenuItem Example"); final ActiveFrame frame = activeClosingFrame.getActiveFrame (); final MenuBar menuBar = new MenuBar (); frame.setMenuBar (menuBar); final Menu fileMenu = new Menu ("File"); final Menu langMenu = new Menu ("Language"); menuBar.add (fileMenu); menuBar.add (langMenu); final String[] fileOptions = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; final String[] langOptions = {"occam-pi", "Java", "Smalltalk", "Algol-60", "Pascal", "Haskell", "SML", "Lisp"}; final Any2OneChannel event[] = Channel.any2oneArray (2, new OverWriteOldestBuffer (10)); final ActiveMenuItem[] fileMenuItem = new ActiveMenuItem[fileOptions.length]; for (int i = 0; i < fileOptions.length; i++) { fileMenuItem[i] = new ActiveMenuItem (null, event[0].out (), fileOptions[i]); fileMenu.add (fileMenuItem[i]); } final ActiveCheckboxMenuItem[] langCheckboxMenuItem = new ActiveCheckboxMenuItem[langOptions.length]; for (int i = 0; i < langOptions.length; i++) { langCheckboxMenuItem[i] = new ActiveCheckboxMenuItem (null, event[1].out (), langOptions[i]); langMenu.add (langCheckboxMenuItem[i]); } frame.setSize (300, 200); frame.setBackground (Color.green); frame.setVisible (true); new Parallel ( new CSProcess[] { activeClosingFrame, new Parallel (fileMenuItem), new Parallel (langCheckboxMenuItem), new CSProcess () { public void run () { boolean running = true; while (running) { final String s = (String) event[0].in ().read (); System.out.println ("File ==> `" + s + "' selected ..."); running = (s != fileOptions[fileOptions.length - 1]); } frame.setVisible (false); System.exit (0); } }, new CSProcess () { public void run () { while (true) { final ItemEvent e = (ItemEvent) event[1].in ().read (); final String item = (String) e.getItem (); System.out.print ("Language ==> `" + item); if (e.getStateChange () == ItemEvent.SELECTED) { System.out.println ("' selected ..."); } else { System.out.println ("' deselected ..."); } } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveFileDialogExample.java0000644000000000000000000000220311105664736023711 0ustar import java.awt.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveFileDialogExample { public static void main (String argv[]) { final Frame root = new Frame (); final One2OneChannel configure = Channel.one2one (); final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10)); final ActiveFileDialog fileDialog = new ActiveFileDialog (configure.in (), event.out (), root, "ActiveFileDialog Example"); new Parallel ( new CSProcess[] { fileDialog, new CSProcess () { public void run () { String dir = "."; // start directory for the file dialogue String file = ""; while (file != null) { configure.out ().write (dir); configure.out ().write (Boolean.TRUE); dir = (String) event.in ().read (); file = (String) event.in ().read (); if (file != null) System.out.println ("Chosen file = `" + dir + file + "'"); } System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveContainerExample.java0000644000000000000000000000352711105664736023646 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.util.*; import org.jcsp.lang.*; import org.jcsp.awt.*; public class ActiveContainerExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveContainer Example"); final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10)); final ActiveContainer container = new ActiveContainer (); container.addMouseEventChannel (mouseEvent.out ()); root.add (container); root.setSize (400, 400); root.setVisible (true); new Parallel ( new CSProcess[] { container, new CSProcess () { public void run () { boolean running = true; while (running) { final MouseEvent event = (MouseEvent) mouseEvent.in ().read (); switch (event.getID ()) { case MouseEvent.MOUSE_ENTERED: System.out.println ("MOUSE_ENTERED"); break; case MouseEvent.MOUSE_EXITED: System.out.println ("MOUSE_EXITED"); break; case MouseEvent.MOUSE_PRESSED: System.out.println ("MOUSE_PRESSED"); break; case MouseEvent.MOUSE_RELEASED: System.out.println ("MOUSE_RELEASED"); break; case MouseEvent.MOUSE_CLICKED: if (event.getClickCount() > 1) { System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!"); running = false; } else { System.out.println ("MOUSE_CLICKED ... *double* click to quit!"); } break; } } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveDialogExample.java0000644000000000000000000000153211105664736023115 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveDialogExample { public static void main (String argv[]) { final Frame root = new Frame (); final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10)); final ActiveDialog dialog = new ActiveDialog (null, event.out (), root, "ActiveDialog Example"); // root.setSize (400, 400); // root.setVisible (true); dialog.setSize (300, 200); dialog.setVisible (true); new Parallel ( new CSProcess[] { dialog, new CSProcess () { public void run () { while (true) { WindowEvent w = (WindowEvent) event.in ().read (); System.out.println (w); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveTextEnterFieldExample.java0000644000000000000000000000330211105664736024601 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; public class ActiveTextEnterFieldExample { public static void main (String argv[]) { final ActiveClosingFrame frame = new ActiveClosingFrame ("ActiveTextEnterField Example"); final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10)); final String[] string = {"Entia Non Sunt Multiplicanda Praeter Necessitatem", "Less is More ... More or Less", "Everything we do, we do it to you", "Race Hazards - What Rice Hozzers?", "Cogito Ergo Occam"}; final String goodbye = "Goodbye World"; final ActiveTextEnterField[] activeText = new ActiveTextEnterField[string.length]; for (int i = 0; i < string.length; i++) { activeText[i] = new ActiveTextEnterField (null, event.out (), string[i]); } Panel panel = new Panel (new GridLayout (string.length, 1)); for (int i = 0; i < string.length; i++) { panel.add (activeText[i].getActiveTextField ()); } final Frame realFrame = frame.getActiveFrame (); realFrame.setBackground (Color.green); realFrame.add (panel); realFrame.pack (); realFrame.setVisible (true); new Parallel ( new CSProcess[] { frame, new Parallel (activeText), new CSProcess () { public void run () { boolean running = true; while (running) { String s = (String) event.in ().read (); System.out.println (s); running = (! s.equals (goodbye)); } realFrame.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveMenuExample.java0000644000000000000000000000657211105664736022633 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveMenuExample { public static void main (String argv[]) { final ActiveClosingFrame activeClosingFrame = new ActiveClosingFrame ("ActiveCheckboxMenuItem Example"); final ActiveFrame frame = activeClosingFrame.getActiveFrame (); final MenuBar menuBar = new MenuBar (); frame.setMenuBar (menuBar); final Menu fileMenu = new Menu ("File"); menuBar.add (fileMenu); final String[] fileOptions = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; final Any2OneChannel event[] = Channel.any2oneArray (2, new OverWriteOldestBuffer (10)); final ActiveMenuItem[] fileMenuItem = new ActiveMenuItem[fileOptions.length]; for (int i = 0; i < fileOptions.length; i++) { fileMenuItem[i] = new ActiveMenuItem (null, event[0].out (), fileOptions[i]); fileMenu.add (fileMenuItem[i]); } fileMenu.addSeparator (); final Any2OneChannel langConfigure = Channel.any2one (); final ActiveMenu langMenu = new ActiveMenu (langConfigure.in (), null, "Language"); fileMenu.add (langMenu); // set up the active langMenu as a sub-menu final String[] langOptions = {"occam-pi", "Java", "Smalltalk", "Algol-60", "Pascal", "Haskell", "SML", "Lisp"}; final ActiveCheckboxMenuItem[] langCheckboxMenuItem = new ActiveCheckboxMenuItem[langOptions.length]; for (int i = 0; i < langOptions.length; i++) { langCheckboxMenuItem[i] = new ActiveCheckboxMenuItem (null, event[1].out (), langOptions[i]); langMenu.add (langCheckboxMenuItem[i]); } frame.setSize (700, 350); frame.setBackground (Color.green); frame.setVisible (true); new Parallel ( new CSProcess[] { // don't forget to include all active processes langMenu, activeClosingFrame, new Parallel (fileMenuItem), new Parallel (langCheckboxMenuItem), new CSProcess () { public void run () { boolean running = true; while (running) { final String s = (String) event[0].in ().read (); System.out.println ("File ==> `" + s + "' selected ..."); if (s == fileOptions[0]) { langConfigure.out ().write (Boolean.TRUE); System.out.println ("`Language' enabled ..."); } running = (s != fileOptions[fileOptions.length - 1]); } frame.setVisible (false); System.exit (0); } }, new CSProcess () { public void run () { while (true) { final ItemEvent e = (ItemEvent) event[1].in ().read (); final String item = (String) e.getItem (); System.out.print ("Language ==> `" + item); if (e.getStateChange () == ItemEvent.SELECTED) { System.out.println ("' selected ..."); if (item == langOptions[0]) { langConfigure.out ().write (Boolean.FALSE); System.out.println ("`Language' disabled ..."); } } else { System.out.println ("' deselected ..."); } } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveTextFieldExample.java0000644000000000000000000000323211105664736023605 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; public class ActiveTextFieldExample { public static void main (String argv[]) { final ActiveClosingFrame frame = new ActiveClosingFrame ("ActiveTextFieldExample Example"); final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10)); final String[] string = {"Entia Non Sunt Multiplicanda Praeter Necessitatem", "Less is More ... More or Less", "Everything we do, we do it to you", "Race Hazards - What Rice Hozzers?", "Cogito Ergo Occam"}; final String goodbye = "Goodbye World"; final ActiveTextField[] activeText = new ActiveTextField[string.length]; for (int i = 0; i < string.length; i++) { activeText[i] = new ActiveTextField (null, event.out (), string[i]); } Panel panel = new Panel (new GridLayout (string.length, 1)); for (int i = 0; i < string.length; i++) { panel.add (activeText[i]); } final Frame realFrame = frame.getActiveFrame (); realFrame.setBackground (Color.green); realFrame.add (panel); realFrame.pack (); realFrame.setVisible (true); new Parallel ( new CSProcess[] { frame, new Parallel (activeText), new CSProcess () { public void run () { boolean running = true; while (running) { String s = (String) event.in ().read (); System.out.println (s); running = (! s.equals (goodbye)); } realFrame.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveClosingFrameButtonExample.java0000644000000000000000000000301011105664736025454 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveClosingFrameButtonExample { public static void main (String argv[]) { final ActiveClosingFrame frame = new ActiveClosingFrame ("ActiveClosingFrameButton Example"); final String[] label = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; final Any2OneChannel buttonEvent = Channel.any2one (new OverWriteOldestBuffer (10)); final ActiveButton[] button = new ActiveButton[label.length]; for (int i = 0; i < label.length; i++) { button[i] = new ActiveButton (null, buttonEvent.out (), label[i]); } final Frame realFrame = frame.getActiveFrame (); realFrame.setSize (300, 200); realFrame.setLayout (new GridLayout (label.length/2, 2)); for (int i = 0; i < label.length; i++) { realFrame.add (button[i]); } realFrame.setVisible (true); new Parallel ( new CSProcess[] { frame, new Parallel (button), new CSProcess () { public void run () { boolean running = true; while (running) { final String s = (String) buttonEvent.in ().read (); System.out.println ("Button `" + s + "' pressed ..."); running = (s != label[label.length - 1]); } realFrame.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveWindowExample.java0000644000000000000000000000146311105664736023170 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveWindowExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveWindow Example"); final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10)); final ActiveWindow window = new ActiveWindow (null, event.out (), root); root.setSize (400, 400); root.setVisible (true); window.setVisible (true); new Parallel ( new CSProcess[] { window, new CSProcess () { public void run () { while (true) { WindowEvent w = (WindowEvent) event.in ().read (); System.out.println (w); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveListExample.java0000644000000000000000000000531111105664736022630 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveListExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveList Example"); final One2OneChannel configure = Channel.one2one (); final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10)); final One2OneChannel itemEvent = Channel.one2one (new OverWriteOldestBuffer (10)); final ActiveList list = new ActiveList (configure.in (), event.out (), 0, true); list.addItemEventChannel (itemEvent.out ()); final String[] menu = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; for (int i = 0; i < menu.length; i++) { list.add (menu[i]); } root.setSize (300, 105); root.add (list); root.setVisible (true); new Parallel ( new CSProcess[] { // respond to the event channel list, new CSProcess () { public void run () { boolean running = true; while (running) { final String s = (String) event.in ().read (); System.out.println (" Action ==> `" + s + "'"); running = (s != menu[menu.length - 1]); } root.setVisible (false); System.exit (0); } }, new CSProcess () { // respond to the itemEvent channel public void run () { while (true) { final ItemEvent e = (ItemEvent) itemEvent.in ().read (); final Integer item = (Integer) e.getItem (); if (e.getStateChange () == ItemEvent.SELECTED) { System.out.println ("Selected item " + item); } else { System.out.println ("Unselected item " + item); } } } }, new CSProcess () { // dynamically reconfigure the list public void run () { CSTimer tim = new CSTimer (); long timeout = tim.read (); while (true) { timeout += 10000; tim.after (timeout); System.out.println ("*** Removing last three items ..."); for (int i = 3; i < menu.length; i++) { configure.out ().write ("-" + menu[i]); } timeout += 10000; tim.after (timeout); System.out.println ("*** Restoring last three items ..."); for (int i = 3; i < menu.length; i++) { configure.out ().write (menu[i]); } } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/FlasherNetwork.java0000644000000000000000000000536211113055740022175 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; public class FlasherNetwork implements CSProcess { final private long period; final private ActiveApplet activeApplet; public FlasherNetwork (final long period, final ActiveApplet activeApplet) { this.period = period; this.activeApplet = activeApplet; } public void run () { final One2OneChannel mouseEvent = Channel.one2one (); final One2OneChannel appletConfigure = Channel.one2one (); activeApplet.addMouseEventChannel (mouseEvent.out()); activeApplet.setConfigureChannel (appletConfigure.in()); new Parallel ( new CSProcess[] { activeApplet, new FlasherControl (period, mouseEvent.in(), appletConfigure.out()) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveCanvasExample.java0000644000000000000000000000634611105664736023141 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveCanvasExample { public static void main (String argv[]) { final ActiveClosingFrame activeClosingFrame = new ActiveClosingFrame ("ActiveCanvas Example"); final Frame frame = activeClosingFrame.getActiveFrame (); final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10)); final DisplayList displayList = new DisplayList (); final ActiveCanvas canvas = new ActiveCanvas (); canvas.addMouseEventChannel (mouseEvent.out ()); canvas.setPaintable (displayList); canvas.setSize (600, 400); frame.add (canvas); frame.pack (); frame.setVisible (true); new Parallel ( new CSProcess[] { activeClosingFrame, canvas, new CSProcess () { public void run () { final String clickMessage = "D O U B L E - C L I C K T H E M O U S E T O E X I T"; final String clickPlea = " P L E A S E M O V E T H E M O U S E B A C K "; final GraphicsCommand[] mouseEntered = {new GraphicsCommand.SetColor (Color.cyan), new GraphicsCommand.FillRect (0, 0, 600, 400), new GraphicsCommand.SetColor (Color.black), new GraphicsCommand.DrawString (clickMessage, 140, 200)}; final GraphicsCommand[] mouseExited = {new GraphicsCommand.SetColor (Color.pink), new GraphicsCommand.FillRect (0, 0, 600, 400), new GraphicsCommand.SetColor (Color.black), new GraphicsCommand.DrawString (clickPlea, 140, 200)}; final GraphicsCommand mousePressed = new GraphicsCommand.DrawString (clickMessage, 160, 220); final GraphicsCommand mouseReleased = new GraphicsCommand.DrawString (clickMessage, 140, 200); displayList.set (mouseExited); boolean running = true; while (running) { final MouseEvent event = (MouseEvent) mouseEvent.in ().read (); switch (event.getID ()) { case MouseEvent.MOUSE_ENTERED: System.out.println ("MOUSE_ENTERED"); displayList.set (mouseEntered); break; case MouseEvent.MOUSE_EXITED: System.out.println ("MOUSE_EXITED"); displayList.set (mouseExited); break; case MouseEvent.MOUSE_PRESSED: System.out.println ("MOUSE_PRESSED"); displayList.change (mousePressed, 3); break; case MouseEvent.MOUSE_RELEASED: System.out.println ("MOUSE_RELEASED"); displayList.change (mouseReleased, 3); break; case MouseEvent.MOUSE_CLICKED: if (event.getClickCount() > 1) { System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!"); running = false; } break; } } frame.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveLabelExample.java0000644000000000000000000000473211105664736022742 0ustar import java.awt.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveLabelExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveLabel Example"); final int nLabels = 8; final int countdown = 10; final One2OneChannel[] configureLabel = Channel.one2oneArray (nLabels); final ActiveLabel[] label = new ActiveLabel[nLabels]; for (int i = 0; i < label.length; i++) { label[i] = new ActiveLabel (configureLabel[i].in (), "==> " + countdown + " <=="); label[i].setAlignment (Label.CENTER); } final One2OneChannel configureButton = Channel.one2one (); final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10)); final ActiveButton button = new ActiveButton (configureButton.in (), event.out (), "Start"); root.setSize (300, 200); root.setLayout (new GridLayout (3, 3)); for (int i = 0; i < nLabels + 1; i++) { if (i < 4) { root.add (label[i]); } else if (i == 4) { root.add (button); } else if (i > 4) { root.add (label[i - 1]); } } root.setVisible (true); new Parallel ( new CSProcess[] { new Parallel (label), button, new CSProcess () { public void run () { final long second = 1000; CSTimer tim = new CSTimer (); Alternative alt = new Alternative (new Guard[] {event.in (), tim}); event.in ().read (); // wait for the start signal configureButton.out ().write ("Restart"); int count = countdown; long timeout = tim.read () + second; while (count > 0) { tim.setAlarm (timeout); switch (alt.priSelect ()) { case 0: // reset signal event.in ().read (); // clear the reset timeout = tim.read () + second; count = countdown; break; case 1: // timeout signal timeout += second; count--; break; } final String newLabel = "==> " + count + " <=="; for (int i = 0; i < nLabels; i++) { configureLabel[i].out ().write (newLabel); } } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActivePanelExample.java0000644000000000000000000000346711105664736022766 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.util.*; import org.jcsp.lang.*; import org.jcsp.awt.*; public class ActivePanelExample { public static void main (String argv[]) { final Frame root = new Frame ("ActivePanel Example"); final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10)); final ActivePanel panel = new ActivePanel (); panel.addMouseEventChannel (mouseEvent.out ()); root.add (panel); root.setSize (400, 400); root.setVisible (true); new Parallel ( new CSProcess[] { panel, new CSProcess () { public void run () { boolean running = true; while (running) { final MouseEvent event = (MouseEvent) mouseEvent.in ().read (); switch (event.getID ()) { case MouseEvent.MOUSE_ENTERED: System.out.println ("MOUSE_ENTERED"); break; case MouseEvent.MOUSE_EXITED: System.out.println ("MOUSE_EXITED"); break; case MouseEvent.MOUSE_PRESSED: System.out.println ("MOUSE_PRESSED"); break; case MouseEvent.MOUSE_RELEASED: System.out.println ("MOUSE_RELEASED"); break; case MouseEvent.MOUSE_CLICKED: if (event.getClickCount() > 1) { System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!"); running = false; } else { System.out.println ("MOUSE_CLICKED ... *double* click to quit!"); } break; } } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveCheckboxExample.java0000644000000000000000000000307611105664736023451 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveCheckboxExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveCheckbox Example"); final String[] box = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10)); final ActiveCheckbox[] check = new ActiveCheckbox[box.length]; for (int i = 0; i < box.length; i++) { check[i] = new ActiveCheckbox (null, event.out (), box[i]); } root.setSize (300, 200); root.setLayout (new GridLayout (box.length, 1)); for (int i = 0; i < box.length; i++) { root.add (check[i]); } root.setVisible (true); new Parallel ( new CSProcess[] { new Parallel (check), new CSProcess () { public void run () { boolean running = true; while (running) { final ItemEvent e = (ItemEvent) event.in ().read (); final String item = (String) e.getItem (); if (e.getStateChange () == ItemEvent.SELECTED) { System.out.println ("Checked ==> `" + item + "'"); running = (item != box[box.length - 1]); } else { System.out.println ("Unchecked ==> `" + item + "'"); } } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/FlasherApplet.java0000644000000000000000000000471411113056135021770 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; public class FlasherApplet extends ActiveApplet { public static final int minPeriod = 300; // milliseconds public static final int maxPeriod = 1000; // milliseconds public static final int defaultPeriod = 500; // milliseconds public void init () { final int period = getAppletInt ("period", minPeriod, maxPeriod, defaultPeriod); setProcess (new FlasherNetwork (period, this)); // setProcess (new FlasherNetworkSSD (period, this)); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveButtonExample.java0000644000000000000000000000256311105664736023176 0ustar import java.awt.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveButtonExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveButton Example"); final String[] label = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10)); final ActiveButton[] button = new ActiveButton[label.length]; for (int i = 0; i < label.length; i++) { button[i] = new ActiveButton (null, event.out (), label[i]); button[i].setBackground (Color.green); } root.setSize (300, 200); root.setLayout (new GridLayout (label.length/2, 2)); for (int i = 0; i < label.length; i++) { root.add (button[i]); } root.setVisible (true); new Parallel ( new CSProcess[] { new Parallel (button), new CSProcess () { public void run () { boolean running = true; while (running) { final String s = (String) event.in ().read (); System.out.println ("Button `" + s + "' pressed ..."); running = (s != label[label.length - 1]); } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveFrameButtonExample.java0000644000000000000000000000401111105664736024137 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveFrameButtonExample { public static void main (String argv[]) { final Any2OneChannel windowEvent = Channel.any2one (new OverWriteOldestBuffer (10)); final ActiveFrame frame = new ActiveFrame (null, windowEvent.out (), "ActiveButton Example"); final String[] label = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; final Any2OneChannel buttonEvent = Channel.any2one (new OverWriteOldestBuffer (10)); final ActiveButton[] button = new ActiveButton[label.length]; for (int i = 0; i < label.length; i++) { button[i] = new ActiveButton (null, buttonEvent.out (), label[i]); } frame.setSize (300, 200); frame.setLayout (new GridLayout (label.length/2, 2)); for (int i = 0; i < label.length; i++) { frame.add (button[i]); } frame.setVisible (true); new Parallel ( new CSProcess[] { new Parallel (button), new CSProcess () { // respond to window events public void run () { boolean running = true; while (running) { final WindowEvent w = (WindowEvent) windowEvent.in ().read (); System.out.println ("Window event: " + w); running = (w.getID () != WindowEvent.WINDOW_CLOSING); } frame.setVisible (false); System.exit (0); } }, new CSProcess () { // respond to button events public void run () { boolean running = true; while (running) { final String s = (String) buttonEvent.in ().read (); System.out.println ("Button `" + s + "' pressed ..."); running = (s != label[label.length - 1]); } frame.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveTextEnterAreaExample.java0000644000000000000000000000323511105664736024433 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; public class ActiveTextEnterAreaExample { public static void main (String argv[]) { final ActiveClosingFrame frame = new ActiveClosingFrame ("ActiveTextEnterArea Example"); final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10)); final String[] string = {"Entia Non Sunt Multiplicanda Praeter Necessitatem", "Everything we do, we do it to you", "Race Hazards - What Rice Hozzers?", "Cogito Ergo Occam"}; final String goodbye = "Goodbye World"; final ActiveTextEnterArea[] activeText = new ActiveTextEnterArea[string.length]; for (int i = 0; i < string.length; i++) { activeText[i] = new ActiveTextEnterArea (null, event.out (), string[i], 5, 40); } Panel panel = new Panel (new GridLayout (string.length/2, 2)); for (int i = 0; i < string.length; i++) { panel.add (activeText[i].getActiveTextArea ()); } final Frame realFrame = frame.getActiveFrame (); realFrame.setBackground (Color.green); realFrame.add (panel); realFrame.pack (); realFrame.setVisible (true); new Parallel ( new CSProcess[] { frame, new Parallel (activeText), new CSProcess () { public void run () { boolean running = true; while (running) { String s = (String) event.in ().read (); System.out.println (s); running = (! s.equals (goodbye)); } realFrame.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveMenuItemExample.java0000644000000000000000000000464211105664736023446 0ustar import java.awt.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveMenuItemExample { public static void main (String argv[]) { final ActiveClosingFrame activeClosingFrame = new ActiveClosingFrame ("ActiveMenuItem Example"); final ActiveFrame frame = activeClosingFrame.getActiveFrame (); final MenuBar menuBar = new MenuBar (); frame.setMenuBar (menuBar); final Menu fileMenu = new Menu ("File"); final Menu langMenu = new Menu ("Language"); menuBar.add (fileMenu); menuBar.add (langMenu); final String[] fileOptions = {"Hello World", "Rocket Science", "CSP", "Monitors", "Ignore Me", "Goodbye World"}; final String[] langOptions = {"occam-pi", "Java", "Smalltalk", "Algol-60", "Pascal", "Haskell", "SML", "Lisp"}; final Any2OneChannel event[] = Channel.any2oneArray (2, new OverWriteOldestBuffer (10)); final ActiveMenuItem[] fileMenuItem = new ActiveMenuItem[fileOptions.length]; for (int i = 0; i < fileOptions.length; i++) { fileMenuItem[i] = new ActiveMenuItem (null, event[0].out (), fileOptions[i]); fileMenu.add (fileMenuItem[i]); } final ActiveMenuItem[] langMenuItem = new ActiveMenuItem[langOptions.length]; for (int i = 0; i < langOptions.length; i++) { langMenuItem[i] = new ActiveMenuItem (null, event[1].out (), langOptions[i]); langMenu.add (langMenuItem[i]); } frame.setSize (300, 200); frame.setBackground (Color.green); frame.setVisible (true); new Parallel ( new CSProcess[] { activeClosingFrame, new Parallel (fileMenuItem), new Parallel (langMenuItem), new CSProcess () { public void run () { boolean running = true; while (running) { final String s = (String) event[0].in ().read (); System.out.println ("File ==> `" + s + "' selected ..."); running = (s != fileOptions[fileOptions.length - 1]); } frame.setVisible (false); System.exit (0); } }, new CSProcess () { public void run () { while (true) { final String s = (String) event[1].in ().read (); System.out.println ("Language ==> `" + s + "' selected ..."); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveScrollbarExample.java0000644000000000000000000000461311105664736023644 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.util.ints.*; import org.jcsp.awt.*; public class ActiveScrollbarExample { public static void main (String argv[]) { final ActiveClosingFrame activeFrame = new ActiveClosingFrame ("ActiveScrollbar Example"); final One2OneChannel configure = Channel.one2one (); final One2OneChannelInt scrollEvent = Channel.one2oneInt (new OverWriteOldestBufferInt (10)); final ActiveScrollbar scrollBar = new ActiveScrollbar ( configure.in (), scrollEvent.out (), Scrollbar.HORIZONTAL, 0, 10, 0, 110 ); final Frame realFrame = activeFrame.getActiveFrame (); realFrame.setSize (400, 75); realFrame.add (scrollBar); realFrame.setVisible (true); new Parallel ( new CSProcess[] { activeFrame, scrollBar, new CSProcess () { public void run () { final long FREE_TIME = 10000, BUSY_TIME = 250; CSTimer tim = new CSTimer (); Alternative alt = new Alternative (new Guard[] {tim, scrollEvent.in ()}); final int TIM = 0, SCROLL = 1; long timeout = tim.read (); tim.setAlarm (timeout + FREE_TIME); boolean running = true; while (running) { switch (alt.priSelect ()) { case TIM: // timeout happened configure.out ().write (Boolean.FALSE); // disable scrollbar for (int i = 40; i > 0; i--) { System.out.println ("*** busy busy busy ... " + i); timeout = tim.read (); tim.after (timeout + BUSY_TIME); } System.out.println ("*** free free free ... 0"); configure.out ().write (Boolean.TRUE); // enable scrollbar timeout = tim.read (); tim.setAlarm (timeout + FREE_TIME); break; case SCROLL: // scrollEvent happened int position = scrollEvent.in ().read (); System.out.println ("ScrollBar ==> " + position); running = (position != 100); break; } } realFrame.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveButtonControlExample.java0000644000000000000000000001626711105664736024545 0ustar import java.awt.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; public class ActiveButtonControlExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveButtonControl Example"); final String[][] labels = { new String[] {"Hello World", "JCSP", "Restart"}, new String[] {"Rocket Science", "JCSP", "occam"}, new String[] {"Deadlock", "JCSP", "occam"}, new String[] {"Race Hazard", "JCSP", "occam"}, new String[] {"Starvation", "JCSP", "Quit", "Back"}, new String[] {"Threads", "JCSP", "occam"}, new String[] {"Livelock", "JCSP", "occam"}, new String[] {"Monitors", "JCSP", "occam"}, new String[] {"Alchemy", "JCSP", "Smile"} }; final int nButtons = labels.length; final One2OneChannel[] fromButton = Channel.one2oneArray (nButtons, new OverWriteOldestBuffer (1)); final Any2OneChannel[] toButton = Channel.any2oneArray (nButtons); final One2OneChannel report = Channel.one2one (); final ActiveButton[] button = new ActiveButton[nButtons]; for (int i = 0; i < nButtons; i++) { button[i] = new ActiveButton (toButton[i].in (), fromButton[i].out (), "XXXXXXXXX"); button[i].setBackground (Color.green); } root.setSize (450, 200); root.setLayout (new GridLayout (nButtons/3, 3)); for (int i = 0; i < nButtons; i++) { root.add (button[i]); } root.setVisible (true); final int initial = 0; // state names final int diagonal = 1; final int opposite = 2; final int centre = 3; final int full = 4; final int terminal = 5; final String[] stateName = { "initial", "diagonal", "opposite", "centre", "full", "terminal" }; final ActiveButtonState[] state = new ActiveButtonState[stateName.length]; try { state[initial] = new ActiveButtonState ( new int[] { 0, 0, 1, 0, 1, 1, // label index 1, 1, 1 }, new boolean[] { true, true, false, true, false, false, // enable/disable false, false, false }, new int[] { diagonal, initial, initial, initial, initial, initial, // next state initial, initial, initial } ); state[diagonal] = new ActiveButtonState ( new int[] { 1, 1, 0, 1, 0, 1, // label index 0, 1, 1 }, new boolean[] { false, false, true, false, true, false, // enable/disable true, false, false }, new int[] { diagonal, diagonal, centre, diagonal, opposite, diagonal, // next state full, diagonal, diagonal } ); state[opposite] = new ActiveButtonState ( new int[] { 1, 1, 1, 1, 1, 0, // label index 1, 0, 0 }, new boolean[] { false, false, false, false, false, true, // enable/disable false, true, true }, new int[] { opposite, opposite, opposite, opposite, opposite, opposite, // next state opposite, opposite, diagonal } ); state[centre] = new ActiveButtonState ( new int[] { 1, 1, 1, 1, 3, 1, // label index 1, 1, 1 }, new boolean[] { false, false, false, false, true, false, // enable/disable false, false, false }, new int[] { centre, centre, centre, centre, diagonal, centre, // next state centre, centre, centre } ); state[full] = new ActiveButtonState ( new int[] { 2, 2, 2, 2, 2, 2, // label index 2, 2, 2 }, new boolean[] { true, true, true, true, true, true, // enable/disable true, true, true }, new int[] { initial, diagonal, diagonal, diagonal, terminal, diagonal, // next state diagonal, diagonal, opposite } ); state[terminal] = new ActiveButtonState ( new int[] { 1, 1, 1, 1, 1, 1, // label index 1, 1, 1 }, new boolean[] { false, false, false, false, false, false, // enable/disable false, false, false }, new int[] { terminal, terminal, terminal, terminal, terminal, terminal, // next state terminal, terminal, terminal } ); } catch (ActiveButtonState.BadArguments e) { System.out.println (e); System.exit (0); }; new Parallel ( new CSProcess[] { new Parallel (button), new CSProcess () { public void run () { final ActiveButtonControl control; try { control = new ActiveButtonControl ( Channel.getInputArray (fromButton), Channel.getOutputArray (toButton), report.out (), labels, state, initial ); control.setReportButtonIndex (true); control.setReportButtonLabel (true); control.run (); } catch (ActiveButtonControl.BadArguments e) { System.out.println (e); System.exit (0); } } }, new CSProcess () { public void run () { for (int j = 0; j < nButtons; j++) { toButton[j].out ().write (Color.RED); } boolean running = true; while (running) { final int newState = ((Integer) report.in ().read ()).intValue (); final int buttonIndex = ((Integer) report.in ().read ()).intValue (); final String buttonString = (String) report.in ().read (); System.out.println ( "Button " + buttonIndex + " (" + buttonString + ") pressed ==> " + stateName[newState] ); running = (newState != terminal); } final CSTimer tim = new CSTimer (); // countdown to exit final long interval = 1000; // one second long timeout = tim.read (); for (int i = 10; i >= 0; i--) { timeout += interval; tim.after (timeout); final String iString = (new Integer (i)).toString (); for (int j = 0; j < nButtons; j++) { toButton[j].out ().write (iString); } } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveScrollPaneExample.java0000644000000000000000000000353711105664736023767 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.util.*; import org.jcsp.lang.*; import org.jcsp.awt.*; public class ActiveScrollPaneExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveScrollPane Example"); final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10)); final ActiveScrollPane scrollPane = new ActiveScrollPane (); scrollPane.addMouseEventChannel (mouseEvent.out ()); root.add (scrollPane); root.setSize (400, 400); root.setVisible (true); new Parallel ( new CSProcess[] { scrollPane, new CSProcess () { public void run () { boolean running = true; while (running) { final MouseEvent event = (MouseEvent) mouseEvent.in ().read (); switch (event.getID ()) { case MouseEvent.MOUSE_ENTERED: System.out.println ("MOUSE_ENTERED"); break; case MouseEvent.MOUSE_EXITED: System.out.println ("MOUSE_EXITED"); break; case MouseEvent.MOUSE_PRESSED: System.out.println ("MOUSE_PRESSED"); break; case MouseEvent.MOUSE_RELEASED: System.out.println ("MOUSE_RELEASED"); break; case MouseEvent.MOUSE_CLICKED: if (event.getClickCount() > 1) { System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!"); running = false; } else { System.out.println ("MOUSE_CLICKED ... *double* click to quit!"); } break; } } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/FlasherNetworkSSD.java0000644000000000000000000001047211113055740022545 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; public class FlasherNetworkSSD implements CSProcess { final private long period; final private ActiveApplet activeApplet; public FlasherNetworkSSD (final long period, final ActiveApplet activeApplet) { this.period = period; this.activeApplet = activeApplet; } public void run () { final One2OneChannel mouseEvent = Channel.one2one (); final One2OneChannel appletConfigure = Channel.one2one (); final One2OneChannelInt stopStart = Channel.one2oneInt (); final One2OneChannelInt destroy = Channel.one2oneInt (); final One2OneChannelInt destroyAck = Channel.one2oneInt (); activeApplet.addMouseEventChannel (mouseEvent.out()); activeApplet.setConfigureChannel (appletConfigure.in()); activeApplet.setStopStartChannel (stopStart.out()); activeApplet.setDestroyChannels (destroy.out(), destroyAck.in()); // activeApplet.setDestroyChannels (destroy.out(), destroyAck.in(), -1); new Parallel ( new CSProcess[] { activeApplet, new FlasherControl (period, mouseEvent.in(), appletConfigure.out()), new CSProcess () { public void run () { while (true) { switch (stopStart.in().read ()) { case ActiveApplet.STOP: System.out.println ("FlasherNetworkSSD: ActiveApplet.STOP received"); break; case ActiveApplet.START: System.out.println ("FlasherNetworkSSD: ActiveApplet.START received"); break; default: System.out.println ("FlasherNetworkSSD: ActiveApplet. received"); break; } } } }, new CSProcess () { public void run () { while (true) { switch (destroy.in().read ()) { case ActiveApplet.DESTROY: System.out.println ("FlasherNetworkSSD: ActiveApplet.DESTROY received"); destroyAck.out().write (0); break; default: System.out.println ("FlasherNetworkSSD: ActiveApplet. received"); break; } } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveTextAreaExample.java0000644000000000000000000000316611105664736023440 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; public class ActiveTextAreaExample { public static void main (String argv[]) { final ActiveClosingFrame frame = new ActiveClosingFrame ("ActiveTextAreaExample Example"); final Any2OneChannel event = Channel.any2one (new OverWriteOldestBuffer (10)); final String[] string = {"Entia Non Sunt Multiplicanda Praeter Necessitatem", "Everything we do, we do it to you", "Race Hazards - What Rice Hozzers?", "Cogito Ergo Occam"}; final String goodbye = "Goodbye World"; final ActiveTextArea[] activeText = new ActiveTextArea[string.length]; for (int i = 0; i < string.length; i++) { activeText[i] = new ActiveTextArea (null, event.out (), string[i], 5, 40); } Panel panel = new Panel (new GridLayout (string.length/2, 2)); for (int i = 0; i < string.length; i++) { panel.add (activeText[i]); } final Frame realFrame = frame.getActiveFrame (); realFrame.setBackground (Color.green); realFrame.add (panel); realFrame.pack (); realFrame.setVisible (true); new Parallel ( new CSProcess[] { frame, new Parallel (activeText), new CSProcess () { public void run () { boolean running = true; while (running) { String s = (String) event.in ().read (); System.out.println (s); running = (! s.equals (goodbye)); } realFrame.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/awt/ActiveComponentExample.java0000644000000000000000000000352711105664736023666 0ustar import java.awt.*; import java.awt.event.*; import org.jcsp.util.*; import org.jcsp.lang.*; import org.jcsp.awt.*; public class ActiveComponentExample { public static void main (String argv[]) { final Frame root = new Frame ("ActiveComponent Example"); final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10)); final ActiveComponent component = new ActiveComponent (); component.addMouseEventChannel (mouseEvent.out ()); root.add (component); root.setSize (400, 400); root.setVisible (true); new Parallel ( new CSProcess[] { component, new CSProcess () { public void run () { boolean running = true; while (running) { final MouseEvent event = (MouseEvent) mouseEvent.in ().read (); switch (event.getID ()) { case MouseEvent.MOUSE_ENTERED: System.out.println ("MOUSE_ENTERED"); break; case MouseEvent.MOUSE_EXITED: System.out.println ("MOUSE_EXITED"); break; case MouseEvent.MOUSE_PRESSED: System.out.println ("MOUSE_PRESSED"); break; case MouseEvent.MOUSE_RELEASED: System.out.println ("MOUSE_RELEASED"); break; case MouseEvent.MOUSE_CLICKED: if (event.getClickCount() > 1) { System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!"); running = false; } else { System.out.println ("MOUSE_CLICKED ... *double* click to quit!"); } break; } } root.setVisible (false); System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/0000755000000000000000000000000011410045035017542 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/NorExample.java0000644000000000000000000000112511105664736022476 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class NorExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); final One2OneChannel c = Channel.one2one (); final One2OneChannel d = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Generate (b.out (), 0), new Nor (a.in (), b.in (), c.out ()), new Successor (c.in (), d.out ()), new Printer (d.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/FramedScrollbarExample.java0000644000000000000000000000424511105664736025010 0ustar import org.jcsp.lang.*; import org.jcsp.util.ints.*; import org.jcsp.plugNplay.*; public class FramedScrollbarExample { public static void main (String argv[]) { // initial pixel sizes for the scrollbar frame final boolean horizontal = true; final int pixDown = horizontal ? 300 : 400; final int pixAcross = horizontal ? 400 : 300; // the event channel is wired up to the scrollbar & reports all slider movements ... final One2OneChannelInt event = Channel.one2oneInt (new OverWriteOldestBufferInt (10)); // the configure channel is wired up to the scrollbar ... final One2OneChannel configure = Channel.one2one (); // make the framed scrollbar (connecting up its wires) ... final FramedScrollbar scrollbar = new FramedScrollbar ( "FramedScrollbar Demo", pixDown, pixAcross, configure.in (), event.out (), horizontal, 0, 10, 0, 100 ); // testrig ... new Parallel ( new CSProcess[] { scrollbar, new CSProcess () { public void run () { while (true) { final int n = event.in ().read (); System.out.println ("FramedScrollbar ==> " + n); } } }, new CSProcess () { public void run () { final int second = 1000; // time is in millisecs final int enabledTime = 10*second; final int disabledCountdown = 5; final CSTimer tim = new CSTimer (); while (true) { tim.sleep (enabledTime); configure.out ().write (Boolean.FALSE); for (int i = disabledCountdown; i > 0; i--) { System.out.println ("\t\t\t\tScrollbar disabled ... " + i); tim.sleep (second); } configure.out ().write (Boolean.TRUE); System.out.println ("\t\t\t\tScrollbar enabled ..."); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ParaplexExample.java0000644000000000000000000000167111105664736023522 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; class ParaplexExample { public static void main (String[] args) { final One2OneChannel[] a = Channel.one2oneArray (3); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a[0].out ()), new Squares (a[1].out ()), new Fibonacci (a[2].out ()), new Paraplex (Channel.getInputArray (a), b.out ()), new CSProcess () { public void run () { ChannelInput in = b.in (); System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n"); while (true) { Object[] data = (Object[]) in.read (); for (int i = 0; i < data.length; i++) { System.out.print ("\t\t" + data[i]); } System.out.println (); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/Merge2Example.java0000644000000000000000000000161211105664736023062 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; public class Merge2Example { public static void main (String[] argv) { final One2OneChannel[] a = Channel.one2oneArray (4); final One2OneChannel[] b = Channel.one2oneArray (3, new InfiniteBuffer ()); final One2OneChannel c = Channel.one2one (); final One2OneChannel d = Channel.one2one (); final One2OneChannel e = Channel.one2one (); new Parallel ( new CSProcess[] { new Mult (2, a[0].in (), b[0].out ()), new Mult (3, a[1].in (), b[1].out ()), new Mult (5, a[2].in (), b[2].out ()), new Merge2 (b[0].in (), b[1].in (), c.out ()), new Merge2 (c.in (), b[2].in (), d.out ()), new Prefix (1, d.in (), e.out ()), new Delta (e.in (), Channel.getOutputArray (a)), new Printer (a[3].in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/TimesExample.java0000644000000000000000000000077111105664736023027 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class TimesExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Numbers (b.out ()), new Times (a.in (), b.in (), c.out ()), new Printer (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/FramedButtonExample.java0000644000000000000000000000274111105664736024337 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; public class FramedButtonExample { public static void main (String argv[]) { // initial pixel sizes for the button frame final int pixDown = 100; final int pixAcross = 250; // labels for the button final String[] label = {"JCSP", "Rocket Science", "occam-pi", "Goodbye World"}; // the event channel is wired up to the button & reports all button presses ... final One2OneChannel event = Channel.one2one (new OverWriteOldestBuffer (10)); // the configure channel is wired up to the button ... final One2OneChannel configure = Channel.one2one (); // make the framed button (connecting up its wires) ... final FramedButton button = new FramedButton ( "FramedButton Demo", pixDown, pixAcross, configure.in (), event.out () ); // testrig ... new Parallel ( new CSProcess[] { button, new CSProcess () { public void run () { int i = 0; while (true) { configure.out ().write (label[i]); i = (i + 1) % label.length; final String s = (String) event.in ().read (); System.out.println ("Button `" + s + "' pressed ..."); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/FramedButtonGridArrayExample.java0000644000000000000000000000753111105664736026146 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; public class FramedButtonGridArrayExample { public static void main (String argv[]) { // the allEvents channel is wired up to all buttons & reports all button presses ... final Any2OneChannel allEvents = Channel.any2one (new OverWriteOldestBuffer (10)); // labels for the array of buttons final String[] arrayLabel = {"JCSP", "Rocket Science", "CSP", "Goodbye World"}; final int nButtons = arrayLabel.length; // row or column array? final boolean horizontal = false; // initial pixel sizes for the frame for the button array final int arrayPixDown = 20 + (horizontal ? 120 : nButtons*120); final int arrayPixAcross = horizontal ? nButtons*120 : 120; // make the array of buttons (each one separately configured) ... final Any2OneChannel[] arrayEvent = new Any2OneChannel[nButtons]; for (int i = 0; i < nButtons; i++) { arrayEvent[i] = allEvents; } final One2OneChannel[] arrayConfigure = Channel.one2oneArray (nButtons); final FramedButtonArray array = new FramedButtonArray ( "FramedButtonArray Demo", nButtons, arrayPixDown, arrayPixAcross, horizontal, Channel.getInputArray (arrayConfigure), Channel.getOutputArray (arrayEvent) ); // initial pixel sizes for the grid of buttons final int gridPixDown = 200; final int gridPixAcross = 500; // labels for the grid of buttons final String[][] gridLabel = { new String[] {"Java", "occam", "Handel"}, new String[] {"C", "C++", "C#"}, new String[] {"Haskell", "Modula", "Shut Down"} }; final int nDown = gridLabel.length; final int nAcross = gridLabel[0].length; // make the grid of buttons (each one separately configured) ... final Any2OneChannel[][] gridEvent = new Any2OneChannel[nDown][nAcross]; for (int i = 0; i < nDown; i++) { for (int j = 0; j < nAcross; j++) { gridEvent[i][j] = allEvents; } } final One2OneChannel[][] gridConfigure = new One2OneChannel[nDown][nAcross]; for (int i = 0; i < nDown; i++) { gridConfigure[i] = Channel.one2oneArray (nAcross); } final ChannelInput[][] gridConfigureIn = new ChannelInput[nDown][nAcross]; final ChannelOutput[][] gridEventOut = new ChannelOutput[nDown][nAcross]; for (int i = 0; i < nDown; i++) { gridConfigureIn[i] = Channel.getInputArray (gridConfigure[i]); gridEventOut[i] = Channel.getOutputArray (gridEvent[i]); } final FramedButtonGrid grid = new FramedButtonGrid ( "FramedButtonGrid Demo", nDown, nAcross, gridPixDown, gridPixAcross, gridConfigureIn, gridEventOut ); // testrig ... new Parallel ( new CSProcess[] { array, grid, new CSProcess () { public void run () { for (int i = 0; i < nButtons; i++) { arrayConfigure[i].out ().write (arrayLabel[i]); } for (int i = 0; i < nDown; i++) { for (int j = 0; j < nAcross; j++) { gridConfigure[i][j].out ().write (gridLabel[i][j]); } } boolean running = true; while (running) { final String s = (String) allEvents.in ().read (); System.out.println ("Button `" + s + "' pressed ..."); running = ( (s != arrayLabel[nButtons - 1]) && (s != gridLabel[nDown - 1][nAcross - 1]) ); } System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/PlusExample.java0000644000000000000000000000076711105664736022676 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class PlusExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Numbers (b.out ()), new Plus (a.in (), b.in (), c.out ()), new Printer (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/MultExample.java0000644000000000000000000000064111105664736022663 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class MultExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Mult (42, a.in (), b.out ()), new Printer (b.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/Plex2Example.java0000644000000000000000000000125411105664736022735 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class Plex2Example { public static void main (String[] argv) { final One2OneChannel[] a = Channel.one2oneArray (2); final One2OneChannel[] b = Channel.one2oneArray (2); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Fibonacci (a[0].out ()), new Squares (a[1].out ()), new Sign ("Fibonacci ", a[0].in (), b[0].out ()), new Sign (" Squares ", a[1].in (), b[1].out ()), new Plex2 (b[0].in (), b[1].in (), c.out ()), new Printer (c.in (), "", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/DeparaplexExample.java0000644000000000000000000000220711105664736024027 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class DeparaplexExample { public static void main (String[] args) { final One2OneChannel[] a = Channel.one2oneArray (3); final One2OneChannel b = Channel.one2one (); final One2OneChannel[] c = Channel.one2oneArray (3); final One2OneChannel d = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a[0].out ()), new Squares (a[1].out ()), new Fibonacci (a[2].out ()), new Paraplex (Channel.getInputArray (a), b.out ()), new Deparaplex (b.in (), Channel.getOutputArray (c)), new Paraplex (Channel.getInputArray (c), d.out ()), new CSProcess () { public void run () { System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n"); while (true) { Object[] data = (Object[]) d.in ().read (); for (int i = 0; i < data.length; i++) { System.out.print ("\t\t" + data[i]); } System.out.println (); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/0000755000000000000000000000000011410045035020517 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/ParaplexIntExample.java0000644000000000000000000000165211105664736025151 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; class ParaplexIntExample { public static void main (String[] args) { final One2OneChannelInt[] a = Channel.one2oneIntArray (3); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new NumbersInt (a[0].out ()), new SquaresInt (a[1].out ()), new FibonacciInt (a[2].out ()), new ParaplexInt (Channel.getInputArray (a), b.out ()), new CSProcess () { public void run () { System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n"); while (true) { int[] data = (int[]) b.in ().read (); for (int i = 0; i < data.length; i++) { System.out.print ("\t\t" + data[i]); } System.out.println (); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/SuccessorIntExample.java0000644000000000000000000000070411105664736025343 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class SuccessorIntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new SuccessorInt (a.in (), b.out ()), new PrinterInt (b.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/PlusIntExample.java0000644000000000000000000000103511105664736024313 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class PlusIntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); final One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new NumbersInt (b.out ()), new PlusInt (a.in (), b.in (), c.out ()), new PrinterInt (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/XorIntExample.java0000644000000000000000000000103511105664736024140 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class XorIntExample { public static void main (String[] argv) { One2OneChannelInt a = Channel.one2oneInt (); One2OneChannelInt b = Channel.one2oneInt (); One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new GenerateInt (b.out (), Integer.MAX_VALUE), new XorInt (a.in (), b.in (), c.out ()), new PrinterInt (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/SignIntExample.java0000644000000000000000000000154011105664736024271 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; import org.jcsp.plugNplay.*; public class SignIntExample { public static void main (String[] argv) { final One2OneChannelInt[] a = Channel.one2oneIntArray (3); final One2OneChannel[] b = Channel.one2oneArray (3); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new NumbersInt (a[0].out ()), new FibonacciInt (a[1].out ()), new SquaresInt (a[2].out ()), new SignInt ("Numbers ", a[0].in (), b[0].out ()), new SignInt (" Fibonacci ", a[1].in (), b[1].out ()), new SignInt (" Squares ", a[2].in (), b[2].out ()), new Plex (Channel.getInputArray (b), c.out ()), new Printer (c.in (), "", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/AndIntExample.java0000644000000000000000000000106311105664736024073 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class AndIntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); final One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new GenerateInt (b.out (), Integer.MAX_VALUE - 1), new AndInt (a.in (), b.in (), c.out ()), new PrinterInt (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/OrIntExample.java0000644000000000000000000000103511105664736023750 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class OrIntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); final One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new GenerateInt (b.out (), 1), new OrInt (a.in (), b.in (), c.out ()), new PrinterInt (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/NorIntExample.java0000644000000000000000000000120411105664736024124 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class NorIntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); final One2OneChannelInt c = Channel.one2oneInt (); final One2OneChannelInt d = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new GenerateInt (b.out (), 0), new NorInt (a.in (), b.in (), c.out ()), new SuccessorInt (c.in (), d.out ()), new PrinterInt (d.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/NandIntExample.java0000644000000000000000000000123211105664736024247 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class NandIntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); final One2OneChannelInt c = Channel.one2oneInt (); final One2OneChannelInt d = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new GenerateInt (b.out (), Integer.MAX_VALUE - 1), new NandInt (a.in (), b.in (), c.out ()), new SuccessorInt (c.in (), d.out ()), new PrinterInt (d.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/MultiplexIntExample.java0000644000000000000000000000173711105664736025364 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class MultiplexIntExample { public static void main (String[] argv) { final One2OneChannelInt[] a = Channel.one2oneIntArray (3); final One2OneChannelInt b = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a[0].out ()), new FibonacciInt (a[1].out ()), new SquaresInt (a[2].out ()), new MultiplexInt (Channel.getInputArray (a), b.out ()), new CSProcess () { public void run () { String[] key = {"Numbers ", " Fibonacci ", " Squares "}; while (true) { System.out.print (key[b.in ().read ()]); // print channel source System.out.println (b.in ().read ()); // print multiplexed data } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/PlexIntExample.java0000644000000000000000000000107411105664736024303 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class PlexIntExample { public static void main (String[] argv) { final One2OneChannelInt[] a = Channel.one2oneIntArray (3); final One2OneChannelInt b = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a[0].out ()), new FibonacciInt (a[1].out ()), new SquaresInt (a[2].out ()), new PlexInt (Channel.getInputArray (a), b.out ()), new PrinterInt (b.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/TimesIntExample.java0000644000000000000000000000103711105664736024453 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class TimesIntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); final One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new NumbersInt (b.out ()), new TimesInt (a.in (), b.in (), c.out ()), new PrinterInt (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/Merge2IntExample.java0000644000000000000000000000172011105664736024512 0ustar import org.jcsp.lang.*; import org.jcsp.util.ints.*; import org.jcsp.plugNplay.ints.*; public class Merge2IntExample { public static void main (String[] argv) { final One2OneChannelInt[] a = Channel.one2oneIntArray (4); final One2OneChannelInt[] b = Channel.one2oneIntArray (3, new InfiniteBufferInt ()); final One2OneChannelInt c = Channel.one2oneInt (); final One2OneChannelInt d = Channel.one2oneInt (); final One2OneChannelInt e = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new MultInt (2, a[0].in (), b[0].out ()), new MultInt (3, a[1].in (), b[1].out ()), new MultInt (5, a[2].in (), b[2].out ()), new Merge2Int (b[0].in (), b[1].in (), c.out ()), new Merge2Int (c.in (), b[2].in (), d.out ()), new PrefixInt (1, d.in (), e.out ()), new DeltaInt (e.in (), Channel.getOutputArray (a)), new PrinterInt (a[3].in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/MergeIntExample.java0000644000000000000000000000162511105664736024434 0ustar import org.jcsp.lang.*; import org.jcsp.util.ints.*; import org.jcsp.plugNplay.ints.*; public class MergeIntExample { public static void main (String[] argv) { final One2OneChannelInt[] a = Channel.one2oneIntArray (5); final One2OneChannelInt[] b = Channel.one2oneIntArray (4, new InfiniteBufferInt ()); final One2OneChannelInt c = Channel.one2oneInt (); final One2OneChannelInt d = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new MultInt (2, a[0].in (), b[0].out ()), new MultInt (3, a[1].in (), b[1].out ()), new MultInt (5, a[2].in (), b[2].out ()), new MultInt (7, a[3].in (), b[3].out ()), new MergeInt (Channel.getInputArray (b), c.out ()), new PrefixInt (1, c.in (), d.out ()), new DeltaInt (d.in (), Channel.getOutputArray (a)), new PrinterInt (a[4].in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/DeparaplexIntExample.java0000644000000000000000000000224711105664736025463 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class DeparaplexIntExample { public static void main (String[] args) { final One2OneChannelInt[] a = Channel.one2oneIntArray (3); final One2OneChannel b = Channel.one2one (); final One2OneChannelInt[] c = Channel.one2oneIntArray (3); final One2OneChannel d = Channel.one2one (); new Parallel ( new CSProcess[] { new NumbersInt (a[0].out ()), new SquaresInt (a[1].out ()), new FibonacciInt (a[2].out ()), new ParaplexInt (Channel.getInputArray (a), b.out ()), new DeparaplexInt (b.in (), Channel.getOutputArray (c)), new ParaplexInt (Channel.getInputArray (c), d.out ()), new CSProcess () { public void run () { System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n"); while (true) { int[] data = (int[]) d.in ().read (); for (int i = 0; i < data.length; i++) { System.out.print ("\t\t" + data[i]); } System.out.println (); } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/Plex2IntExample.java0000644000000000000000000000107011105664736024361 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class Plex2IntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); final One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new FibonacciInt (a.out ()), new SquaresInt (b.out ()), new Plex2Int (a.in (), b.in (), c.out ()), new PrinterInt (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/MultIntExample.java0000644000000000000000000000067611105664736024323 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class MultIntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a.out ()), new MultInt (42, a.in (), b.out ()), new PrinterInt (b.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/AndExample.java0000644000000000000000000000101511105664736022440 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class AndExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Generate (b.out (), Integer.MAX_VALUE - 1), new And (a.in (), b.in (), c.out ()), new Printer (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/NandExample.java0000644000000000000000000000115311105664736022621 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class NandExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); final One2OneChannel c = Channel.one2one (); final One2OneChannel d = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Generate (b.out (), Integer.MAX_VALUE - 1), new Nand (a.in (), b.in (), c.out ()), new Successor (c.in (), d.out ()), new Printer (d.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/OrExample.java0000644000000000000000000000112311105664736022316 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class OrExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); final One2OneChannel c = Channel.one2one (); final One2OneChannel d = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Generate (b.out (), 1), new Or (a.in (), b.in (), c.out ()), new Successor (c.in (), d.out ()), new Printer (d.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/MultiplexExample.java0000644000000000000000000000207111105664736023724 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class MultiplexExample { public static void main (String[] argv) { final One2OneChannel[] a = Channel.one2oneArray (3); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a[0].out ()), new Fibonacci (a[1].out ()), new Squares (a[2].out ()), new Multiplex (Channel.getInputArray (a), b.out ()), new CSProcess () { public void run () { String[] key = {"Numbers ", " Fibonacci ", " Squares "}; while (true) { int channel = ((Integer) b.in ().read ()).intValue (); System.out.print (key[channel]); // print channel source int n = ((Integer) b.in ().read ()).intValue (); System.out.println (n); // print multiplexed data } } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/PlexExample.java0000644000000000000000000000144211105664736022652 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class PlexExample { public static void main (String[] argv) { final One2OneChannel[] a = Channel.one2oneArray (3); final One2OneChannel[] b = Channel.one2oneArray (3); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a[0].out ()), new Fibonacci (a[1].out ()), new Squares (a[2].out ()), new Sign ("Numbers ", a[0].in (), b[0].out ()), new Sign (" Fibonacci ", a[1].in (), b[1].out ()), new Sign (" Squares ", a[2].in (), b[2].out ()), new Plex (Channel.getInputArray (b), c.out ()), new Printer (c.in (), "", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/MergeExample.java0000644000000000000000000000152511105664736023003 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; public class MergeExample { public static void main (String[] argv) { final One2OneChannel[] a = Channel.one2oneArray (5); final One2OneChannel[] b = Channel.one2oneArray (4, new InfiniteBuffer ()); final One2OneChannel c = Channel.one2one (); final One2OneChannel d = Channel.one2one (); new Parallel ( new CSProcess[] { new Mult (2, a[0].in (), b[0].out ()), new Mult (3, a[1].in (), b[1].out ()), new Mult (5, a[2].in (), b[2].out ()), new Mult (7, a[3].in (), b[3].out ()), new Merge (Channel.getInputArray (b), c.out ()), new Prefix (1, c.in (), d.out ()), new Delta (d.in (), Channel.getOutputArray (a)), new Printer (a[4].in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/FramedButtonGridExample.java0000644000000000000000000000505511105664736025146 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; public class FramedButtonGridExample { public static void main (String argv[]) { // labels for the grid of buttons final String[][] label = { new String[] {"Java", "occam-pi", "Handel-C"}, new String[] {"C", "C++", "C#"}, new String[] {"Haskell", "Modula", "Goodbye World"} }; final int nDown = label.length; final int nAcross = label[0].length; // initial pixel sizes for the frame for the grid of buttons final int pixDown = 20 + (nDown*100); final int pixAcross = nAcross*120; // all button events are wired (for this example) to the same channel ... final Any2OneChannel allEvents = Channel.any2one (new OverWriteOldestBuffer (10)); final Any2OneChannel[][] event = new Any2OneChannel[nDown][nAcross]; for (int i = 0; i < nDown; i++) { for (int j = 0; j < nAcross; j++) { event[i][j] = allEvents; } } // make the grid of buttons (each one separately configured) ... final One2OneChannel[][] configure = new One2OneChannel[nDown][nAcross]; for (int i = 0; i < nDown; i++) { configure[i] = Channel.one2oneArray (nAcross); } final ChannelInput[][] configureIn = new ChannelInput[nDown][nAcross]; final ChannelOutput[][] eventOut = new ChannelOutput[nDown][nAcross]; for (int i = 0; i < nDown; i++) { configureIn[i] = Channel.getInputArray (configure[i]); eventOut[i] = Channel.getOutputArray (event[i]); } final FramedButtonGrid grid = new FramedButtonGrid ( "FramedButtonGrid Demo", nDown, nAcross, pixDown, pixAcross, configureIn, eventOut ); // testrig ... new Parallel ( new CSProcess[] { grid, new CSProcess () { public void run () { for (int i = 0; i < nDown; i++) { for (int j = 0; j < nAcross; j++) { configure[i][j].out ().write (label[i][j]); } } boolean running = true; while (running) { final String s = (String) allEvents.in ().read (); System.out.println ("Button `" + s + "' pressed ..."); running = (s != label[nDown - 1][nAcross - 1]); } System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/SuccessorExample.java0000644000000000000000000000064711105664736023721 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class SuccessorExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Successor (a.in (), b.out ()), new Printer (b.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/SignExample.java0000644000000000000000000000144211105664736022642 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class SignExample { public static void main (String[] argv) { final One2OneChannel[] a = Channel.one2oneArray (3); final One2OneChannel[] b = Channel.one2oneArray (3); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a[0].out ()), new Fibonacci (a[1].out ()), new Squares (a[2].out ()), new Sign ("Numbers ", a[0].in (), b[0].out ()), new Sign (" Fibonacci ", a[1].in (), b[1].out ()), new Sign (" Squares ", a[2].in (), b[2].out ()), new Plex (Channel.getInputArray (b), c.out ()), new Printer (c.in (), "", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/XorExample.java0000644000000000000000000000076711105664736022523 0ustar import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class XorExample { public static void main (String[] argv) { One2OneChannel a = Channel.one2one (); One2OneChannel b = Channel.one2one (); One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Generate (b.out (), Integer.MAX_VALUE), new Xor (a.in (), b.in (), c.out ()), new Printer (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/doc-ex/jcsp/plugNplay/FramedButtonArrayExample.java0000644000000000000000000000405211105664736025333 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; public class FramedButtonArrayExample { public static void main (String argv[]) { // labels for the array of buttons final String[] label = {"JCSP", "Rocket Science", "occam-pi", "Goodbye World"}; final int nButtons = label.length; // row or column? final boolean horizontal = true; // initial pixel sizes for the frame for the button array final int pixDown = 20 + (horizontal ? 120 : nButtons*120); final int pixAcross = horizontal ? nButtons*120 : 120; // all button events are wired (for this example) to the same channel ... final Any2OneChannel allEvents = Channel.any2one (new OverWriteOldestBuffer (10)); final Any2OneChannel[] event = new Any2OneChannel[nButtons]; for (int i = 0; i < nButtons; i++) { event[i] = allEvents; } // each button is given its own configuration channel ... final One2OneChannel[] configure = Channel.one2oneArray (nButtons); // make the array of buttons ... final FramedButtonArray buttons = new FramedButtonArray ( "FramedButtonArray Demo", nButtons, pixDown, pixAcross, horizontal, Channel.getInputArray (configure), Channel.getOutputArray (event) ); // testrig ... new Parallel ( new CSProcess[] { buttons, new CSProcess () { public void run () { for (int i = 0; i < nButtons; i++) { configure[i].out ().write (label[i]); } boolean running = true; while (running) { final String s = (String) allEvents.in ().read (); System.out.println ("Button `" + s + "' pressed ..."); running = (s != label[nButtons - 1]); } System.exit (0); } } } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/eratosthenes/0000755000000000000000000000000011410045036016156 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/eratosthenes/NoMultiples.java0000644000000000000000000000504311111352066021300 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class NoMultiples implements CSProcess { private final int n; private final ChannelInputInt in; private final ChannelOutputInt out; public NoMultiples (final int n, final ChannelInputInt in, final ChannelOutputInt out) { this.n = n; this.in = in; this.out = out; } public void run () { while (true) { int a = in.read (); if ((a%n) != 0) out.write (a); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/eratosthenes/Eratosthenes.java0000644000000000000000000000633311111352066021474 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public class Eratosthenes { public static final String TITLE = "Sieve of Eratosthenes"; public static final String DESCR = "Demonstrates the pipe-line approach to parallelisation, generating prime numbers by sieving. The " + "sieve of Eratosthenes works by a feeder process pushing numbers into a pipeline of sieve processes. " + "Each sieve process is allocated a prime number and discards any numbers in the pipeline divisible " + "by that number. If a number reaches the end of the pipe it must be prime as no factors were found. " + "It is printed and a new sieve process added to the pipeline to carry on searching for higher primes.\n" + "\n" + "This demonstration is a good way of stress testing the system for running a lot of processes."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new Primes (c.out ()), new PrinterInt (c.in (), "--> ", "\n") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/eratosthenes/Sieve.java0000644000000000000000000000511111111352066020074 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Sieve implements CSProcess { private final ChannelInputInt in; private final ChannelOutputInt out; public Sieve (final ChannelInputInt in, final ChannelOutputInt out) { this.in = in; this.out = out; } public void run () { int n = in.read (); out.write (n); One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NoMultiples (n, in, c.out ()), new Sieve (c.in (), out) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/eratosthenes/NumbersFrom.java0000644000000000000000000000506711111352066021272 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class NumbersFrom implements CSProcess { private final int start; private final int increment; private final ChannelOutputInt out; public NumbersFrom (final int start, final int increment, final ChannelOutputInt out) { this.start = start; this.increment = increment; this.out = out; } public void run () { int n = start; while (true) { out.write (n); n += increment; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/eratosthenes/Primes.java0000644000000000000000000000473711111352066020275 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class Primes implements CSProcess { private final ChannelOutputInt out; public Primes (final ChannelOutputInt out) { this.out = out; } public void run () { out.write (2); One2OneChannelInt c = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersFrom (3, 2, c.out ()), new Sieve (c.in (), out) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/0000755000000000000000000000000011410045036014547 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls2/0000755000000000000000000000000011410045036015726 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls2/BallsMain2.java0000644000000000000000000001202711111352066020521 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class BallsMain2 extends ActiveApplet { public static final int minWidth = 300; public static final int maxWidth = 1024; public static final int maxHeight = 768; public static final int minHeight = 100; public static final int minBalls = 1; public static final int maxBalls = 100; public static final int defaultBalls = 10; public static final int minSpeed = 1; public static final int maxSpeed = 100; public static final int defaultSpeed = 20; public static final int minLife = 1; public static final int maxLife = 100; public static final int defaultLife = 20; public void init () { final int nBalls = getAppletInt ("balls", minBalls, maxBalls, defaultBalls); final int speed = getAppletInt ("speed", minSpeed, maxSpeed, defaultSpeed); final int life = getAppletInt ("life", minLife, maxLife, defaultLife); setProcess (new BallsNetwork2 (nBalls, speed, life, this)); } public static final String TITLE = "Bouncing Balls [different update]"; public static final String DESCR = "Shows the use of a DisplayList and the ActiveCanvas when animating a number of objects. Each ball " + "process is given a reference to an information object to be updated. When all balls have updated " + "these objects then a single request is issued by the control process to update the actual canvas. This " + "implementation avoids the need to give the whole DisplayList object to each ball process. This gives " + "a more secure system as the ball processes are then unable to accidentally (or maliciously) alter " + "a display slot not allocated to them."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.addPrompt ("balls", minBalls, maxBalls, defaultBalls); Ask.addPrompt ("speed (movements/second)", minSpeed, maxSpeed, defaultSpeed); Ask.addPrompt ("life (seconds/ball)", minLife, maxLife, defaultLife); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); final int nBalls = Ask.readInt ("balls"); final int speed = Ask.readInt ("speed (movements/second)"); final int life = Ask.readInt ("life (seconds/ball)"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame (TITLE); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final BallsNetwork2 ballsNetwork = new BallsNetwork2 (nBalls, speed, life, activeFrame); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, ballsNetwork } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls2/ns-Balls2.html0000644000000000000000000000306311113065047020357 0ustar JCSP Balls 2

Balls

This applet demonstrates some simple concurrent animation.  Each ball is a process writing to its own slot of a shared display channel (jcsp.awt.DisplayList), whose other end is serviced by a jcsp.awt.ActiveCanvas.  There are no GUI controls, but the number of balls in the display is specified by the applet balls parameter and their speed (movements per second) by speed.  Each ball has its own (random) colour, starting position, size and initial direction vector.

Useful extensions to this applet would be: GUI controls for adjusting temperature (i.e. speed) and displaying pressure (i.e. bounces per second off the walls), changing the size of the containment canvas, zapping existing balls and adding new ones, varying the mass and size of the balls, freezing and resuming the animation, collision detection and bouncing, adding resistance to motion and gravity, ...
 
  jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls2/BallsNetwork2.java0000644000000000000000000001121011111352066021257 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class BallsNetwork2 implements CSProcess { private final ActiveCanvas activeCanvas; private final BallsControl2 control; private final Ball2[] balls; public BallsNetwork2 (final int nBalls, final int speed, final int life, final Container parent) { parent.setLayout (new BorderLayout ()); final DisplayList displayList = new DisplayList (); // displayList.setMinRefreshInterval (40); // System.out.println ("BallsNetwork2: displayList.setMinRefreshInterval (40) ..."); final Barrier barrier = new Barrier (); final Barrier dead = new Barrier (nBalls); final Any2OneChannelInt fromBalls = Channel.any2oneInt (); final One2OneChannel[] toBalls = Channel.one2oneArray (nBalls); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); activeCanvas = new ActiveCanvas (); activeCanvas.setBackground (Color.black); activeCanvas.setPaintable (displayList); activeCanvas.setGraphicsChannels (toGraphics.in (), fromGraphics.out ()); activeCanvas.setSize (parent.getSize ()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. System.out.println ("BallsNetwork2 adding ActiveCanvas to the parent ..."); parent.add ("Center", activeCanvas); final Ball2.Info[] oldInfo = new Ball2.Info[nBalls]; final Ball2.Info[] newInfo = new Ball2.Info[nBalls]; for (int i = 0; i < nBalls; i++) { oldInfo[i] = new Ball2.Info (); newInfo[i] = new Ball2.Info (); } balls = new Ball2[nBalls]; for (int i = 0; i < nBalls; i++) { balls[i] = new Ball2 (i, speed, life, dead, fromBalls.out (), toBalls[i].in (), barrier, oldInfo[i], newInfo[i]); } control = new BallsControl2 (fromBalls.in (), Channel.getOutputArray (toBalls), barrier, toGraphics.out (), fromGraphics.in (), displayList, oldInfo, newInfo, speed); } public void run () { System.out.println ("BallsNetwork starting up ..."); new Parallel ( new CSProcess[] { activeCanvas, new Parallel (balls), control } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls2/Ball2.java0000644000000000000000000001450711111352066017536 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.util.*; import java.awt.*; /** * @author P.H. Welch */ public class Ball2 implements CSProcess { public final static class Info { public Color colour; public int x, y, width, height; public boolean alive; } private final int id; private final int life; private final Barrier dead; private final ChannelOutputInt toControl; private final ChannelInput fromControl; private final Barrier barrier; private Info oldInfo, newInfo; private Random random; public Ball2 (int id, int speed, int life, Barrier dead, ChannelOutputInt toControl, ChannelInput fromControl, Barrier barrier, Info oldInfo, Info newInfo) { this.id = id; this.life = life*speed; this.dead = dead; this.toControl = toControl; this.fromControl = fromControl; this.barrier = barrier; this.oldInfo = oldInfo; this.newInfo = newInfo; } private final int range (int n) { int i = random.nextInt (); if (i < 0) { if (i == Integer.MIN_VALUE) { // guard against minint ! i = 42; } else { i = -i; } } return i % n; } private final int delta (int n) { int i = range ((2*n) + 1) - n; while (i == 0) i = range ((2*n) + 1) - n; return i; } public void run () { // System.out.println ("Ball " + id + " running ..."); final Thread me = Thread.currentThread (); // System.out.println ("Ball " + id + ": priority = " + me.getPriority ()); me.setPriority (Thread.MAX_PRIORITY); // System.out.println ("Ball " + id + ": priority = " + me.getPriority ()); final Dimension graphicsDim = (Dimension) fromControl.read (); final long seed = id + ((Long) fromControl.read ()).longValue (); this.random = new Random (seed); // System.out.println ("Ball " + id + ": " + graphicsDim); // System.out.println ("Ball " + id + ": seed = " + seed); final CSTimer tim = new CSTimer (); final long second = 1000; // JCSP Timer units are milliseconds final long blackout = 5*second; while (true) { // initialise data for new ball ... newInfo.colour = new Color (random.nextInt ()); newInfo.width = range (30) + 10; newInfo.height = range (30) + 10; newInfo.x = range (graphicsDim.width - newInfo.width); newInfo.y = range (graphicsDim.height - newInfo.height); oldInfo.colour = newInfo.colour; oldInfo.width = newInfo.width; oldInfo.height = newInfo.height; int deltaX = delta (10); int deltaY = delta (10); // System.out.println ("Ball " + id + ": initialX,Y = " + newGraphic.x + ", " + newGraphic.y); // System.out.println ("Ball " + id + ": initialW,H = " + newGraphic.width + ", " + newGraphic.height); // System.out.println ("Ball " + id + ": (deltaX, deltaY) = (" + deltaX + ", " + deltaY + ")"); tim.sleep (id*second); // bring the balls up one by one toControl.write (id); // bring our newInfo/oldInfo into sync with control newInfo.alive = true; oldInfo.alive = true; barrier.enroll (); fromControl.read (); // now we are in sync with control // System.out.println ("Ball " + id + ": alive"); int countdown = life; while (countdown > 0) { barrier.sync (); // let control know newInfo is ready ... final Info tmp = oldInfo; oldInfo = newInfo; newInfo = tmp; int x = oldInfo.x + deltaX; if ((x < 0) || ((x + oldInfo.width) > graphicsDim.width)) { deltaX = -deltaX; } int y = oldInfo.y + deltaY; if ((y < 0) || ((y + oldInfo.height) > graphicsDim.height)) { deltaY = -deltaY; } newInfo.x = x; newInfo.y = y; countdown--; } // System.out.println ("Ball " + id + ": dead"); newInfo.alive = false; oldInfo.alive = false; barrier.resign (); // don't need to sync with control for this dead.sync (); // wait for all the other balls to die tim.sleep (blackout); // blackout for 5 seconds ... } } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls2/BallsControl2.java0000644000000000000000000001420011111352066021250 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class BallsControl2 implements CSProcess { private final AltingChannelInputInt fromBalls; private final ChannelOutput[] toBalls; private final Barrier barrier; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; private final DisplayList displayList; private final Ball2.Info[] oldInfo; private final Ball2.Info[] newInfo; private final int speed; public BallsControl2 (final AltingChannelInputInt fromBalls, final ChannelOutput[] toBalls, final Barrier barrier, final ChannelOutput toGraphics, final ChannelInput fromGraphics, final DisplayList displayList, final Ball2.Info[] oldInfo, final Ball2.Info[] newInfo, final int speed) { this.fromBalls = fromBalls; this.toBalls = toBalls; this.barrier = barrier; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; this.displayList = displayList; this.oldInfo = oldInfo; this.newInfo = newInfo; this.speed = speed; } private final static class Graphic implements GraphicsCommand.Graphic { public Dimension graphicsDim; public Ball2.Info[] info; public boolean someAlive = true; public void doGraphic (java.awt.Graphics g, java.awt.Component c) { g.clearRect (0, 0, graphicsDim.width, graphicsDim.height); someAlive = false; for (int i = 0; i < info.length; i++) { final Ball2.Info myInfo = info[i]; if (myInfo.alive) { someAlive = true; g.setColor (myInfo.colour); g.fillOval (myInfo.x, myInfo.y, myInfo.width, myInfo.height); } } } } public void run() { toGraphics.write (GraphicsProtocol.GET_DIMENSION); final Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("BallsControl2: graphics dimension = " + graphicsDim); final CSTimer tim = new CSTimer (); final long seed = tim.read (); barrier.enroll (); // we do this before any of the balls for (int i = 0; i < toBalls.length; i++) { toBalls[i].write (graphicsDim); toBalls[i].write (new Long (seed)); } Graphic oldGraphic = new Graphic (); oldGraphic.graphicsDim = graphicsDim; oldGraphic.info = oldInfo; Graphic newGraphic = new Graphic (); newGraphic.graphicsDim = graphicsDim; newGraphic.info = newInfo; GraphicsCommand oldCommand = new GraphicsCommand.General (oldGraphic); GraphicsCommand newCommand = new GraphicsCommand.General (newGraphic); final long second = 1000; // JCSP Timer units are milliseconds long interval = (int) (((float) second)/((float) speed) + 0.5); System.out.println ("BallsControl1 : interval = " + interval); long timeout; // timeouts will drift ... but never mind ... // long timeout = tim.read (); // timeouts won't drift ... not wanted here ... boolean evenCycle = true; while (true) { timeout = tim.read () + interval; // timeouts will drift ... but never mind ... // timeout += interval; // timeouts won't drift ... not wanted here ... if (evenCycle) { while (fromBalls.pending ()) { int ball = fromBalls.read (); newGraphic.someAlive = true; oldGraphic.someAlive = true; toBalls[ball].write (null); } evenCycle = false; } else { evenCycle = true; } barrier.sync (); // wait for all participating balls // to update their newInfo slots if (newGraphic.someAlive) { displayList.set (newCommand); } final GraphicsCommand tmp = oldCommand; oldCommand = newCommand; newCommand = tmp; tim.after (timeout); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls2/Balls2.html0000644000000000000000000000606111113065047017742 0ustar JCSP Balls 2

Balls

This applet demonstrates some simple concurrent animation.  Each ball is a process writing to its own slot of a shared display channel (jcsp.awt.DisplayList), whose other end is serviced by a jcsp.awt.ActiveCanvas.  There are no GUI controls, but the number of balls in the display is specified by the applet balls parameter and their speed (movements per second) by speed.  Each ball has its own (random) colour, starting position, size and initial direction vector.

Useful extensions to this applet would be: GUI controls for adjusting temperature (i.e. speed) and displaying pressure (i.e. bounces per second off the walls), changing the size of the containment canvas, zapping existing balls and adding new ones, varying the mass and size of the balls, freezing and resuming the animation, collision detection and bouncing, adding resistance to motion and gravity, ...
 
  jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls0/0000755000000000000000000000000011410045036015724 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls0/BallsNetwork0.java0000644000000000000000000001014111111352066021255 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ class BallsNetwork0 implements CSProcess { private final ActiveCanvas activeCanvas; private final BallsControl0 control; private final Ball0[] balls; public BallsNetwork0 (final int nBalls, final int speed, final int life, final Container parent) { parent.setLayout (new BorderLayout ()); final DisplayList displayList = new DisplayList (); // displayList.setMinRefreshInterval (10); // System.out.println ("BallsNetwork: displayList.setMinRefreshInterval (10) ..."); final One2OneChannel[] toBalls = Channel.one2oneArray (nBalls); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); final Barrier dead = new Barrier (nBalls); activeCanvas = new ActiveCanvas (); activeCanvas.setBackground (Color.black); activeCanvas.setPaintable (displayList); activeCanvas.setGraphicsChannels (toGraphics.in(), fromGraphics.out()); activeCanvas.setSize (parent.getSize ()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. System.out.println ("BallsNetwork adding ActiveCanvas to the parent ..."); parent.add ("Center", activeCanvas); balls = new Ball0[nBalls]; for (int i = 0; i < nBalls; i++) { balls[i] = new Ball0 (i, speed, life, dead, toBalls[i].in(), displayList); } control = new BallsControl0 (Channel.getOutputArray(toBalls), displayList, toGraphics.out(), fromGraphics.in()); } public void run () { System.out.println ("BallsNetwork starting up ..."); new Parallel ( new CSProcess[] { activeCanvas, control, new Parallel (balls) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls0/BallsControl0.java0000644000000000000000000001252511113056662021261 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ class BallsControl0 implements CSProcess { private static final int RED_SPEED = 7, GREEN_SPEED = 13, BLUE_SPEED = 19; private final ChannelOutput[] toBalls; private final DisplayList displayList; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; public BallsControl0 (final ChannelOutput[] toBalls, final DisplayList displayList, final ChannelOutput toGraphics, final ChannelInput fromGraphics) { this.toBalls = toBalls; this.displayList = displayList; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; } private final static class Graphic implements GraphicsCommand.Graphic { public Color colour; public void doGraphic (java.awt.Graphics g, java.awt.Component c) { Dimension dim = c.getSize(); g.setColor (colour); g.fillRect (0, 0, dim.width, dim.height); } } Graphic oldGraphic = new Graphic (); Graphic newGraphic = new Graphic (); GraphicsCommand oldCommand = new GraphicsCommand.General (oldGraphic); GraphicsCommand newCommand = new GraphicsCommand.General (newGraphic); public void run() { toGraphics.write (GraphicsProtocol.GET_DIMENSION); final Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("BallsControl: graphics dimension = " + graphicsDim); final CSTimer tim = new CSTimer (); final long seed = tim.read (); // initialise data for background colour ... int colRed = 0, colGreen = 0, colBlue = 0, cvRed = RED_SPEED, cvGreen = GREEN_SPEED, cvBlue = BLUE_SPEED; newGraphic.colour = Color.black; displayList.set (newCommand); for (int i = 0; i < toBalls.length; i++) { toBalls[i].write (graphicsDim); toBalls[i].write (new Long (seed)); } //final Thread me = Thread.currentThread (); //me.setPriority (Thread.MAX_PRIORITY); final long second = 1000; // JCSP Timer units are milliseconds long interval = second / 20; long timeout; // timeouts will drift ... but never mind ... // long timeout = tim.read (); // timeouts won't drift ... not wanted here ... while (true) { timeout = tim.read () + interval; // timeouts will drift ... but never mind ... // timeout += interval; // timeouts won't drift ... not wanted here ... final Graphic tmpA = oldGraphic; oldGraphic = newGraphic; newGraphic = tmpA; final GraphicsCommand tmpB = oldCommand; oldCommand = newCommand; newCommand = tmpB; colRed += cvRed; if (colRed > 255 - RED_SPEED) cvRed = -RED_SPEED; else if (colRed < RED_SPEED) cvRed = RED_SPEED; colGreen += cvGreen; if (colGreen > 255 - GREEN_SPEED) cvGreen = -GREEN_SPEED; else if (colGreen < GREEN_SPEED) cvGreen = GREEN_SPEED; colBlue += cvBlue; if (colBlue > 255 - BLUE_SPEED) cvBlue = -BLUE_SPEED; else if (colBlue < BLUE_SPEED) cvBlue = BLUE_SPEED; newGraphic.colour = new Color (colRed, colGreen, colBlue); tim.after (timeout); displayList.change (newCommand, 0); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls0/Balls0.html0000644000000000000000000000620711113065047017740 0ustar JCSP Balls 0

Balls

This applet demonstrates some simple concurrent animation.  Each ball is a process writing to its own slot of a shared display channel (jcsp.awt.DisplayList), whose other end is serviced by a jcsp.awt.ActiveCanvas.  There are no GUI controls, but the number of balls in the display is specified by the applet balls parameter and their speed (movements per second) by speed.  Each ball has its own (random) colour, starting position, size and initial direction vector.

Useful extensions to this applet would be: GUI controls for adjusting temperature (i.e. speed) and displaying pressure (i.e. bounces per second off the walls), changing the size of the containment canvas, zapping existing balls and adding new ones, varying the mass and size of the balls, freezing and resuming the animation, collision detection and bouncing, adding resistance to motion and gravity, ...
 
  jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls0/ns-Balls0.html0000644000000000000000000000313111113065047020347 0ustar JCSP Balls 0

Balls

This applet demonstrates some simple concurrent animation.  Each ball is a process writing to its own slot of a shared display channel (jcsp.awt.DisplayList), whose other end is serviced by a jcsp.awt.ActiveCanvas.  There are no GUI controls, but the number of balls in the display is specified by the applet balls parameter and their speed (movements per second) by speed.  Each ball has its own (random) colour, starting position, size and initial direction vector.

Useful extensions to this applet would be: GUI controls for adjusting temperature (i.e. speed) and displaying pressure (i.e. bounces per second off the walls), changing the size of the containment canvas, zapping existing balls and adding new ones, varying the mass and size of the balls, freezing and resuming the animation, collision detection and bouncing, adding resistance to motion and gravity, ...
 
  jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls0/Ball0.java0000644000000000000000000001623311111352066017530 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.util.*; import java.awt.*; /** * @author P.H. Welch */ class Ball0 implements CSProcess { private final int id; private final int speed; private final int life; private final Barrier dead; private final ChannelInput fromControl; private final DisplayList displayList; private Random random; public Ball0 (int id, int speed, int life, Barrier dead, ChannelInput fromControl, DisplayList displayList) { this.id = id; this.speed = speed; this.life = life*speed; this.dead = dead; this.fromControl = fromControl; this.displayList = displayList; } private final static class Graphic implements GraphicsCommand.Graphic { public Color colour; public int x, y, width, height; public void doGraphic (java.awt.Graphics g, java.awt.Component c) { g.setColor (colour); g.fillOval (x, y, width, height); } } /** * returns a random integer in the range [0, n - 1] */ private final int range (int n) { int i = random.nextInt (); if (i < 0) { if (i == Integer.MIN_VALUE) { // guard against minint ! i = 42; } else { i = -i; } } return i % n; } /** * returns a random integer in the range [-n, n] excluding 0 */ private final int delta (int n) { int i = range (2*n) - n; if (i == 0) i = n; return i; } public void run () { // System.out.println ("Ball " + id + " running ..."); final Dimension graphicsDim = (Dimension) fromControl.read (); final long seed = id + ((Long) fromControl.read ()).longValue (); this.random = new Random (seed); // System.out.println ("Ball " + id + ": " + graphicsDim); // System.out.println ("Ball " + id + ": seed = " + seed); final int displaySlot = displayList.extend (GraphicsCommand.NULL); // System.out.println ("Ball " + id + ": displaySlot = " + displaySlot); Graphic oldGraphic = new Graphic (); Graphic newGraphic = new Graphic (); GraphicsCommand oldCommand = new GraphicsCommand.General (oldGraphic); GraphicsCommand newCommand = new GraphicsCommand.General (newGraphic); final CSTimer tim = new CSTimer (); final Thread me = Thread.currentThread (); // System.out.println ("Ball " + id + ": priority = " + me.getPriority ()); me.setPriority (Thread.MAX_PRIORITY); // System.out.println ("Ball " + id + ": priority = " + me.getPriority ()); final long second = 1000; // JCSP Timer units are milliseconds long interval = (long) (((float) second)/((float) speed) + 0.5); // System.out.println ("Ball " + id + ": interval = " + interval); final long blackout = 5*second; while (true) { // initialise data for new ball ... newGraphic.colour = new Color (random.nextInt ()); newGraphic.width = range (30) + 10; newGraphic.height = range (30) + 10; newGraphic.x = range (graphicsDim.width - newGraphic.width); newGraphic.y = range (graphicsDim.height - newGraphic.height); oldGraphic.colour = newGraphic.colour; oldGraphic.width = newGraphic.width; oldGraphic.height = newGraphic.height; int deltaX = delta (10); int deltaY = delta (10); // System.out.println ("Ball " + id + ": initialX,Y = " + newGraphic.x + ", " + newGraphic.y); // System.out.println ("Ball " + id + ": initialW,H = " + newGraphic.width + ", " + newGraphic.height); // System.out.println ("Ball " + id + ": (deltaX, deltaY) = (" + deltaX + ", " + deltaY + ")"); tim.sleep (id*second); // bring the balls up one by one // System.out.println ("Ball " + id + ": alive"); int countdown = life; long timeout; // timeouts will drift ... but never mind ... // long timeout = tim.read (); // timeouts won't drift ... not wanted here ... while (countdown > 0) { timeout = tim.read () + interval; // timeouts will drift ... but never mind ... // timeout += interval; // timeouts won't drift ... not wanted here ... displayList.change (newCommand, displaySlot); final Graphic tmpA = oldGraphic; oldGraphic = newGraphic; newGraphic = tmpA; final GraphicsCommand tmpB = oldCommand; oldCommand = newCommand; newCommand = tmpB; int x = oldGraphic.x + deltaX; if ((x < 0) || ((x + oldGraphic.width) > graphicsDim.width)) { deltaX = -deltaX; } int y = oldGraphic.y + deltaY; if ((y < 0) || ((y + oldGraphic.height) > graphicsDim.height)) { deltaY = -deltaY; } newGraphic.x = x; newGraphic.y = y; countdown--; tim.after (timeout); } // System.out.println ("Ball " + id + ": dead"); displayList.change (GraphicsCommand.NULL, displaySlot); dead.sync (); // wait for all the other balls to die tim.sleep (blackout); // blackout for 5 seconds ... } } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls0/BallsMain0.java0000644000000000000000000001162011111352066020513 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class BallsMain0 extends ActiveApplet { public static final int minWidth = 300; public static final int maxWidth = 1024; public static final int maxHeight = 768; public static final int minHeight = 100; public static final int minBalls = 1; public static final int maxBalls = 100; public static final int defaultBalls = 10; public static final int minSpeed = 1; public static final int maxSpeed = 100; public static final int defaultSpeed = 20; public static final int minLife = 1; public static final int maxLife = 100; public static final int defaultLife = 20; public void init () { final int nBalls = getAppletInt ("balls", minBalls, maxBalls, defaultBalls); final int speed = getAppletInt ("speed", minSpeed, maxSpeed, defaultSpeed); final int life = getAppletInt ("life", minLife, maxLife, defaultLife); setProcess (new BallsNetwork0 (nBalls, speed, life, this)); } public static final String TITLE = "Bouncing Balls"; public static final String DESCR = "Shows the use of a DisplayList and the ActiveCanvas when animating a number of objects. The " + "component colour is faded and a number of processes are started for the balls. Each ball process " + "is allocated a slot in the display list and can update the graphics command at that slot. The use of " + "the DisplayList allows each ball to have a logical layer and so pass neatly over/underneath one " + "another in a visually consistent fashion."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.addPrompt ("balls", minBalls, maxBalls, defaultBalls); Ask.addPrompt ("speed (movements/second)", minSpeed, maxSpeed, defaultSpeed); Ask.addPrompt ("life (seconds/ball)", minLife, maxLife, defaultLife); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); final int nBalls = Ask.readInt ("balls"); final int speed = Ask.readInt ("speed (movements/second)"); final int life = Ask.readInt ("life (seconds/ball)"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame (TITLE); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final BallsNetwork0 ballsNetwork = new BallsNetwork0 (nBalls, speed, life, activeFrame); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, ballsNetwork } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls1/0000755000000000000000000000000011410045036015725 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls1/ns-Balls1.html0000644000000000000000000000306311113065047020355 0ustar JCSP Balls 1

Balls

This applet demonstrates some simple concurrent animation.  Each ball is a process writing to its own slot of a shared display channel (jcsp.awt.DisplayList), whose other end is serviced by a jcsp.awt.ActiveCanvas.  There are no GUI controls, but the number of balls in the display is specified by the applet balls parameter and their speed (movements per second) by speed.  Each ball has its own (random) colour, starting position, size and initial direction vector.

Useful extensions to this applet would be: GUI controls for adjusting temperature (i.e. speed) and displaying pressure (i.e. bounces per second off the walls), changing the size of the containment canvas, zapping existing balls and adding new ones, varying the mass and size of the balls, freezing and resuming the animation, collision detection and bouncing, adding resistance to motion and gravity, ...
 
  jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls1/Balls1.html0000644000000000000000000000606111113065047017740 0ustar JCSP Balls 1

Balls

This applet demonstrates some simple concurrent animation.  Each ball is a process writing to its own slot of a shared display channel (jcsp.awt.DisplayList), whose other end is serviced by a jcsp.awt.ActiveCanvas.  There are no GUI controls, but the number of balls in the display is specified by the applet balls parameter and their speed (movements per second) by speed.  Each ball has its own (random) colour, starting position, size and initial direction vector.

Useful extensions to this applet would be: GUI controls for adjusting temperature (i.e. speed) and displaying pressure (i.e. bounces per second off the walls), changing the size of the containment canvas, zapping existing balls and adding new ones, varying the mass and size of the balls, freezing and resuming the animation, collision detection and bouncing, adding resistance to motion and gravity, ...
 
  jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls1/BallsMain1.java0000644000000000000000000001127011111352066020516 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class BallsMain1 extends ActiveApplet { public static final int minWidth = 300; public static final int maxWidth = 1024; public static final int maxHeight = 768; public static final int minHeight = 100; public static final int minBalls = 1; public static final int maxBalls = 100; public static final int defaultBalls = 10; public static final int minSpeed = 1; public static final int maxSpeed = 100; public static final int defaultSpeed = 20; public static final int minLife = 1; public static final int maxLife = 100; public static final int defaultLife = 20; public void init () { final int nBalls = getAppletInt ("balls", minBalls, maxBalls, defaultBalls); final int speed = getAppletInt ("speed", minSpeed, maxSpeed, defaultSpeed); final int life = getAppletInt ("life", minLife, maxLife, defaultLife); setProcess (new BallsNetwork1 (nBalls, speed, life, this)); } public static final String TITLE = "Bouncing Balls [static background]"; public static final String DESCR = "Shows the use of a DisplayList and the ActiveCanvas when animating a number of objects. This is " + "the same as the main Bouncing Balls demonstration but without the control process changing the " + "background colour."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.addPrompt ("balls", minBalls, maxBalls, defaultBalls); Ask.addPrompt ("speed (movements/second)", minSpeed, maxSpeed, defaultSpeed); Ask.addPrompt ("life (seconds/ball)", minLife, maxLife, defaultLife); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); final int nBalls = Ask.readInt ("balls"); final int speed = Ask.readInt ("speed (movements/second)"); final int life = Ask.readInt ("life (seconds/ball)"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame (TITLE); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final BallsNetwork1 ballsNetwork = new BallsNetwork1 (nBalls, speed, life, activeFrame); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, ballsNetwork } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls1/Ball1.java0000644000000000000000000001535111111352066017532 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.util.*; import java.awt.*; /** * @author P.H. Welch */ public class Ball1 implements CSProcess { private final int id; private final int life; private final Barrier dead; private final ChannelInput fromControl; private final DisplayList displayList; private final Barrier barrier; private Random random; public Ball1 (int id, int speed, int life, Barrier dead, ChannelInput fromControl, DisplayList displayList, Barrier barrier) { this.id = id; this.life = life*speed; this.dead = dead; this.fromControl = fromControl; this.displayList = displayList; this.barrier = barrier; } private final static class Graphic implements GraphicsCommand.Graphic { public Color colour; public int x, y, width, height; public void doGraphic (java.awt.Graphics g, java.awt.Component c) { g.setColor (colour); g.fillOval (x, y, width, height); } } /** * returns a random integer in the range [0, n - 1] */ private final int range (int n) { int i = random.nextInt (); if (i < 0) { if (i == Integer.MIN_VALUE) { // guard against minint ! i = 42; } else { i = -i; } } return i % n; } /** * returns a random integer in the range [-n, n] excluding 0 */ private final int delta (int n) { int i = range (2*n) - n; if (i == 0) i = n; return i; } public void run () { // System.out.println ("Ball " + id + " running ..."); final Dimension graphicsDim = (Dimension) fromControl.read (); final long seed = id + ((Long) fromControl.read ()).longValue (); this.random = new Random (seed); // System.out.println ("Ball " + id + ": " + graphicsDim); // System.out.println ("Ball " + id + ": seed = " + seed); final int displaySlot = displayList.extend (GraphicsCommand.NULL); // System.out.println ("Ball " + id + ": displaySlot = " + displaySlot); Graphic oldGraphic = new Graphic (); Graphic newGraphic = new Graphic (); GraphicsCommand oldCommand = new GraphicsCommand.General (oldGraphic); GraphicsCommand newCommand = new GraphicsCommand.General (newGraphic); final CSTimer tim = new CSTimer (); final long second = 1000; // JCSP Timer units are milliseconds final long blackout = 5*second; final Thread me = Thread.currentThread (); // System.out.println ("Ball " + id + ": priority = " + me.getPriority ()); me.setPriority (Thread.MAX_PRIORITY); // System.out.println ("Ball " + id + ": priority = " + me.getPriority ()); while (true) { // initialise data for new ball ... newGraphic.colour = new Color (random.nextInt ()); newGraphic.width = range (30) + 10; newGraphic.height = range (30) + 10; newGraphic.x = range (graphicsDim.width - newGraphic.width); newGraphic.y = range (graphicsDim.height - newGraphic.height); oldGraphic.colour = newGraphic.colour; oldGraphic.width = newGraphic.width; oldGraphic.height = newGraphic.height; int deltaX = delta (10); int deltaY = delta (10); // System.out.println ("Ball " + id + ": initialX,Y = " + newGraphic.x + ", " + newGraphic.y); // System.out.println ("Ball " + id + ": initialW,H = " + newGraphic.width + ", " + newGraphic.height); // System.out.println ("Ball " + id + ": (deltaX, deltaY) = (" + deltaX + ", " + deltaY + ")"); tim.sleep (id*second); // bring the balls up one by one barrier.enroll (); // System.out.println ("Ball " + id + ": alive"); int countdown = life; while (countdown > 0) { barrier.sync (); displayList.change (newCommand, displaySlot); final Graphic tmpA = oldGraphic; oldGraphic = newGraphic; newGraphic = tmpA; final GraphicsCommand tmpB = oldCommand; oldCommand = newCommand; newCommand = tmpB; int x = oldGraphic.x + deltaX; if ((x < 0) || ((x + oldGraphic.width) > graphicsDim.width)) { deltaX = -deltaX; } int y = oldGraphic.y + deltaY; if ((y < 0) || ((y + oldGraphic.height) > graphicsDim.height)) { deltaY = -deltaY; } newGraphic.x = x; newGraphic.y = y; countdown--; } // System.out.println ("Ball " + id + ": dead"); displayList.change (GraphicsCommand.NULL, displaySlot); barrier.resign (); dead.sync (); // wait for all the other balls to die tim.sleep (blackout); // blackout for 5 seconds ... } } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls1/BallsControl1.java0000644000000000000000000001037311111352066021255 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class BallsControl1 implements CSProcess { private final ChannelOutput[] toBalls; private final Barrier barrier; private final DisplayList displayList; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; private final int speed; public BallsControl1 (final ChannelOutput[] toBalls, final Barrier barrier, final DisplayList displayList, final ChannelOutput toGraphics, final ChannelInput fromGraphics, final int speed) { this.toBalls = toBalls; this.barrier = barrier; this.displayList = displayList; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; this.speed = speed; } public void run() { toGraphics.write (GraphicsProtocol.GET_DIMENSION); final Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("BallsControl: graphics dimension = " + graphicsDim); final GraphicsCommand baseCommand = new GraphicsCommand.ClearRect (0, 0, graphicsDim.width, graphicsDim.height); displayList.set (baseCommand); final CSTimer tim = new CSTimer (); final long seed = tim.read (); barrier.enroll (); // we do this before any of the balls for (int i = 0; i < toBalls.length; i++) { toBalls[i].write (graphicsDim); toBalls[i].write (new Long (seed)); } final long second = 1000; // JCSP Timer units are milliseconds long interval = (int) (((float) second)/((float) speed) + 0.5); System.out.println ("BallsControl1 : interval = " + interval); long timeout; // timeouts will drift ... but never mind ... // long timeout = tim.read (); // timeouts won't drift ... not wanted here ... while (true) { timeout = tim.read () + interval; // timeouts will drift ... but never mind ... // timeout += interval; // timeouts won't drift ... not wanted here ... barrier.sync (); tim.after (timeout); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/balls/balls1/BallsNetwork1.java0000644000000000000000000001032611111352066021264 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class BallsNetwork1 implements CSProcess { private final ActiveCanvas activeCanvas; private final BallsControl1 control; private final Ball1[] balls; public BallsNetwork1 (final int nBalls, final int speed, final int life, final Container parent) { parent.setLayout (new BorderLayout ()); final DisplayList displayList = new DisplayList (); // displayList.setMinRefreshInterval (10); // System.out.println ("BallsNetwork: displayList.setMinRefreshInterval (10) ..."); final Barrier barrier = new Barrier (); final Barrier dead = new Barrier (nBalls); final One2OneChannel[] toBalls = Channel.one2oneArray (nBalls); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); activeCanvas = new ActiveCanvas (); activeCanvas.setBackground (Color.black); activeCanvas.setPaintable (displayList); activeCanvas.setGraphicsChannels (toGraphics.in (), fromGraphics.out ()); activeCanvas.setSize (parent.getSize ()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. System.out.println ("BallsNetwork adding ActiveCanvas to the parent ..."); parent.add ("Center", activeCanvas); balls = new Ball1[nBalls]; for (int i = 0; i < nBalls; i++) { balls[i] = new Ball1 (i, speed, life, dead, toBalls[i].in (), displayList, barrier); } control = new BallsControl1 (Channel.getOutputArray (toBalls), barrier, displayList, toGraphics.out (), fromGraphics.in (), speed); } public void run () { System.out.println ("BallsNetwork starting up ..."); new Parallel ( new CSProcess[] { activeCanvas, new Parallel (balls), control } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/hamming/0000755000000000000000000000000011410045035015071 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/hamming/Hamming2.java0000644000000000000000000000731711111352066017411 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.demos.util.*; /** * @author P.H. Welch */ public final class Hamming2 { public static final String TITLE = "Hamming Codes"; public static final String DESCR = "Uses an interesting network of processes to generate all positive integers with given sets of prime factors."; public static final long SECONDS = 1000; public static final long PAUSE = 5*SECONDS; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.show (); Ask.blank (); CSTimer tim = new CSTimer (); final One2OneChannelInt trap = Channel.one2oneInt (); final int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}; Parallel.setUncaughtErrorDisplay (false); while (true) { for (int i = 2; i <= primes.length; i++) { System.out.println ("\nAll positive ints whose prime factors contain only:\n"); System.out.print (" " + primes[0]); for (int j = 1; j < i; j++) { System.out.print (", "); System.out.print (primes[j]); } System.out.println ("\n"); System.out.println ("Pausing 5 seconds ..."); tim.sleep (PAUSE); System.out.println (); final ProcessManager manager = new ProcessManager (new PrimeMultiples2 (primes, i, trap.out ())); manager.start (); // start up the managed process final int count = trap.in ().read (); // wait for hamming numbers to overflow manager.interrupt (); // crude kill of the managed process System.out.println ("\n\nThere were " + count + " of them ..."); } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/hamming/TrapNegative.java0000644000000000000000000000520211111352066020327 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ public final class TrapNegative implements CSProcess { private final ChannelInputInt in; private final ChannelOutputInt out; private final ChannelOutputInt trap; public TrapNegative (final ChannelInputInt in, final ChannelOutputInt out, final ChannelOutputInt trap) { this.in = in; this.out = out; this.trap = trap; } public void run () { int count = 0; int i = in.read (); while (i >= 0) { count++; out.write (i); i = in.read (); } trap.write (count); } } jcsp-1.1-rc4.orig/src/jcsp-demos/hamming/PrimeMultiples2.java0000644000000000000000000000730311111352066020777 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.ints.*; import org.jcsp.plugNplay.ints.*; /** * @author P.H. Welch */ public final class PrimeMultiples2 implements CSProcess { private final ChannelOutputInt trap; private final int[] primes; private final int minPrimes = 2; private final int howMany; public PrimeMultiples2 (final int[] primes, final int howMany, final ChannelOutputInt trap) { // assume these are distinct primes (and at least minPrimes of them) this.primes = primes; if (howMany < minPrimes) { this.howMany = minPrimes; } else if (howMany > primes.length) { this.howMany = primes.length; } else { this.howMany = howMany; } this.trap = trap; } public void run () { final One2OneChannelInt[] a = Channel.one2oneIntArray (howMany + 1); final One2OneChannelInt[] b = Channel.one2oneIntArray (howMany, new InfiniteBufferInt ()); final One2OneChannelInt c = Channel.one2oneInt (); final One2OneChannelInt d = Channel.one2oneInt (); final One2OneChannelInt e = Channel.one2oneInt (); final CSProcess[] Multipliers = new CSProcess[howMany]; for (int i = 0; i < howMany; i++) { Multipliers[i] = new MultInt (primes[i], a[i].in (), b[i].out ()); } new Parallel ( new CSProcess[] { new Parallel (Multipliers), new MergeInt (Channel.getInputArray (b), c.out ()), new PrefixInt (1, c.in (), d.out ()), new DeltaInt (d.in (), Channel.getOutputArray (a)), new TrapNegative (a[howMany].in (), e.out (), trap), new PrinterInt (e.in (), "", " ") } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/net2/0000755000000000000000000000000011410045042014317 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/net2/README.txt0000644000000000000000000000011611111352066016020 0ustar These demos need package org.jcsp.net2, which is not in the main release yet. jcsp-1.1-rc4.orig/src/jcsp-demos/net2/async/0000755000000000000000000000000011410045042015434 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/net2/async/AsynchronousChannels.java0000644000000000000000000000272411111352066022460 0ustar import org.jcsp.net2.JCSPNetworkException; import org.jcsp.net2.NetAltingChannelInput; import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.Node; import org.jcsp.net2.tcpip.TCPIPNodeAddress; /** * This program highlights the usage of async messages, as well as locally connected channels * * @author Kevin Chalmers */ public class AsynchronousChannels { public static void main(String[] args) { // Initialise the Node. We are listening on port 4000 Node.getInstance().init(new TCPIPNodeAddress(4000)); // Now create a channel numbered 100 NetAltingChannelInput in = NetChannel.numberedNet2One(100); // Now connect an output end to this input end NetChannelOutput out = NetChannel.one2net(Node.getInstance().getNodeID(), 100); // Now send 100 integers asynchronously to the local input end for (int i = 0; i < 100; i++) out.asyncWrite(new Integer(i)); // Now read them all back while (in.pending()) { System.out.println(in.read()); } // All messages read. Destroy the input end. in.destroy(); // Now attempt an output. Should fail try { out.write(new Object()); } catch (JCSPNetworkException jne) { System.out.println("The local input end was destroyed"); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/net2/barriers/0000755000000000000000000000000011410045042016130 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/net2/barriers/NetBarrierTestProcess.java0000644000000000000000000000114211111352066023232 0ustar /** * */ import org.jcsp.lang.Barrier; import org.jcsp.lang.CSProcess; /** * @author Kevin */ public class NetBarrierTestProcess implements CSProcess { private final Barrier toSync; int n; public NetBarrierTestProcess(Barrier bar, int procNum) { this.toSync = bar; this.n = procNum; } public void run() { while (true) { System.out.println("Process " + this.n + " syncing"); this.toSync.sync(); System.out.println("Process " + this.n + " released"); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/net2/barriers/LocalBarrier.java0000644000000000000000000000274511111352066021351 0ustar import java.util.Random; import org.jcsp.lang.ProcessManager; import org.jcsp.net2.NetBarrier; import org.jcsp.net2.NetBarrierEnd; import org.jcsp.net2.Node; import org.jcsp.net2.tcpip.TCPIPNodeAddress; /** * This program creates a local NetBarrier with two processes syncing upon it * * @author Kevin */ public class LocalBarrier { public static void main(String[] args) { // Initialise the Node Node.getInstance().init(new TCPIPNodeAddress()); // Create a new NetBarrier server end, index 100. 1 locally enrolled process, 1 remote NetBarrier server = NetBarrierEnd.numberedNetBarrier(100, 1, 1); // Now start up the Server process new ProcessManager(new NetBarrierTestProcess(server, 1)).start(); // Now enroll with the NetBarrier NetBarrier client = NetBarrierEnd.netBarrier(Node.getInstance().getNodeID(), 100, 1); // Randomly sync with the Barrier Random rand = new Random(); while (true) { try { // Wait randomly upto 5 seconds Thread.sleep(Math.abs(rand.nextLong() % 5000)); System.out.println("Syncing client end..."); client.sync(); System.out.println("Client end synced..."); } catch (InterruptedException ie) { // Do nothing. Shouldn't happen } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/net2/channels/0000755000000000000000000000000011410045042016112 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/net2/channels/Sender.java0000644000000000000000000000202411111352066020200 0ustar import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelOutput; import org.jcsp.net2.Node; import org.jcsp.net2.tcpip.TCPIPNodeAddress; /** * This program is the sending end (i.e. client) of a simple networked Producer-Consumer program. This program shows how * to create a numbered channel connection without going through the CNS * * @author Kevin Chalmers */ public class Sender { public static void main(String[] args) { // First we need to initialise the Node. Start listening process on port 5000 of this machine Node.getInstance().init(new TCPIPNodeAddress(5000)); // We now need to create a channel to the receiver process. It is listening on port 4000 on this machine, and is // using channel 100 NetChannelOutput out = NetChannel.one2net(new TCPIPNodeAddress(4000), 100); // Now send Integers for ever int i = 0; while (true) { out.write(new Integer(i)); i++; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/net2/channels/Receiver.java0000644000000000000000000000134511111352066020531 0ustar import org.jcsp.net2.NetChannel; import org.jcsp.net2.NetChannelInput; import org.jcsp.net2.Node; import org.jcsp.net2.tcpip.TCPIPNodeAddress; /** * This is the receiver process of the Producer-Consumer program. Run this program first * * @author Kevin Chalmers */ public class Receiver { public static void main(String[] args) { // Initialise the Node. We are listening on port 4000 Node.getInstance().init(new TCPIPNodeAddress(4000)); // Now create a channel numbered 100 NetChannelInput in = NetChannel.numberedNet2One(100); // Loop forever, printing our input while (true) { System.out.println(in.read()); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/0000755000000000000000000000000011410045036015251 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/DrawingSettings.java0000644000000000000000000000656011111352066021241 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.awt.*; /** * @author Quickstone Technologies Limited */ public class DrawingSettings { private Color fillColor; private Color lineColor; private int strokeSize; private boolean filled; private int tool; private WhiteboardDataBundle currentDrawOp; private boolean isDrawing; private boolean textActive; public DrawingSettings(Color lc, Color fc, boolean f, int s, int t) { fillColor = fc; lineColor = lc; strokeSize = s; filled = f; tool = t; } public Color getLineColor() { return lineColor; } public Color getFillColor() { return fillColor; } public boolean isFilled() { return filled; } public int getStroke() { return strokeSize; } public int getTool() { return tool; } public void setLineColor(Color c) { lineColor = c; } public void setFillColor(Color c) { fillColor = c; } public void setFilled(boolean b) { filled = b; } public void setStrokeSize(int i) { strokeSize = i; } public void setTool(int i) { tool = i; if (i != DrawingPanel.TEXT) { this.setTextActive(false); } } public boolean isDrawing() { return isDrawing; } public boolean textActive() { return textActive; } public void setTextActive(boolean b) { textActive = b; } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ChatFrame.java0000644000000000000000000000714611111352066017760 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * @author Quickstone Technologies Limited */ public class ChatFrame extends JFrame { private JTextField nameField = new JTextField(); private JTextArea chatArea = new JTextArea(); private JTextField messageField = new JTextField(); public ChatFrame() { //layout and init components Container contentPane = this.getContentPane(); Box vbox1 = Box.createVerticalBox(); Box hbox1 = Box.createHorizontalBox(); //vbox1.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); vbox1.add(hbox1); hbox1.add(new JLabel("Username:")); hbox1.add(Box.createHorizontalStrut(2)); hbox1.add(nameField); hbox1.add(Box.createGlue()); hbox1.add(Box.createHorizontalStrut(2)); vbox1.add(Box.createVerticalStrut(8)); vbox1.add(chatArea); chatArea.setPreferredSize(new Dimension(400,400)); chatArea.setEditable(false); chatArea.setBorder(BorderFactory.createLoweredBevelBorder()); vbox1.add(Box.createVerticalStrut(8)); vbox1.add(messageField); messageField.setPreferredSize(new Dimension(400,40)); messageField.setBorder(BorderFactory.createLoweredBevelBorder()); contentPane.add(vbox1); } protected void processWindowEvent(WindowEvent e) { if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public JTextField getNameTextField() { return nameField; } public JTextField getMessageTextField() { return messageField; } public JTextArea getChatTextArea() { return chatArea; } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ChatPlusClientMain.java0000644000000000000000000001364011111352066021611 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.awt.*; import javax.swing.*; import org.jcsp.lang.*; import java.util.*; import org.jcsp.net.*; import org.jcsp.net.tcpip.*; import org.jcsp.net.cns.*; /** * @author Quickstone Technologies Limited */ public class ChatPlusClientMain { private boolean cnsConnected = false; public ChatPlusClientMain() { } public static void main(String[] args) { ConnectDialog cd = new ConnectDialog(); String cnsName = cd.getCNSName(); try { Node.getInstance().init(new TCPIPNodeFactory(cnsName)); } catch (Exception e) { System.out.println("Error - could not connect to server: " + e); System.exit(-1); } String channelName = cd.getChannelName(); String username = cd.getUsername(); String connectName = channelName + ".client2serverconnect"; //setup channels ChannelOutput messageOutChan; NetChannelOutput connectChan = CNS.createOne2Net(connectName); NetChannelInput messageInChan = NetChannelEnd.createNet2One(); NetChannelOutput serverOutChan = NetChannelEnd.createOne2Net(messageInChan.getChannelLocation()); One2OneChannel sorter2WhiteboardChan = Channel.one2one(); One2OneChannel sorter2ChatChan = Channel.one2one(); Any2OneChannel output2BufferChan = Channel.any2one(); DrawingSettings ds = new DrawingSettings(Color.blue, Color.orange, true, 3, 1); ChatPlusFrame cpf = new ChatPlusFrame(ds); One2OneChannel buffer2IdChan = Channel.one2one(); One2OneChannelInt id2BufferChan = Channel.one2oneInt(); One2OneChannelInt localRedrawNotifyChan = Channel.one2oneInt(); connectChan.write(new ConnectionBundle(username, serverOutChan, true)); Object o = messageInChan.read(); messageOutChan = null; if (o instanceof NetChannelLocation) { messageOutChan = NetChannelEnd.createAny2Net((NetChannelLocation) o); } else { Boolean b = (Boolean) o; if (b.booleanValue()) { System.out.println("client: received confirm"); } else { JOptionPane.showMessageDialog( new JFrame(), "The username " + username + " is already in use.\n" + "Please try a different name"); System.exit(0); } } Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); cpf.setSize(d.width, d.height / 2); cpf.setVisible(true); cpf.initComponents(); cpf.validate(); ArrayList al = new ArrayList(2); al.add( new MessageObject( username, username + " connected.\n", MessageObject.CONNECT)); messageOutChan.write(al); CSProcess wsp = new WhiteboardSendProcess( ds, cpf.getWhiteboard(), cpf.getWipeButton(), cpf.getWhiteboardScrollPane(), cpf.getToolMenu(), cpf, output2BufferChan.out(), localRedrawNotifyChan.in(), username, connectChan, serverOutChan); new Parallel( new CSProcess[] { new SorterProcess( messageInChan, sorter2WhiteboardChan.out(), sorter2ChatChan.out()), new JTextFieldProcessPlus( cpf.getMessageArea(), output2BufferChan.out(), username), new MessageReceiverProcess( username, sorter2ChatChan.in(), cpf.getUserArea(), cpf.getChatLog()), new CoalescingBuffer( output2BufferChan.in(), buffer2IdChan.out(), id2BufferChan.in()), new ReadyReportingIdentity( buffer2IdChan.in(), messageOutChan, id2BufferChan.out()), wsp, new WhiteboardReceiveProcess( cpf.getWhiteboard(), sorter2WhiteboardChan.in(), localRedrawNotifyChan.out(), username)}) .run(); } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/DrawingPanel.java0000644000000000000000000001055311111352066020475 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.*; import java.awt.image.*; /** * @author Quickstone Technologies Limited */ public class DrawingPanel extends JPanel { public static final int whiteboardWidth = 1024; public static final int whiteboardHeight = 768; final static int FREEHAND = 1; final static int LINE = 2; final static int RECTANGLE = 3; final static int ROUND_RECTANGLE = 4; final static int OVAL = 5; final static int TEXT = 6; final static int WIPE = 999; final static Font TEXTFONT = new Font("SansSerif", Font.PLAIN, 16); int oldX,oldY,newX,newY; int tool = FREEHAND; boolean graphicsObjectInitialized = false; Rectangle oldRect = new Rectangle(0,0,whiteboardWidth,whiteboardHeight); boolean textActive = false; boolean filled = true; String textInput = ""; BufferedImage buffer = new BufferedImage(whiteboardWidth,whiteboardHeight,BufferedImage.TYPE_3BYTE_BGR); Graphics2D bg = buffer.createGraphics(); int strokeType = 3; Point startDrag = null; public DrawingPanel () { bg.setColor(Color.white); bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); bg.fillRect(0,0,buffer.getWidth(),buffer.getHeight()); bg.setFont(TEXTFONT); } public boolean isFocusable() { // used to override: isFocusTraversable() return true; } public Rectangle clearOldShape (Rectangle rect, Rectangle newRect) { this.getGraphics().drawImage(buffer.getSubimage(rect.x,rect.y,rect.width,rect.height),rect.x,rect.y,this); return (Rectangle)newRect.createIntersection(new Rectangle(0,0,whiteboardWidth,whiteboardHeight)); } public int getCurrentTool() { return tool; } public Point getStartDrag() { return startDrag; } public boolean isFilled() { return filled; } public String getTextInput() { return textInput; } public void finishTextInput() { textActive = false; textInput= ""; } public Point getOldPoint() { return new Point(oldX,oldY); } public int getStroke() { return strokeType; } public boolean isTextActive() { return textActive; } public BufferedImage getBufferedImage() { return buffer; } public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(buffer,0,0,this); } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ConnectionBundle.java0000644000000000000000000000537211111352066021356 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.io.*; /** * @author Quickstone Technologies Limited */ public class ConnectionBundle implements Serializable { private ChannelOutput returnChan; private String user; private boolean connect; public ConnectionBundle(String user, ChannelOutput returnChan, boolean connect) { this.user = user; this.returnChan = returnChan; this.connect = connect; } public ConnectionBundle(String user, boolean connect) { this.user = user; this.connect = connect; this.returnChan = null; } public ChannelOutput getReturnChan() { return returnChan; } public String getUser() { return user; } public boolean connect() { return connect; } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/JTextFieldProcess.java0000644000000000000000000000605411111352066021464 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import javax.swing.event.*; import org.jcsp.lang.*; import java.awt.event.*; /** * @author Quickstone Technologies Limited */ public class JTextFieldProcess implements CSProcess { private ChannelOutput out; private JTextField jtf; private ChannelInput namein; public JTextFieldProcess(JTextField field, ChannelOutput chan, boolean needsConfirm) { jtf = field; out = chan; if (needsConfirm) { jtf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JTextFieldProcess.this.out.write(jtf.getText()); jtf.setText(""); } }); } else { jtf.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate (DocumentEvent e) { JTextFieldProcess.this.out.write(jtf.getText()); } public void removeUpdate (DocumentEvent e) {} }); } } public void run() { } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/JTextAreaReceiverProcess.java0000644000000000000000000000567511111352066023006 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import org.jcsp.lang.*; /** * @author Quickstone Technologies Limited */ public class JTextAreaReceiverProcess implements CSProcess { private JTextArea jta; private ChannelInput in; public JTextAreaReceiverProcess(JTextArea jta, ChannelInput in) { this.jta = jta; this.in = in; } public void run() { while (true) { final String messageText = (String)in.read(); final JTextArea temparea = jta; Runnable r = new Runnable() { public void run() { try { String s = temparea.getText(); if (s != null) { s = s + messageText; } else { s = messageText; } temparea.setText(s); } catch (Exception e) { System.out.println(e); } } }; SwingUtilities.invokeLater(r); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/WhiteboardSendProcess.java0000644000000000000000000003167111111352066022367 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; import java.awt.*; import java.awt.image.*; import org.jcsp.lang.*; /** * @author Quickstone Technologies Limited */ public class WhiteboardSendProcess implements CSProcess { private DrawingPanel dp; private DrawingSettings ds; private ChannelOutput out; private ChannelOutput lpbk; private int oldX,oldY,newX,newY,sx,ex,sy,ey; private Point startDrag; private String user; private Point endDrag; private Rectangle oldRect = new Rectangle(0,0,DrawingPanel.whiteboardWidth,DrawingPanel.whiteboardHeight); private String textInput = ""; private Runnable runner; private Graphics2D dg; private Graphics2D bg; private JButton wipeButton; private BufferedImage bi; private JScrollPane scrollPane; private boolean filled = true; private boolean localDrawActive = false; private ChannelInputInt in; private JComboBox toolMenu; private JFrame chatPlusFrame; private ChannelOutput connectChan; private ChannelOutput serverOutChan; public WhiteboardSendProcess(DrawingSettings ds, DrawingPanel panel, JButton wipeButton, JScrollPane scrollPane, JComboBox toolMenu, JFrame chatPlusFrame,ChannelOutput output, ChannelInputInt in, String user, ChannelOutput connectChan, ChannelOutput serverOutChan) { this.in = in; this.user = user; this.ds = ds; this.serverOutChan = serverOutChan; this.connectChan = connectChan; this.chatPlusFrame = chatPlusFrame; this.toolMenu = toolMenu; this.scrollPane = scrollPane; dp = panel; bi = dp.getBufferedImage(); this.wipeButton = wipeButton; out = output; dg = (Graphics2D)dp.getGraphics(); dg.setFont(DrawingPanel.TEXTFONT); this.addListeners(); } private void drawLocalShapes() { sx = startDrag.x; sy = startDrag.y; ex = newX; ey = newY; if (ex < sx) { ex = startDrag.x; sx = newX; } if (ey < sy) { ey = startDrag.y; sy = newY; } final Rectangle newRect = new Rectangle(sx-10,sy-10,ex-sx+20,ey-sy+20); dg = (Graphics2D)dp.getGraphics(); bg = (Graphics2D)bi.createGraphics(); bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); Runnable runner = new Runnable() { public void run() { } }; switch (ds.getTool()) { case DrawingPanel.OVAL: runner = new Runnable() { public void run() { oldRect = dp.clearOldShape(oldRect,newRect); dg.setColor(ds.getLineColor()); dg.setStroke(WhiteboardReceiveProcess.strokes[ds.getStroke()-1]); dg.drawOval(sx,sy,ex-sx,ey-sy); } }; break; case DrawingPanel.ROUND_RECTANGLE: runner = new Runnable() { public void run() { oldRect = dp.clearOldShape(oldRect,newRect); int edgeRadius = (Math.min(ex-sx,ey-sy))/10; dg.setColor(ds.getLineColor()); dg.setStroke(WhiteboardReceiveProcess.strokes[ds.getStroke()-1]); dg.drawRoundRect(sx,sy,ex-sx,ey-sy,edgeRadius,edgeRadius); } }; break; case DrawingPanel.LINE: runner = new Runnable() { public void run() { oldRect = dp.clearOldShape(oldRect,newRect); dg.setColor(ds.getLineColor()); dg.setStroke(WhiteboardReceiveProcess.strokes[ds.getStroke()-1]); dg.drawLine(startDrag.x,startDrag.y,newX,newY); } }; break; case DrawingPanel.RECTANGLE: runner = new Runnable() { public void run() { oldRect = dp.clearOldShape(oldRect,newRect); dg.setColor(ds.getLineColor()); dg.setStroke(WhiteboardReceiveProcess.strokes[ds.getStroke()-1]); dg.drawRect(sx,sy,ex-sx,ey-sy); } }; break; } SwingUtilities.invokeLater(runner); } private void drawLocalText() { SwingUtilities.invokeLater(new Runnable () { public void run() { dp.paintImmediately(new Rectangle(oldX-20,oldY-20,dg.getFontMetrics().stringWidth(textInput)+40, dg.getFontMetrics().getHeight()+40)); dg = (Graphics2D)dp.getGraphics(); dg.setFont(DrawingPanel.TEXTFONT); dg.setColor(ds.getLineColor()); dg.drawString(textInput+"|",oldX,oldY); } }); } private void addListeners() { chatPlusFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { connectChan.write(new ConnectionBundle(user,false)); out.write(new MessageObject(user,user + " DISCONNECTED\n",MessageObject.DISCONNECT)); System.exit(0); } }); toolMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ds.setTool(toolMenu.getSelectedIndex()+1); if (ds.getTool() != DrawingPanel.TEXT) { ds.setTextActive(false); textInput = ""; } dp.repaint(); } }); scrollPane.getViewport().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ds.textActive()) { dg = (Graphics2D)dp.getGraphics(); WhiteboardSendProcess.this.drawLocalText(); } } }); MouseHandler mh = new MouseHandler(); dp.addHierarchyBoundsListener(new HierarchyBoundsAdapter() { public void ancestorResized(HierarchyEvent e) { dg = (Graphics2D)dp.getGraphics(); } }); wipeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { out.write(new WhiteboardDataBundle(DrawingPanel.WIPE)); } }); dp.addMouseListener(mh); dp.addMouseMotionListener(mh); dp.addKeyListener(new KeyAdapter() { boolean dontType = false; public void keyTyped(KeyEvent e) { if (ds.getTool() == DrawingPanel.TEXT && ds.textActive()) { if (dontType) { dontType = false; } else if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { textInput = textInput+e.getKeyChar(); WhiteboardSendProcess.this.drawLocalText(); } } } public void keyPressed(KeyEvent e) { if (ds.getTool() == DrawingPanel.TEXT && ds.textActive()) { if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { if (textInput.length() > 0) { textInput = textInput.substring(0,textInput.length()-1); } WhiteboardSendProcess.this.drawLocalText(); dontType = true; } if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { ds.setTextActive(false); textInput = ""; dp.paintImmediately(new Rectangle(oldX-20,oldY-20,dg.getFontMetrics().stringWidth(textInput+" ")+40, dg.getFontMetrics().getHeight()+40)); } if (e.getKeyCode() == KeyEvent.VK_ENTER) { out.write(new WhiteboardDataBundle(WhiteboardSendProcess.this.user,DrawingPanel.TEXT,new Rectangle(WhiteboardSendProcess.this.startDrag.x,WhiteboardSendProcess.this.startDrag.y,1,1),ds.getLineColor(),textInput)); ds.setTextActive(false); textInput = ""; } } } }); } public void run() { while (true) { in.read(); if (ds.textActive()) { this.drawLocalText(); } if (localDrawActive) { this.drawLocalShapes(); } } } public Rectangle calcRect(Point start, Point end) { int sx = start.x; int sy = start.y; int ex = end.x; int ey = end.y; if (ex < sx) { ex = start.x; sx = end.x; } if (ey < sy) { ey = start.y; sy = end.y; } return new Rectangle(sx,sy,ex-sx,ey-sy); } private class MouseHandler extends MouseAdapter implements MouseMotionListener { public void mouseMoved (MouseEvent e) {} public void mouseReleased (MouseEvent e) { localDrawActive = false; endDrag = e.getPoint(); switch (ds.getTool()) { case DrawingPanel.FREEHAND: break; case DrawingPanel.LINE: out.write(new WhiteboardDataBundle(user, ds.getTool(),ds.getLineColor(),ds.getStroke(),new Point(startDrag.x,startDrag.y), new Point(endDrag.x,endDrag.y))); break; case DrawingPanel.TEXT: break; default: Rectangle rect = WhiteboardSendProcess.this.calcRect(startDrag,endDrag); out.write(new WhiteboardDataBundle(user, ds.getTool(),rect,ds.isFilled(),ds.getLineColor(), ds.getFillColor(),ds.getStroke())); } } public void mousePressed(MouseEvent e) { dp.requestFocus(); if (!ds.textActive()) { oldX = e.getX(); oldY = e.getY(); newX = e.getX(); newY = e.getY(); startDrag = e.getPoint(); switch (ds.getTool()) { case DrawingPanel.TEXT: ds.setTextActive(true); dp.paintImmediately(0,0,DrawingPanel.whiteboardWidth,DrawingPanel.whiteboardHeight); dg.drawString(textInput+"|",oldX,oldY); break; case DrawingPanel.FREEHAND: bg = (Graphics2D)bi.createGraphics(); bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); bg.setColor(ds.getLineColor()); bg.setStroke(WhiteboardReceiveProcess.strokes[ds.getStroke()-1]); bg.drawLine(oldX,oldY,newX,newY); dp.paintImmediately(Math.min(oldX,newX)-10,Math.min(oldY,newY)-10,Math.abs(oldX-newX)+20,Math.abs(oldY-newY)+20); out.write(new WhiteboardDataBundle(user,ds.getTool(),ds.getLineColor(),ds.getStroke(),new Point (oldX, oldY),new Point(newX,newY))); } } } public void mouseDragged(MouseEvent e) { if (!ds.textActive()) { oldX = newX; oldY = newY; newX = e.getX(); newY = e.getY(); switch (ds.getTool()) { case DrawingPanel.TEXT: break; case DrawingPanel.FREEHAND: bg.setColor(ds.getLineColor()); bg.setStroke(WhiteboardReceiveProcess.strokes[ds.getStroke()-1]); bg.drawLine(oldX,oldY,newX,newY); dp.paintImmediately(Math.min(oldX,newX)-10,Math.min(oldY,newY)-10,Math.abs(oldX-newX)+20,Math.abs(oldY-newY)+20); //System.out.println("sending freehand info: " + oldX + ", " + oldY + " - " + newX + ", " + newY); out.write(new WhiteboardDataBundle(user,ds.getTool(),ds.getLineColor(),ds.getStroke(),new Point (oldX, oldY),new Point(newX,newY))); break; default: WhiteboardSendProcess.this.drawLocalShapes(); break; } localDrawActive = true; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/CoalescingBuffer.java0000644000000000000000000000735711111352066021333 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.util.*; /** * @author Quickstone Technologies Limited */ public class CoalescingBuffer implements CSProcess { private ChannelOutput dataOut; private Guard[] inputArray; private ArrayList daList = new ArrayList(); private int i; public CoalescingBuffer(AltingChannelInput dataIn, ChannelOutput dataOut,AltingChannelInputInt readyIn) { inputArray = new Guard[] {readyIn, dataIn}; this.dataOut = dataOut; } public void run() { final Alternative alt = new Alternative(inputArray); boolean ready = false; while (true) { switch(alt.fairSelect()) { case 0: //System.out.println("buffer: chose report chan"); i = ((AltingChannelInputInt)inputArray[0]).read(); if (daList.size() > 0) { //System.out.println("buffer: stuff to send immediately - sending"); daList.trimToSize(); //System.out.println("buffer: list trimmed to " + daList.size()); dataOut.write(daList); //System.out.println("buffer: sent data"); daList = new ArrayList(); } else { ready = true; } break; case 1: //System.out.println("buffer: chose message chan"); Object o = ((AltingChannelInput)inputArray[1]).read(); //System.out.println("buffer: received data - adding to list"); daList.add(o); if (ready) { //System.out.println("buffer: ready - sending"); daList.trimToSize(); dataOut.write(daList); daList = new ArrayList(); ready = false; } break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/WhiteboardReceiveProcess.java0000644000000000000000000002010111111352066023042 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.*; import org.jcsp.lang.*; /** * @author Quickstone Technologies Limited */ public class WhiteboardReceiveProcess implements CSProcess { private DrawingPanel dp; private ChannelInput in; private Graphics2D bg; public static final BasicStroke[] strokes = new BasicStroke[] {new BasicStroke(1,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND),new BasicStroke(2,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND),new BasicStroke(3,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND),new BasicStroke(4,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND),new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)}; private String user; private ChannelOutputInt out; private WhiteboardDataBundle bun; public WhiteboardReceiveProcess(DrawingPanel panel, ChannelInput input, ChannelOutputInt out, String user) { dp = panel; this.user = user; this.out = out; in = input; bg = dp.getBufferedImage().createGraphics(); bg.setColor(Color.white); bg.fillRect(0,0,dp.getBufferedImage().getWidth(),dp.getBufferedImage().getHeight()); bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); bg.setFont(DrawingPanel.TEXTFONT); } public void run() { while (true) { bun = (WhiteboardDataBundle)in.read(); Runnable runner = new Runnable() { public void run() { } }; //System.out.println("bun " + x + " = " + bun); switch (bun.getTool()) { case DrawingPanel.WIPE: runner = new Runnable() { public void run() { bg.setColor(Color.white); bg.fillRect(0,0,DrawingPanel.whiteboardWidth,DrawingPanel.whiteboardHeight); dp.repaint(); } }; break; case DrawingPanel.FREEHAND: //System.out.println("drawing freehand"); if (!(bun.getUser().equals(user))) { runner = new Runnable() { private Color lc = bun.getLineColor(); private int s = bun.getStroke()-1; private Point p1 = bun.getP1(); private Point p2 = bun.getP2(); public void run () { bg.setColor(lc); bg.setStroke(strokes[s]); bg.drawLine(p1.x,p1.y,p2.x,p2.y); dp.paintImmediately(Math.min(p1.x,p2.x)-10,Math.min(p1.y,p2.y)-10,Math.abs(p1.x - p2.x)+20,Math.abs(p1.y - p2.y)+20); } }; } break; case DrawingPanel.LINE: runner = new Runnable() { private Color lc = bun.getLineColor(); private int s = bun.getStroke()-1; private Point p1 = bun.getP1(); private Point p2 = bun.getP2(); public void run () { bg.setColor(lc); bg.setStroke(strokes[s]); bg.drawLine(p1.x,p1.y,p2.x,p2.y); dp.paintImmediately(Math.min(p1.x,p2.x)-10,Math.min(p1.y,p2.y)-10,Math.abs(p1.x - p2.x)+20,Math.abs(p1.y - p2.y)+20); } }; break; case DrawingPanel.OVAL: runner = new Runnable() { private boolean isFilled = bun.isFilled(); private Color fc = bun.getFillColor(); private Rectangle rect = bun.getRect(); private Color lc = bun.getLineColor(); private int s = bun.getStroke()-1; public void run () { if (isFilled) { bg.setColor(fc); bg.fillOval(rect.x,rect.y,rect.width,rect.height); } bg.setColor(lc); bg.setStroke(strokes[s]); bg.drawOval(rect.x,rect.y,rect.width,rect.height); dp.paintImmediately(rect.x - 10, rect.y - 10, rect.width+20, rect.height+20); } }; break; case DrawingPanel.RECTANGLE: runner = new Runnable() { private boolean isFilled = bun.isFilled(); private Color fc = bun.getFillColor(); private Rectangle rect = bun.getRect(); private Color lc = bun.getLineColor(); private int s = bun.getStroke()-1; public void run () { if (isFilled) { bg.setColor(fc); bg.fillRect(rect.x,rect.y,rect.width,rect.height); } bg.setColor(lc); bg.setStroke(strokes[s]); bg.drawRect(rect.x,rect.y,rect.width,rect.height); dp.paintImmediately(rect.x - 10, rect.y - 10, rect.width+20, rect.height+20); } }; break; case DrawingPanel.ROUND_RECTANGLE: runner = new Runnable() { private boolean isFilled = bun.isFilled(); private Color fc = bun.getFillColor(); private Rectangle rect = bun.getRect(); private Color lc = bun.getLineColor(); private int s = bun.getStroke()-1; public void run () { int edgeRadius = (Math.min(rect.width,rect.height))/10; if (isFilled) { bg.setColor(fc); bg.fillRoundRect(rect.x,rect.y,rect.width,rect.height,edgeRadius,edgeRadius); } bg.setColor(lc); bg.setStroke(strokes[s]); bg.drawRoundRect(rect.x,rect.y,rect.width,rect.height,edgeRadius,edgeRadius); dp.paintImmediately(rect.x - 10, rect.y - 10, rect.width+20, rect.height+20); } }; break; case DrawingPanel.TEXT: runner = new Runnable() { private Color lc = bun.getLineColor(); private String text = bun.getText(); private Rectangle rect = bun.getRect(); public void run() { bg.setColor(lc); bg.drawString(text,rect.x,rect.y); dp.repaint(); } }; } SwingUtilities.invokeLater(runner); out.write(0); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/WhiteboardDataBundle.java0000644000000000000000000000772611111352066022146 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.awt.*; import java.io.*; /** * @author Quickstone Technologies Limited */ public class WhiteboardDataBundle implements Serializable { private int tool; private String user = ""; private Rectangle rect = null; private boolean filled = false; private String text = ""; private Color lineColor = null; private Color fillColor = null; private Object[] freehandArray = null; private int stroke = 1; private Point p1; private Point p2; //shape constructor public WhiteboardDataBundle(String user,int tool, Rectangle rect, boolean filled, Color lineColor, Color fillColor, int stroke) { this.tool = tool; this.rect = rect; this.filled = filled; this.lineColor = lineColor; this.fillColor = fillColor; this.stroke = stroke; this.user = user; } //line constructor public WhiteboardDataBundle(String user,int tool, Color lineColor,int stroke, Point p1, Point p2) { this.tool = tool; this.user = user; this.lineColor = lineColor; this.stroke = stroke; this.p1 = p1; this.p2 = p2; } //text constructor public WhiteboardDataBundle(String user,int tool, Rectangle rect, Color lineColor, String text) { this.tool = tool; this.user = user; this.rect = rect; this.lineColor = lineColor; this.text = text; } //wipe constructor public WhiteboardDataBundle(int tool) { this.tool = tool; } public int getTool() { return tool; } public int getStroke() { return stroke; } public String getUser() { return user; } public Rectangle getRect() { return rect; } public Point getP1() { return p1; } public Point getP2() { return p2; } public Color getLineColor() { return lineColor; } public Color getFillColor() { return fillColor; } public String getText() { return text; } public boolean isFilled() { return filled; } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ChatPlusServerMain.java0000644000000000000000000001244211111352066021640 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.net.*; import java.net.*; import javax.swing.*; import java.awt.event.*; import java.awt.*; import org.jcsp.net.tcpip.*; import org.jcsp.net.cns.*; /** * @author Quickstone Technologies Limited */ public class ChatPlusServerMain { private static final String connectChannelNameExt = ".client2serverconnect"; private static final String messageChannelNameExt = ".client2servermessage"; private static final String whiteboardChannelNameExt = ".client2serverwhiteboard"; public static void main(String[] args) throws java.io.IOException { ServerSetupDialog ssd = new ServerSetupDialog(); //dialog is modal so this doesn't execute until it is closed String chatChanName = ssd.getChannelName(); NodeKey key; if (!(Node.getInstance().isInitialized())) { try { key = Node.getInstance().init( new TCPIPNodeFactory(InetAddress.getLocalHost().getHostAddress())); } catch (NodeInitFailedException e) { try { key = Node.getInstance().init( new TCPIPAddressID( InetAddress.getLocalHost().getHostAddress(), TCPIPCNSServer.DEFAULT_CNS_PORT, true)); CNS.install(key); NodeAddressID cnsAddress = Node.getInstance().getNodeID().getAddresses()[0]; CNSService.install(key, cnsAddress); } catch (NodeInitFailedException e2) { Node.err.log("Node failed to initialize."); System.exit(-1); } } } JFrame serverFrame = new JFrame(); String s = "Chat channel \"" + chatChanName + "\" running on " + Node.getInstance().getNodeID(); JButton exitButton = new JButton("Exit"); Box vbox = Box.createVerticalBox(); serverFrame.getContentPane().add(vbox); JLabel label = new JLabel(s); label.setHorizontalAlignment(SwingConstants.CENTER); label.setAlignmentX(0.5F); exitButton.setAlignmentX(0.5F); vbox.add(label); vbox.add(Box.createVerticalStrut(10)); vbox.add(exitButton); exitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); serverFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); serverFrame.pack(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension td = serverFrame.getSize(); serverFrame.setBounds( (d.width - td.width) / 2, (d.height - td.height) / 2, td.width, td.height); serverFrame.setVisible(true); String connectChannelName = chatChanName + connectChannelNameExt; NetAltingChannelInput connectIn = CNS.createNet2One(connectChannelName); One2OneChannel connectAuth2dd = Channel.one2one(); NetAltingChannelInput messageChan = NetChannelEnd.createNet2One(); new Parallel( new CSProcess[] { new CustomDynamicDelta(messageChan, connectAuth2dd.in()), new ConnectionAuthenticator( connectIn, connectAuth2dd.out(), messageChan)}) .run(); } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/OutPlex.java0000644000000000000000000000577411111352066017533 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author Quickstone Technologies Limited */ public class OutPlex implements CSProcess { private AltingChannelInput usernameIn; private AltingChannelInput messageIn; private ChannelOutput out; private String username = "Anon"; public OutPlex(AltingChannelInput usernameIn, AltingChannelInput messageIn, ChannelOutput out) { this.usernameIn = usernameIn; this.messageIn = messageIn; this.out = out; } public void run() { final AltingChannelInput[] altChans = { usernameIn, messageIn}; final Alternative alt = new Alternative (altChans); String output; while (true) { switch (alt.select()) { case 0: username = (String)usernameIn.read(); break; case 1: output = username + ": " + (String)messageIn.read() + "\n"; // System.out.println("OutPlex: sending message = " + output); out.write(output); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/JTextFieldProcessPlus.java0000644000000000000000000000676211111352066022336 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import javax.swing.event.*; import org.jcsp.lang.*; import java.awt.event.*; /** * @author Quickstone Technologies Limited */ public class JTextFieldProcessPlus implements CSProcess { private ChannelOutput out; private JTextField jtf; private String user; public JTextFieldProcessPlus(JTextField field, ChannelOutput chan, String username) { jtf = field; out = chan; user = username; jtf.setText("Type your message here"); jtf.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { JTextFieldProcessPlus.this.out.write(new MessageObject(user,jtf.getText()+"\n")); jtf.setText(""); } } }); jtf.addFocusListener(new FocusAdapter() { boolean initialMessage = true; public void focusGained(FocusEvent e) { if (initialMessage) { jtf.setText(""); initialMessage=false; } } }); jtf.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate (DocumentEvent e) { JTextFieldProcessPlus.this.out.write(new MessageObject(user,jtf.getText())); } public void removeUpdate (DocumentEvent e) { JTextFieldProcessPlus.this.out.write(new MessageObject(user,jtf.getText())); } }); } public void run() { } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ConnectDialog.java0000644000000000000000000001102311111352066020624 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * @author Quickstone Technologies Limited */ public class ConnectDialog extends JDialog { private JTextField cnsTextField = new JTextField("",30); private JTextField channelTextField = new JTextField("JCSPChatChannel", 30); private JTextField usernameTextField = new JTextField(30); private JButton connectButton = new JButton ("Connect"); private String cnsName; private String channelName; private String username; public ConnectDialog() { this.setModal(true); Container cp = this.getContentPane(); Box vbox1 = Box.createVerticalBox(); cp.add(vbox1); //not in 1.3 vbox1.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0,0,1,1, Color.darkGray),BorderFactory.createMatteBorder(1,1,0,0, Color.white)),BorderFactory.createEmptyBorder(4,4,4,4))); Box hbox1 = Box.createHorizontalBox(); vbox1.add(hbox1); hbox1.add(new JLabel("Server address:")); hbox1.add(Box.createHorizontalStrut(2)); hbox1.add(cnsTextField); Box hbox2 = Box.createHorizontalBox(); vbox1.add(Box.createVerticalStrut(4)); vbox1.add(hbox2); hbox2.add(new JLabel("Channel name:")); hbox2.add(Box.createHorizontalStrut(2)); hbox2.add(channelTextField); vbox1.add(Box.createVerticalStrut(4)); Box hbox3 = Box.createHorizontalBox(); vbox1.add(hbox3); hbox3.add(new JLabel("Username:")); hbox3.add(Box.createHorizontalStrut(2)); hbox3.add(usernameTextField); vbox1.add(Box.createVerticalStrut(4)); vbox1.add(connectButton); connectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cnsName = cnsTextField.getText(); username = usernameTextField.getText(); channelName = channelTextField.getText(); ConnectDialog.this.setVisible(false); } }); this.pack(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension td = this.getSize(); this.setBounds((d.width - td.width)/2,(d.height - td.height)/2,td.width,td.height); this.setVisible(true); } protected void processWindowEvent(WindowEvent e) { if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public String getChannelName() { return channelName; } public String getCNSName() { return cnsName; } public String getUsername() { return username; } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ChatPlusFrame.java0000644000000000000000000002052311111352066020616 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.event.*; import java.awt.*; /** * @author Quickstone Technologies Limited */ public class ChatPlusFrame extends JFrame { private DrawingPanel whiteboard = new DrawingPanel(); private JTextField messageArea = new JTextField(80); private JTextArea chatLog = new JTextArea(); private JList userArea = new JList(); private JSplitPane horizPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); private JSplitPane vertPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); private JScrollPane chatLogScrollPane = new JScrollPane(chatLog); private JScrollPane whiteboardScrollPane = new JScrollPane(whiteboard); private JScrollPane userAreaScrollPane = new JScrollPane(userArea); private JToolBar whiteboardBar = new JToolBar(JToolBar.HORIZONTAL); private LineColorButton lcb; private FillColorButton fcb; private DrawingSettings ds; private JButton wipeButton; private JComboBox toolMenu = new JComboBox(new Object[] {"Freehand","Line","Rectangle","Round Rect","Oval","Text"}); private JComboBox strokeSizeMenu = new JComboBox(new Object[] {"1","2","3","4","5"}); public ChatPlusFrame(DrawingSettings ds) { this.ds = ds; Container cp = this.getContentPane(); JPanel outerpanel = new JPanel(new BorderLayout()); cp.add(outerpanel); outerpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1,1,0,0,Color.white),BorderFactory.createMatteBorder(0,0,1,1,Color.darkGray)),BorderFactory.createEmptyBorder(1,1,10,1))); Box vbox = Box.createVerticalBox(); vbox.add(Box.createVerticalStrut(4)); Box hbox = Box.createHorizontalBox(); hbox.add(Box.createHorizontalStrut(4)); hbox.add(messageArea); hbox.add(Box.createHorizontalStrut(4)); vbox.add(hbox); outerpanel.add(vbox,BorderLayout.SOUTH); outerpanel.add(vertPane, BorderLayout.CENTER); vertPane.setTopComponent(horizPane); vertPane.setBottomComponent(userAreaScrollPane); JPanel whiteboardLayoutPanel = new JPanel(); whiteboardLayoutPanel.setLayout(new BorderLayout()); whiteboardLayoutPanel.add(whiteboardBar,BorderLayout.NORTH); whiteboardBar.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); whiteboardLayoutPanel.add(whiteboardScrollPane, BorderLayout.CENTER); horizPane.setLeftComponent(whiteboardLayoutPanel); horizPane.setRightComponent(chatLogScrollPane); chatLog.setEditable(false); } // protected void processWindowEvent(WindowEvent e) { // if (e.getID() == WindowEvent.WINDOW_CLOSING) { // System.exit(0); // } // } public DrawingPanel getWhiteboard() { return whiteboard; } public JTextField getMessageArea() { return messageArea; } public JList getUserArea() { return userArea; } public JTextArea getChatLog() { return chatLog; } public JButton getWipeButton() { return wipeButton; } public JScrollPane getWhiteboardScrollPane() { return whiteboardScrollPane; } public JComboBox getToolMenu() { return toolMenu; } public void initComponents() { userArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); vertPane.setOneTouchExpandable(true); horizPane.setOneTouchExpandable(true); Dimension d =new Dimension(DrawingPanel.whiteboardWidth,DrawingPanel.whiteboardHeight); whiteboard.setPreferredSize(d); whiteboard.setMinimumSize(d); vertPane.setDividerLocation(0.75); vertPane.setResizeWeight(0.75); horizPane.setDividerLocation(0.75); messageArea.setMargin(new Insets(4,4,4,4)); lcb = new LineColorButton(ds); fcb = new FillColorButton(ds); strokeSizeMenu.setSelectedIndex(2); toolMenu.setSelectedIndex(0); whiteboardBar.setFloatable(false); whiteboardBar.add(new JLabel("Tool:")); whiteboardBar.add(Box.createHorizontalStrut(2)); whiteboardBar.add(toolMenu); toolMenu.setPreferredSize(new Dimension(100,22)); toolMenu.setMaximumSize(new Dimension(100,22)); toolMenu.setMinimumSize(new Dimension(100,22)); whiteboardBar.add(Box.createHorizontalStrut(4)); whiteboardBar.add(new JLabel(" Stroke Size:")); whiteboardBar.add(Box.createHorizontalStrut(2)); whiteboardBar.add(strokeSizeMenu); strokeSizeMenu.setPreferredSize(new Dimension(40,22)); strokeSizeMenu.setMaximumSize(new Dimension(40,22)); strokeSizeMenu.setMinimumSize(new Dimension(40,22)); whiteboardBar.add(Box.createHorizontalStrut(4)); strokeSizeMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ds.setStrokeSize(strokeSizeMenu.getSelectedIndex()+1); } }); whiteboardBar.addSeparator(); whiteboardBar.add(Box.createHorizontalStrut(4)); whiteboardBar.add(new JLabel("Line:")); whiteboardBar.add(Box.createHorizontalStrut(2)); whiteboardBar.add(lcb); whiteboardBar.add(Box.createHorizontalStrut(4)); whiteboardBar.add(new JLabel("Fill:")); whiteboardBar.add(Box.createHorizontalStrut(2)); whiteboardBar.add(fcb); lcb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(ChatPlusFrame.this,"Choose Line Colour",ds.getLineColor()); ds.setLineColor(newColor); lcb.repaint(); } }); fcb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(ChatPlusFrame.this,"Choose Fill Colour",ds.getLineColor()); ds.setFillColor(newColor); fcb.repaint(); } }); whiteboardBar.add(Box.createHorizontalStrut(4)); JCheckBox fillCheckBox = new JCheckBox("Filled Shapes:",true); fillCheckBox.setHorizontalTextPosition(SwingConstants.LEFT); fillCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.DESELECTED) { ds.setFilled(false); } else { ds.setFilled(true); } } }); whiteboardBar.add(fillCheckBox); whiteboardBar.addSeparator(); whiteboardBar.add(Box.createHorizontalStrut(4)); wipeButton = new JButton("Wipe"); whiteboardBar.add(wipeButton); } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/LineColorButton.java0000644000000000000000000000566511111352066021214 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.*; /** * @author Quickstone Technologies Limited */ public class LineColorButton extends JButton { private Dimension d; private DrawingSettings ds; public LineColorButton(DrawingSettings ds) { super(); this.ds =ds; //this.setContentAreaFilled(false); //this.setHorizontalTextPosition(AbstractButton.LEFT); //this.setVerticalTextPosition(AbstractButton.TOP); d = new Dimension (26,18); // System.out.println("dimension = " + d); this.setSize(d); this.setPreferredSize(d); this.setMinimumSize(d); this.setMaximumSize(d); this.setBorder(BorderFactory.createEmptyBorder(4,4,4,8)); this.setBorderPainted(true); } public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(ds.getLineColor()); g.fillRect(3,3,20,12); g.setColor(Color.black); g.drawRect(3,3,20,12); } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/MessageObject.java0000644000000000000000000000522211111352066020632 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.io.*; /** * @author Quickstone Technologies Limited */ public class MessageObject implements Serializable { public static final int USERMESSAGE = 0; public static final int CONNECT = 1; public static final int DISCONNECT = 2; public String user; public String message; public int sysCommand; public MessageObject(String user, String message) { this.user = user; this.message = message; this.sysCommand = USERMESSAGE; } public MessageObject(String user, String message, int sysCommand) { this.user = user; this.message = message; this.sysCommand = sysCommand; } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ChatPlusColorChooser.java0000644000000000000000000000437111111352066022170 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; /** * @author Quickstone Technologies Limited */ public class ChatPlusColorChooser extends JColorChooser { public ChatPlusColorChooser() { super(); this.setPreviewPanel(new JPanel()); } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/UserInListObject.java0000644000000000000000000000474511111352066021320 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author Quickstone Technologies Limited */ public class UserInListObject { private String messageText; private String userName; public UserInListObject(String user, String message) { userName = user; messageText = message; } public String getUserName() { return userName; } public void setMessageText(String s) { messageText = s; } public String toString() { return userName +": " + messageText; } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ReadyReportingIdentity.java0000644000000000000000000000570011111352066022570 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.util.*; /** * @author Quickstone Technologies Limited */ public class ReadyReportingIdentity implements CSProcess { private ChannelInput dataIn; private ChannelOutput dataOut; private ChannelOutputInt readyOut; public ReadyReportingIdentity(ChannelInput dataIn, ChannelOutput dataOut, ChannelOutputInt readyOut) { this.dataIn = dataIn; this.dataOut = dataOut; this.readyOut = readyOut; } public void run() { while (true) { //System.out.println("id: in true loop"); readyOut.write(0); //System.out.println("id: sent ready message"); ArrayList data = (ArrayList)dataIn.read(); //System.out.println("id: received data " + data); if (data.size() != 0) { //System.out.println("id: resending data " + data.size()); dataOut.write(data); } //System.out.println("id: written data"); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ServerSetupDialog.java0000644000000000000000000000766511111352066021543 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * @author Quickstone Technologies Limited */ public class ServerSetupDialog extends JDialog{ private JTextField channelTextField = new JTextField("JCSPChatChannel", 30); private JButton createButton = new JButton ("Create"); private String channelName; public ServerSetupDialog() { this.setModal(true); Container cp = this.getContentPane(); Box vbox1 = Box.createVerticalBox(); cp.add(vbox1); //not in 1.3 vbox1.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0,0,1,1, Color.darkGray),BorderFactory.createMatteBorder(1,1,0,0, Color.white)),BorderFactory.createEmptyBorder(4,4,4,4))); Box hbox2 = Box.createHorizontalBox(); vbox1.add(Box.createVerticalStrut(8)); vbox1.add(hbox2); hbox2.add(new JLabel("Channel name:")); hbox2.add(Box.createHorizontalStrut(2)); channelTextField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),BorderFactory.createEmptyBorder(2,2,2,2))); hbox2.add(channelTextField); vbox1.add(Box.createVerticalStrut(8)); vbox1.add(createButton); createButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { channelName = channelTextField.getText(); if (channelName != "") { ServerSetupDialog.this.setVisible(false); } } }); this.pack(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension td = this.getSize(); this.setBounds((d.width - td.width)/2,(d.height - td.height)/2,td.width,td.height); this.setVisible(true); } protected void processWindowEvent(WindowEvent e) { if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public String getChannelName() { return channelName; } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/ConnectionAuthenticator.java0000644000000000000000000000727011111352066022756 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.net.*; import java.util.*; /** * @author Quickstone Technologies Limited */ public class ConnectionAuthenticator implements CSProcess { private ChannelInput auth; private ChannelOutput out; private ChannelOutput back; private NetAltingChannelInput messageChan; private ArrayList users = new ArrayList(); public ConnectionAuthenticator(NetAltingChannelInput auth, ChannelOutput out, NetAltingChannelInput messageChan) { this.auth = auth; this.out = out; this.messageChan = messageChan; } public void run() { while (true) { Object o = auth.read(); System.out.println("connectAuth got "+ o); if (o instanceof ConnectionBundle) { String newUser = ((ConnectionBundle)o).getUser(); if (((ConnectionBundle)o).connect()) { //connecting if (users.contains(newUser)) { ((ConnectionBundle)o).getReturnChan().write(Boolean.FALSE); //auth.close(Boolean.FALSE); } else { users.add(newUser); System.out.println("added user " + newUser); out.write(o); //auth.close(Boolean.TRUE); ((ConnectionBundle)o).getReturnChan().write(messageChan.getChannelLocation()); } } else { //disconnecting out.write(o); } } else if (o instanceof ChannelOutput) { System.out.println("outputting to dynamic delta to disconnect"); out.write(o); } else { System.out.println("uh-oh - not a string or ChannelOutput received by ConnectionAuthenticator"); } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/SorterProcess.java0000644000000000000000000000603411111352066020736 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import java.util.*; /** * @author Quickstone Technologies Limited */ public class SorterProcess implements CSProcess{ private ChannelInput in; private ChannelOutput whiteboardOut; private ChannelOutput chatOut; public SorterProcess(ChannelInput in, ChannelOutput whiteboardOut, ChannelOutput chatOut) { this.in = in; this.whiteboardOut = whiteboardOut; this.chatOut = chatOut; } public void run () { while (true) { Object o = in.read(); //System.out.println("Sorter: received data"); if (o instanceof ArrayList && ((ArrayList)o).size() != 0) { ArrayList al = (ArrayList)o; for (int x=0; x < al.size(); x++ ) { Object o2 = al.get(x); if (o2 instanceof WhiteboardDataBundle) { whiteboardOut.write(o2); } else { chatOut.write(o2); } } } else { System.out.println("uh-oh - somethings awry... :( "); } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/MessageReceiverProcess.java0000644000000000000000000001260611111352066022533 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import org.jcsp.lang.*; /** * @author Quickstone Technologies Limited */ public class MessageReceiverProcess implements CSProcess { private String user; private ChannelInput in; private JList userlist; private JTextArea chatlog; private DefaultListModel listmodel; public MessageReceiverProcess(String user, ChannelInput in, JList userlist, JTextArea chatlog) { this.user = user; this.in = in; this.userlist = userlist; this.chatlog = chatlog; listmodel = new DefaultListModel(); userlist.setModel(listmodel); } public boolean updateRealtimeArea(String name, String message, boolean remove) { if (remove) { for (int x=0; x < listmodel.getSize(); x++ ) { UserInListObject uilo = (UserInListObject)listmodel.getElementAt(x); String s = uilo.getUserName(); if (name.equals(s)) { listmodel.removeElementAt(x); return true; } } } for (int x= 0; x < listmodel.getSize(); x++) { UserInListObject uilo = (UserInListObject)listmodel.getElementAt(x); String s = uilo.getUserName(); if (name.equals(s)) { uilo.setMessageText(message); userlist.update(userlist.getGraphics()); return true; } } UserInListObject newUserObject = new UserInListObject(name,message); listmodel.addElement(newUserObject); return false; } public void run() { while (true) { MessageObject mess = (MessageObject)in.read(); final String messageText = mess.message; final String messageUser = mess.user; final int sysCommand = mess.sysCommand; if (sysCommand != MessageObject.USERMESSAGE) { SwingUtilities.invokeLater(new Runnable() { final int command = sysCommand; public void run() { String s = chatlog.getText(); if (s != null) { s = s + messageText.toUpperCase(); } else { s = messageText.toUpperCase(); } chatlog.setText(s); if (command == MessageObject.CONNECT) { if (!(user.equals(messageUser))) { MessageReceiverProcess.this.updateRealtimeArea(messageUser,"",false); } } else if (command == MessageObject.DISCONNECT) { if (!(user.equals(messageUser))) { MessageReceiverProcess.this.updateRealtimeArea(messageUser,"",true); } } } }); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { if (messageText.endsWith("\n")) { String s = chatlog.getText(); if (s != null) { s = s + messageUser + ": " + messageText; } else { s = messageUser + ": " + messageText; } chatlog.setText(s); if (!(user.equals(messageUser))) { MessageReceiverProcess.this.updateRealtimeArea(messageUser,"",false); } } else { if (!(user.equals(messageUser))) { MessageReceiverProcess.this.updateRealtimeArea(messageUser,messageText,false); } } } }); } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/CustomDynamicDelta.java0000644000000000000000000001004611111352066021650 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.util.*; import org.jcsp.lang.*; import org.jcsp.plugNplay.*; /** * @author Quickstone Technologies Limited */ public final class CustomDynamicDelta implements CSProcess { private AltingChannelInput in; private AltingChannelInput config; private Hashtable hash; private Parallel par; public CustomDynamicDelta (AltingChannelInput in, AltingChannelInput config) { this.in = in; par = new Parallel (); hash = new Hashtable (); this.config = config; } public void run () { AltingChannelInput[] chans = {config, in}; Alternative alt = new Alternative (chans); while (true) { switch (alt.priSelect ()) { case 0: System.out.println("dd: reading config chan"); System.out.println("dd: hashtable looks like this:"); System.out.println(hash); Object object = config.read (); if (object instanceof ConnectionBundle) { ConnectionBundle cb = (ConnectionBundle)object; if (hash.containsKey (cb.getUser())) { System.out.println("dd: removing chan"); removeOutputChannel (cb); } else { addOutputChannel (cb); } } break; case 1: Object message = in.read (); Enumeration hashChans = hash.elements (); while (hashChans.hasMoreElements ()) { ((ProcessWrite) hashChans.nextElement ()).value = message; } par.run (); break; } } } private void addOutputChannel (ConnectionBundle cb) { ProcessWrite p = new ProcessWrite (cb.getReturnChan()); par.addProcess (p); hash.put (cb.getUser(), p); } private void removeOutputChannel (ConnectionBundle cb) { System.out.println("removing outputchan " + cb.getUser() ); ProcessWrite p = (ProcessWrite) hash.get (cb.getUser()); par.removeProcess (p); hash.remove (cb.getUser()); System.out.println("removed"); } } jcsp-1.1-rc4.orig/src/jcsp-demos/jcspchat/FillColorButton.java0000644000000000000000000000561211111352066021203 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import javax.swing.*; import java.awt.*; /** * @author Quickstone Technologies Limited */ public class FillColorButton extends JButton { private Dimension d; private DrawingSettings ds; public FillColorButton(DrawingSettings ds) { super(); this.ds =ds; //this.setContentAreaFilled(false); //this.setHorizontalTextPosition(AbstractButton.LEFT); //this.setVerticalTextPosition(AbstractButton.TOP); d = new Dimension (26,18); this.setSize(d); this.setPreferredSize(d); this.setMinimumSize(d); this.setMaximumSize(d); this.setBorder(BorderFactory.createEmptyBorder(4,4,4,8)); this.setBorderPainted(true); } public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(ds.getFillColor()); g.fillRect(3,3,20,12); g.setColor(Color.black); g.drawRect(3,3,20,12); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/0000755000000000000000000000000011410045036015601 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/MandelFarmer.java0000644000000000000000000001226111111352066021005 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class MandelFarmer implements CSProcess { private final ChannelInput fromControl; private final ChannelInput fromHarvester; private final ChannelOutput toHarvester; private final AltingChannelInput fromCancel; private final ChannelOutput toCancel; private final AltingChannelInput fromWorkers; private final ChannelOutput toWorkers; public MandelFarmer (final ChannelInput fromControl, final ChannelInput fromHarvester, final ChannelOutput toHarvester, final AltingChannelInput fromCancel, final ChannelOutput toCancel, final AltingChannelInput fromWorkers, final ChannelOutput toWorkers) { this.fromControl = fromControl; this.fromHarvester = fromHarvester; this.toHarvester = toHarvester; this.fromCancel = fromCancel; this.toCancel = toCancel; this.fromWorkers = fromWorkers; this.toWorkers = toWorkers; } public void run () { final Alternative alt = new Alternative ( new AltingChannelInput[] { fromCancel, fromWorkers } ); final int CANCEL = 0; final int WORK = 1; Object object = fromControl.read (); final int width = ((Integer) object).intValue (); final double[] X = new double[width]; toHarvester.write (object); object = fromControl.read (); final int height = ((Integer) object).intValue (); toHarvester.write (object); object = fromControl.read (); // mis toHarvester.write (object); object = fromControl.read (); // display toHarvester.write (object); while (true) { final FarmPacket packet = (FarmPacket) fromControl.read (); toHarvester.write (packet); System.out.println ("\nMandelFarmer: Left = " + packet.left); System.out.println ("MandelFarmer: Top = " + packet.top); System.out.println ("MandelFarmer: Size = " + packet.size); System.out.println ("MandelFarmer: Maximum iterations = " + packet.maxIterations); final double shrink = packet.size/((double) (width - 1)); for (int i = 0; i < width; i++) { X[i] = packet.left + (((double) i) * shrink); } while (fromCancel.pending ()) fromCancel.read (); toCancel.write (Boolean.TRUE); loop: for (int j = 0; j < height; j++) { final double y = packet.top - (((double) j) * shrink); switch (alt.priSelect ()) { case CANCEL: fromCancel.read (); System.out.println ("MandelFarmer.CANCEL: " + j); toCancel.write (Boolean.FALSE); toHarvester.write (new Integer (j)); // say how many work packets generated fromHarvester.read (); break loop; case WORK: final WorkPacket work = (WorkPacket) fromWorkers.read (); work.X = X; work.y = y; work.j = j; work.maxIterations = packet.maxIterations; toWorkers.write (work); break; } } toCancel.write (Boolean.FALSE); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/0000755000000000000000000000000011410045036016367 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/MandelFarmer.java0000644000000000000000000001356111111352066021577 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.net.*; import java.util.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class MandelFarmer implements CSProcess { private final ChannelInput fromControl; private final ChannelInput fromHarvester; private final ChannelOutput toHarvester; private final AltingChannelInput fromCancel; private final ChannelOutput toCancel; private final AltingChannelInput fromWorkers; private final Hashtable toWorkers; // NetChannelLocation -> NetChannelOutput objects public MandelFarmer( final ChannelInput fromControl, final ChannelInput fromHarvester, final ChannelOutput toHarvester, final AltingChannelInput fromCancel, final ChannelOutput toCancel, final AltingChannelInput fromWorkers) { this.fromControl = fromControl; this.fromHarvester = fromHarvester; this.toHarvester = toHarvester; this.fromCancel = fromCancel; this.toCancel = toCancel; this.fromWorkers = fromWorkers; this.toWorkers = new Hashtable (); } public void run() { final Guard[] guards = new Guard[] { fromCancel, fromWorkers }; final Alternative alt = new Alternative(guards); final int CANCEL = 0; Object object = fromControl.read(); final int width = ((Integer) object).intValue(); final double[] X = new double[width]; toHarvester.write(object); object = fromControl.read(); final int height = ((Integer) object).intValue(); toHarvester.write(object); object = fromControl.read(); // mis toHarvester.write(object); object = fromControl.read(); // display toHarvester.write(object); WorkPacket work = new WorkPacket(); while (true) { final FarmPacket packet = (FarmPacket) fromControl.read(); toHarvester.write(packet); System.out.println("\nMandelFarmer: Left = " + packet.left); System.out.println("MandelFarmer: Top = " + packet.top); System.out.println("MandelFarmer: Size = " + packet.size); System.out.println( "MandelFarmer: Maximum iterations = " + packet.maxIterations); final double shrink = packet.size / ((double) (width - 1)); for (int i = 0; i < width; i++) { X[i] = packet.left + (((double) i) * shrink); } while (fromCancel.pending()) fromCancel.read(); toCancel.write(Boolean.TRUE); for (int j = 0; j < height; j++) { final double y = packet.top - (((double) j) * shrink); if (alt.priSelect() == CANCEL) { fromCancel.read(); System.out.println("MandelFarmer.CANCEL: " + j); toCancel.write(Boolean.FALSE); toHarvester.write(new Integer(j)); // say how many work packets generated fromHarvester.read(); break; } else { NetChannelLocation ncl = (NetChannelLocation)fromWorkers.read(); work.X = X; work.y = y; work.j = j; work.maxIterations = packet.maxIterations; NetChannelOutput out = (NetChannelOutput)toWorkers.get (ncl); if (out == null) { out = NetChannelEnd.createOne2Net (ncl); toWorkers.put (ncl, out); } out.write(work); } } toCancel.write(Boolean.FALSE); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/MandelNetwork.java0000644000000000000000000002656511111352066022024 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import org.jcsp.net.*; import org.jcsp.net.cns.*; import java.awt.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class MandelNetwork implements CSProcess { private final ActiveCanvas activeCanvas; private final MandelControl mandelControl; private final MandelFarmer mandelFarmer; private final MandelHarvester mandelHarvester; private final ActiveChoice scrollChoice; private final ActiveChoice iterationsChoice; private final ActiveChoice targetChoice; private final ActiveChoice colourChoice; private final ActiveButton forwardButton; private final ActiveButton backwardButton; private final ActiveButton cancelButton; private final ActiveLabel[] infoLabel; public MandelNetwork(final Container parent) { final int minMaxIterations = 256; final int maxMaxIterations = 16 * 4096; // channels final One2OneChannel mouseChannel = Channel.one2one(new OverWriteOldestBuffer(10)); final One2OneChannel mouseMotionChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel keyChannel = Channel.one2one(new OverWriteOldestBuffer(10)); final One2OneChannel farmer2harvester = Channel.one2one(); final One2OneChannel harvester2farmer = Channel.one2one(); final NetAltingChannelInput workers2farmer = CNS.createNet2One ("org.jcsp.demos.mandelbrot.net.Farmer"); final NetAltingChannelInput workers2harvester = CNS.createNet2One ("org.jcsp.demos.mandelbrot.net.Harvester"); final One2OneChannel request = Channel.one2one(); final One2OneChannel reply = Channel.one2one(); final One2OneChannel toGraphics = Channel.one2one(); final One2OneChannel fromGraphics = Channel.one2one(); // processes parent.setLayout(new BorderLayout()); parent.setBackground(Color.black); activeCanvas = new ActiveCanvas(); activeCanvas.addMouseEventChannel(mouseChannel.out()); activeCanvas.addMouseMotionEventChannel(mouseMotionChannel.out()); activeCanvas.addKeyEventChannel(keyChannel.out()); activeCanvas.setGraphicsChannels(toGraphics.in(), fromGraphics.out()); activeCanvas.setSize(parent.getSize()); parent.add("Center", activeCanvas); // menus final Panel south = new Panel(); south.setBackground(Color.green); final One2OneChannel backwardChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel backwardConfigure = Channel.one2one(); backwardButton = new ActiveButton( backwardConfigure.in(), backwardChannel.out(), "Backward"); backwardButton.setBackground(Color.white); backwardButton.setEnabled(false); south.add(backwardButton); final One2OneChannel forwardChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel forwardConfigure = Channel.one2one(); forwardButton = new ActiveButton( forwardConfigure.in(), forwardChannel.out(), "Forward"); forwardButton.setBackground(Color.white); forwardButton.setEnabled(false); south.add(forwardButton); // south.add (new Label (" ", Label.CENTER)); // padding final One2OneChannel scrollChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel scrollConfigure = Channel.one2one(); scrollChoice = new ActiveChoice(scrollConfigure.in(), scrollChannel.out()); final String[] scrollMenu = { "Silent", "Up", "Down", "None" }; for (int i = 0; i < scrollMenu.length; i++) { scrollChoice.add(scrollMenu[i]); } south.add(new Label("Scrolling", Label.CENTER)); south.add(scrollChoice); final One2OneChannel iterationsChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel iterationsConfigure = Channel.one2one(); iterationsChoice = new ActiveChoice(iterationsConfigure.in(), iterationsChannel.out()); final String[] iterationsMenu = { "256", "512", "1K", "2K", "4K", "8K", "16K", "32K", "64K" }; for (int i = 0; i < iterationsMenu.length; i++) { iterationsChoice.add(iterationsMenu[i]); } south.add(new Label("Iterations", Label.CENTER)); south.add(iterationsChoice); final One2OneChannel targetChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel targetConfigure = Channel.one2one(); targetChoice = new ActiveChoice(targetConfigure.in(), targetChannel.out()); /* final String[] targetMenu = {"White", "Black", "Xor"}; */ final String[] targetMenu = { "White", "Black" }; for (int i = 0; i < targetMenu.length; i++) { targetChoice.add(targetMenu[i]); } south.add(new Label("Target", Label.CENTER)); south.add(targetChoice); final One2OneChannel colourChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel colourConfigure = Channel.one2one(); colourChoice = new ActiveChoice(colourConfigure.in(), colourChannel.out()); final String[] colourMenu = { "Step", "Fade" }; for (int i = 0; i < colourMenu.length; i++) { colourChoice.add(colourMenu[i]); } south.add(new Label("Colours", Label.CENTER)); south.add(colourChoice); south.add(new Label(" ", Label.CENTER)); // padding final One2OneChannel cancelChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel cancelConfigure = Channel.one2one(); cancelButton = new ActiveButton( cancelConfigure.in(), cancelChannel.out(), "Cancel"); cancelButton.setBackground(Color.white); cancelButton.setEnabled(false); south.add(cancelButton); parent.add("South", south); // labels final Panel north = new Panel(); north.setBackground(Color.green); final String[] infoTitle = { "Top", "Left", "Scale" }; final String[] infoWidth = { "XXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXX" }; final One2OneChannel[] infoConfigure = Channel.one2oneArray(infoTitle.length); infoLabel = new ActiveLabel[infoTitle.length]; for (int i = 0; i < infoTitle.length; i++) { infoLabel[i] = new ActiveLabel(infoConfigure[i].in(), infoWidth[i]); infoLabel[i].setAlignment(Label.CENTER); infoLabel[i].setBackground(Color.white); north.add(new Label(infoTitle[i], Label.CENTER)); north.add(infoLabel[i]); } parent.add("North", north); mandelControl = new MandelControl( minMaxIterations, maxMaxIterations, mouseChannel.in(), mouseMotionChannel.in(), keyChannel.in(), scrollConfigure.out(), scrollChannel.in(), scrollMenu, iterationsConfigure.out(), iterationsChannel.in(), iterationsMenu, targetConfigure.out(), targetChannel.in(), targetMenu, colourConfigure.out(), colourChannel.in(), colourMenu, forwardConfigure.out(), forwardChannel.in(), backwardConfigure.out(), backwardChannel.in(), Channel.getOutputArray(infoConfigure), request.out(), reply.in(), toGraphics.out(), fromGraphics.in()); mandelFarmer = new MandelFarmer( request.in(), harvester2farmer.in(), farmer2harvester.out(), cancelChannel.in(), cancelConfigure.out(), workers2farmer); mandelHarvester = new MandelHarvester( reply.out(), farmer2harvester.in(), harvester2farmer.out(), workers2harvester, toGraphics.out(), fromGraphics.in()); } public void run() { new Parallel( new CSProcess[] { activeCanvas, mandelControl, mandelFarmer, mandelHarvester, scrollChoice, iterationsChoice, targetChoice, colourChoice, forwardButton, backwardButton, cancelButton, new Parallel(infoLabel)}) .run(); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/MandelHarvester.java0000644000000000000000000001466011111352066022327 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.image.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class MandelHarvester implements CSProcess { private final ChannelOutput toControl; private final AltingChannelInput fromFarmer; private final ChannelOutput toFarmer; private final AltingChannelInput fromWorkers; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; public MandelHarvester (final ChannelOutput toControl, final AltingChannelInput fromFarmer, final ChannelOutput toFarmer, final AltingChannelInput fromWorkers, final ChannelOutput toGraphics, final ChannelInput fromGraphics) { this.toControl = toControl; this.fromFarmer = fromFarmer; this.toFarmer = toFarmer; this.fromWorkers = fromWorkers; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; } public void run () { final Alternative alt = new Alternative ( new AltingChannelInput[] { fromFarmer, fromWorkers } ); final int CANCEL = 0; final int RESULT = 1; final GraphicsCommand[] commands = {null, null}; // final GraphicsProtocol gpChange = new GraphicsProtocol.Change (1, commands); final int width = ((Integer) fromFarmer.read ()).intValue (); final int height = ((Integer) fromFarmer.read ()).intValue (); final MemoryImageSource[] mis = (MemoryImageSource[]) fromFarmer.read (); final Display display = (Display) fromFarmer.read (); final GraphicsCommand[] drawLine = new GraphicsCommand [height]; for (int j = 0; j < height; j++) { drawLine[j] = new GraphicsCommand.DrawLine (0, j, width - 1, j); } final CSTimer tim = new CSTimer (); long time1 = tim.read (); while (true) { final FarmPacket packet = (FarmPacket) fromFarmer.read (); commands[0] = packet.colouring; packet.ok = true; int lastLineArrived = -1; loop: for (int count = 0; count < height; count++) { switch (alt.priSelect ()) { case CANCEL: int generated = ((Integer) fromFarmer.read ()).intValue (); System.out.println ("MandelHarvester.CANCEL: " + count + " " + generated); for (int i = count; i < generated; i++) { fromWorkers.read (); } System.out.println ("MandelHarvester.CANCEL: " + count + " " + generated); toFarmer.write (Boolean.TRUE); // all work packets cleared packet.ok = false; break loop; case RESULT: final ResultPacket result = (ResultPacket) fromWorkers.read (); switch (packet.scrolling) { case FarmPacket.SCROLL_SILENT: System.arraycopy (result.points, 0, packet.pixels, result.j*width, width); if ((count % FarmPacket.STRIDE_SILENT) == 0) { commands[1] = drawLine[count]; display.change (commands, 1); } break; case FarmPacket.SCROLL_UP: if (result.j > lastLineArrived) { // need to scroll at least 1 line final int lines = result.j - lastLineArrived; System.arraycopy (packet.pixels, width * lines, packet.pixels, 0, width * (height - lines)); lastLineArrived = result.j; } // data blit System.arraycopy (result.points, 0, packet.pixels, width * (height - 1 - (lastLineArrived - result.j)), width); long t = tim.read (); if (t > time1 + 40) { mis[packet.colourModel].newPixels (); time1 = t; } break; case FarmPacket.SCROLL_DOWN: System.arraycopy (result.points, 0, packet.pixels, result.j*width, width); mis[packet.colourModel].newPixels (0, result.j, width, 1); break; case FarmPacket.NO_SCROLL: System.arraycopy (result.points, 0, packet.pixels, result.j*width, width); break; } break; } } toControl.write (packet); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/ResultPacket.java0000644000000000000000000000440511111352066021645 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.io.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class ResultPacket implements Serializable { public int j; // public int[] points; public byte[] points; } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/FarmPacket.java0000644000000000000000000000630311111352066021253 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class FarmPacket implements Cloneable { public static final int STRIDE_SILENT = 5; public static final int SCROLL_SILENT = 0; public static final int SCROLL_UP = 1; public static final int SCROLL_DOWN = 2; public static final int NO_SCROLL = 3; public int maxIterations, scrolling, colourModel; public double left, top, size; public GraphicsCommand colouring; public boolean ok; public byte[] pixels; public void copy (final FarmPacket p) { maxIterations = p.maxIterations; scrolling = p.scrolling; colourModel = p.colourModel; left= p.left; top = p.top; size = p.size; colouring = p.colouring; ok = p.ok; System.arraycopy (p.pixels, 0, pixels, 0, pixels.length); } public Object clone () { try { final FarmPacket packet = (FarmPacket) super.clone (); packet.pixels = (byte[]) pixels.clone (); return packet; } catch (CloneNotSupportedException e) { System.out.println (e); System.exit (-1); return null; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/MandelControl.java0000644000000000000000000011036611111352066022004 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.util.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class MandelControl implements CSProcess { private final int minMaxIterations; private final int maxMaxIterations; private final AltingChannelInput mouseChannel; private final AltingChannelInput mouseMotionChannel; private final AltingChannelInput keyChannel; private final ChannelOutput scrollConfigure; private final AltingChannelInput scrollChannel; private final String[] scrollMenu; private final ChannelOutput iterationsConfigure; private final AltingChannelInput iterationsChannel; private final String[] iterationsMenu; private final ChannelOutput targetConfigure; private final AltingChannelInput targetChannel; private final String[] targetMenu; private final ChannelOutput colourConfigure; private final AltingChannelInput colourChannel; private final String[] colourMenu; private final ChannelOutput forwardConfigure; private final AltingChannelInput forwardChannel; private final ChannelOutput backwardConfigure; private final AltingChannelInput backwardChannel; private final ChannelOutput[] infoConfigure; private final ChannelOutput request; private final ChannelInput reply; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; private final Alternative allControl, fbControl; private final int FORWARD_EVENT = 0; private final int BACKWARD_EVENT = 1; private final int MOUSE_EVENT = 2; private final int MOUSE_MOTION_EVENT = 3; private final int KEY_EVENT = 4; private final int SCROLL_EVENT = 5; private final int ITERATIONS_EVENT = 6; private final int TARGET_EVENT = 7; private final int COLOUR_EVENT = 8; public MandelControl (final int minMaxIterations, final int maxMaxIterations, final AltingChannelInput mouseChannel, final AltingChannelInput mouseMotionChannel, final AltingChannelInput keyChannel, final ChannelOutput scrollConfigure, final AltingChannelInput scrollChannel, final String[] scrollMenu, final ChannelOutput iterationsConfigure, final AltingChannelInput iterationsChannel, final String[] iterationsMenu, final ChannelOutput targetConfigure, final AltingChannelInput targetChannel, final String[] targetMenu, final ChannelOutput colourConfigure, final AltingChannelInput colourChannel, final String[] colourMenu, final ChannelOutput forwardConfigure, final AltingChannelInput forwardChannel, final ChannelOutput backwardConfigure, final AltingChannelInput backwardChannel, final ChannelOutput[] infoConfigure, final ChannelOutput request, final ChannelInput reply, final ChannelOutput toGraphics, final ChannelInput fromGraphics) { this.minMaxIterations = minMaxIterations; this.maxMaxIterations = maxMaxIterations; this.mouseChannel = mouseChannel; this.mouseMotionChannel = mouseMotionChannel; this.keyChannel = keyChannel; this.scrollConfigure = scrollConfigure; this.scrollChannel = scrollChannel; this.scrollMenu = scrollMenu; this.iterationsConfigure = iterationsConfigure; this.iterationsChannel = iterationsChannel; this.iterationsMenu = iterationsMenu; this.targetConfigure = targetConfigure; this.targetChannel = targetChannel; this.targetMenu = targetMenu; this.colourConfigure = colourConfigure; this.colourChannel = colourChannel; this.colourMenu = colourMenu; this.forwardConfigure = forwardConfigure; this.forwardChannel = forwardChannel; this.backwardConfigure = backwardConfigure; this.backwardChannel = backwardChannel; this.infoConfigure = infoConfigure; this.request = request; this.reply = reply; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; allControl = new Alternative ( new AltingChannelInput[] { forwardChannel, backwardChannel, mouseChannel, mouseMotionChannel, keyChannel, scrollChannel, iterationsChannel, targetChannel, colourChannel } ); fbControl = new Alternative ( new AltingChannelInput[] { forwardChannel, backwardChannel } ); } // key run-time parameters // ----------------------- private final double initialSize = 4.2; private final double initialLeft = -2.1; private int width; // global ? private int height; // global ? private double doubleWidth; // global ? private double aspectRatio; // global ? private Target box; private FarmPacket packet = new FarmPacket (); private final Vector pax = new Vector (); // for saving FarmPacket(ets) private int vecPax = 0; // number in the vector private int maxPax = 0; // number currently valid (maxPax <= vecPax) private int currentPax = 0; // number currently on display (currentPax <= maxPax) private int scrolling = FarmPacket.SCROLL_SILENT; private final int nColourModels = 2; private MemoryImageSource[] mis = new MemoryImageSource[nColourModels]; private int currentColourModel = 0; private final GraphicsCommand whiteXOR = new GraphicsCommand.SetXORMode (Color.white); private final GraphicsCommand whiteCOLOR = new GraphicsCommand.SetColor (Color.white); private final GraphicsCommand blackCOLOR = new GraphicsCommand.SetColor (Color.black); private final GraphicsCommand[] gcFirst = {null}; private final GraphicsCommand[] gcImage = {null}; private final GraphicsCommand[] gcSketch = {whiteCOLOR, null}; private final GraphicsCommand[] draw = new GraphicsCommand[nColourModels]; private final DisplayList display = new DisplayList (); /* private final GraphicsProtocol gpFirst = new GraphicsProtocol.Set (gcFirst); private final GraphicsProtocol gpImage = new GraphicsProtocol.Set (gcImage); private final GraphicsProtocol gpSketch = new GraphicsProtocol.Update (gcSketch); private final GraphicsProtocol gpChangeImage = new GraphicsProtocol.Change (0, gcImage); private final GraphicsProtocol gpChangeSketch = new GraphicsProtocol.Change (1, gcSketch); */ private final CSTimer tim = new CSTimer (); // protected methods // ----------------- protected ColorModel createColorModel (final int minMaxIterations, final int maxMaxIterations) { System.out.println("createColorModel: " + minMaxIterations + " " + maxMaxIterations); byte[] red = new byte[maxMaxIterations + 1]; byte[] green = new byte[maxMaxIterations + 1]; byte[] blue = new byte[maxMaxIterations + 1]; final int redF = 127; final int greenF = 30; final int blueF = 50; red[0] = 0; green[0] = 0; blue[0] = 0; for (int i = 1; i < (maxMaxIterations); i++) { red[i] = (byte) (((i*redF) % 256) - 128); green[i] = (byte) (((i*greenF) % 256) - 128); blue[i] = (byte) (((i*blueF) % 256) - 128); } int j = minMaxIterations; while (j <= maxMaxIterations) { red[j] = 0; green[j] = 0; blue[j] = 0; j *= 2; } System.out.println("createColorModel: --> IndexColorModel"); final int nBitsOfColour = 8; try { return new IndexColorModel (nBitsOfColour, red.length, red, green, blue); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("createColorModel: " + e); System.exit (-1); return null; } } protected void fade (final byte[] downColour, final byte[] upColour, final int start, final int finish, final int step) { int up = 1; int down = 255; for (int i = start; i < finish; i++) { upColour[i] = (byte) up; downColour[i] = (byte) down; up += step; down -= step; } } protected ColorModel createColorModel (final int variety) { System.out.println("createColorModel: 256"); byte[] red = new byte[256]; byte[] green = new byte[256]; byte[] blue = new byte[256]; red[0] = 0; green[0] = 0; blue[0] = 0; switch (variety) { case 0: final int redF = 127; final int greenF = 30; final int blueF = 50; for (int i = 1; i < 256; i++) { red[i] = (byte) (((i*redF) % 256) - 128); green[i] = (byte) (((i*greenF) % 256) - 128); blue[i] = (byte) (((i*blueF) % 256) - 128); } break; case 1: fade (green, blue, 1, 86, 3); fade (blue, red, 86, 171, 3); fade (red, green, 171, 256, 3); break; } System.out.println("createColorModel: --> IndexColorModel"); final int nBitsOfColour = 8; return new IndexColorModel (nBitsOfColour, red.length, red, green, blue); } public void run () { toGraphics.write (GraphicsProtocol.GET_DIMENSION); final Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("MandelControl: graphics dimension = " + graphicsDim); width = graphicsDim.width; height = graphicsDim.height; doubleWidth = (double) width; // (width - 1) ??? aspectRatio = ((double) height)/doubleWidth; packet.pixels = new byte[width*height]; packet.left = initialLeft; packet.top = (initialSize*aspectRatio)/2.0; packet.size = initialSize; packet.maxIterations = minMaxIterations; // packet.scrolling, packet.colouring and packet.colourModel are maintained separately final Image[] image = new Image[nColourModels]; for (int i = 0; i < nColourModels; i++) { mis[i] = new MemoryImageSource (width, height, createColorModel (i), packet.pixels, 0, width); mis[i].setAnimated (true); mis[i].setFullBufferUpdates (true); toGraphics.write (new GraphicsProtocol.MakeMISImage (mis[i])); image[i] = (Image) fromGraphics.read (); draw[i] = new GraphicsCommand.DrawImage (image[i], 0, 0); } currentColourModel = 0; toGraphics.write (new GraphicsProtocol.SetPaintable (display)); fromGraphics.read (); request.write (new Integer (width)); request.write (new Integer (height)); request.write (mis); request.write (display); box = new Target (width, height); gcFirst[0] = new GraphicsCommand.ClearRect (0, 0, width, height); gcImage[0] = draw[currentColourModel]; // not needed ??? display.set (gcFirst); gcSketch[1] = whiteCOLOR; display.extend (gcSketch); toGraphics.write (GraphicsProtocol.REQUEST_FOCUS); fromGraphics.read (); buildFirstPicture (); // first picture disallows cancel while (true) { defineNextPicture (); // enable ... disable controls buildPicture (); // enable ... disable cancel } } private void buildFirstPicture () { infoConfigure[0].write ("computing ..."); infoConfigure[1].write ("first ..."); infoConfigure[2].write ("image ..."); packet.colouring = gcSketch[0]; packet.scrolling = scrolling; packet.colourModel = currentColourModel; final long t0 = tim.read (); request.write (packet); packet = (FarmPacket) reply.read (); // packet.pixels and packet.ok have been set final long t1 = tim.read (); System.out.println ("buildPicture: " + (t1 - t0) + " milliseconds ..."); gcImage[0] = draw[currentColourModel]; display.set (gcImage); mis[currentColourModel].newPixels (); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); savePacket (); } private void buildPicture () { switch (scrolling) { case FarmPacket.SCROLL_UP: case FarmPacket.SCROLL_DOWN: gcImage[0] = draw[currentColourModel]; display.set (gcImage); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); break; case FarmPacket.SCROLL_SILENT: case FarmPacket.NO_SCROLL: infoConfigure[0].write ("computing ..."); infoConfigure[1].write ("next ..."); infoConfigure[2].write ("image ..."); break; } packet.colouring = gcSketch[0]; packet.scrolling = scrolling; packet.colourModel = currentColourModel; final long t0 = tim.read (); request.write (packet); packet = (FarmPacket) reply.read (); // packet.pixels and packet.ok have been set final long t1 = tim.read (); System.out.println ("buildPicture: " + (t1 - t0) + " milliseconds ..." + packet.ok); if (packet.ok) { savePacket (); } else { packet.copy ((FarmPacket) pax.elementAt (currentPax - 1)); int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); } /* switch (scrolling) { case FarmPacket.SCROLL_UP: case FarmPacket.SCROLL_DOWN: if (! packet.ok) { mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; toGraphics.write (gpImage); fromGraphics.read (); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); } break; case FarmPacket.SCROLL_SILENT: case FarmPacket.NO_SCROLL: gcImage[0] = draw[currentColourModel]; toGraphics.write (gpImage); fromGraphics.read (); if (packet.ok) mis[currentColourModel].newPixels (); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); break; } */ mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.set (gcImage); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); } private void savePacket () { if (currentPax == vecPax) { try { pax.addElement (packet.clone ()); vecPax++; currentPax++; maxPax = currentPax; } catch (OutOfMemoryError e) { System.out.println ("*** BUST: " + e); final FarmPacket pack = (FarmPacket) pax.elementAt (0); pax.removeElementAt (0); pack.copy (packet); pax.addElement (pack); } } else { ((FarmPacket) pax.elementAt (currentPax)).copy (packet); currentPax++; maxPax = currentPax; } System.out.println ("savePacket: " + currentPax + " " + maxPax + " " + vecPax); } protected void defineNextPicture () { final int INITIAL = 0; final int VISIBLE_BOX = 1; MouseEvent mouseEvent = null; KeyEvent keyEvent = null; scrollConfigure.write (Boolean.TRUE); iterationsConfigure.write (Boolean.TRUE); targetConfigure.write (Boolean.TRUE); colourConfigure.write (Boolean.TRUE); if (currentPax > 1) backwardConfigure.write (Boolean.TRUE); if (currentPax < maxPax) forwardConfigure.write (Boolean.TRUE); System.out.println ("defineNextPicture: " + currentPax + " " + maxPax + " " + vecPax); int state = INITIAL; boolean newPicture = true; boolean running = true; while (running) { while (keyChannel.pending ()) keyChannel.read (); // clear keystrokes while (mouseChannel.pending ()) mouseChannel.read (); // clear mouse clicks toGraphics.write (GraphicsProtocol.REQUEST_FOCUS); fromGraphics.read (); switch (state) { case INITIAL: switch (allControl.fairSelect ()) { case MOUSE_EVENT: mouseEvent = (MouseEvent) mouseChannel.read (); if (mouseEvent.getID () == MouseEvent.MOUSE_PRESSED) { box.reset (mouseEvent); gcSketch[1] = box.makeGraphicsCommand (); display.extend (gcSketch); forwardConfigure.write (Boolean.FALSE); backwardConfigure.write (Boolean.FALSE); state = VISIBLE_BOX; } break; case MOUSE_MOTION_EVENT: mouseEvent = (MouseEvent) mouseMotionChannel.read (); // ignore mouse movements here break; case KEY_EVENT: keyEvent = (KeyEvent) keyChannel.read (); if (keyEvent.getID () == KeyEvent.KEY_RELEASED) { switch (keyEvent.getKeyCode ()) { case KeyEvent.VK_RIGHT: packet.maxIterations *= 2; if (packet.maxIterations > maxMaxIterations) packet.maxIterations = maxMaxIterations; int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); gcSketch[1] = whiteCOLOR; display.extend (gcSketch); newPicture = false; // only changed packet.maxIterations running = false; break; case KeyEvent.VK_LEFT: packet.maxIterations /= 2; if (packet.maxIterations < minMaxIterations) packet.maxIterations = minMaxIterations; int ppindex = 0; int ppmax = 256; while (ppmax < packet.maxIterations) { ppmax *= 2; ppindex++; } iterationsConfigure.write (new Integer (ppindex)); gcSketch[1] = whiteCOLOR; display.extend (gcSketch); newPicture = false; // only changed packet.maxIterations running = false; break; case KeyEvent.VK_W: gcSketch[0] = whiteCOLOR; targetConfigure.write (new Integer (0)); break; case KeyEvent.VK_B: gcSketch[0] = blackCOLOR; targetConfigure.write (new Integer (1)); break; /* case KeyEvent.VK_X: gcSketch[0] = whiteXOR; targetConfigure.write (new Integer (2)); break; */ case KeyEvent.VK_S: if (0 != currentColourModel) { currentColourModel = 0; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } colourConfigure.write (new Integer (0)); break; case KeyEvent.VK_F: if (1 != currentColourModel) { currentColourModel = 1; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } colourConfigure.write (new Integer (1)); break; } } break; case SCROLL_EVENT: final ItemEvent se = (ItemEvent) scrollChannel.read (); final String schoice = (String) se.getItem (); scrolling = 0; while (schoice != scrollMenu[scrolling]) scrolling++; break; case ITERATIONS_EVENT: final ItemEvent ie = (ItemEvent) iterationsChannel.read (); final String ichoice = (String) ie.getItem (); int iindex = 0; while (ichoice != iterationsMenu[iindex]) iindex++; packet.maxIterations = 256; for (int i = 0; i < iindex; i++) packet.maxIterations *= 2; System.out.println ("MaxIterations = " + + packet.maxIterations); gcSketch[1] = whiteCOLOR; display.extend (gcSketch); newPicture = false; // only changed packet.maxIterations running = false; break; case TARGET_EVENT: final ItemEvent te = (ItemEvent) targetChannel.read (); final String tchoice = (String) te.getItem (); int tindex = 0; while (tchoice != targetMenu[tindex]) tindex++; switch (tindex) { case 0: gcSketch[0] = whiteCOLOR; break; case 1: gcSketch[0] = blackCOLOR; break; /* case 2: gcSketch[0] = whiteXOR; break; */ } break; case COLOUR_EVENT: final ItemEvent ce = (ItemEvent) colourChannel.read (); final String cchoice = (String) ce.getItem (); int cindex = 0; while (cchoice != colourMenu[cindex]) cindex++; if (cindex != currentColourModel) { currentColourModel = cindex; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } break; case FORWARD_EVENT: forwardChannel.read (); if (currentPax < maxPax) { // in case the GUI was slow at disabling ... backwardConfigure.write (Boolean.TRUE); scrollConfigure.write (Boolean.FALSE); iterationsConfigure.write (Boolean.FALSE); targetConfigure.write (Boolean.FALSE); colourConfigure.write (Boolean.FALSE); fbOption (true); } break; case BACKWARD_EVENT: backwardChannel.read (); if (currentPax > 1) { // in case the GUI was slow at disabling ... forwardConfigure.write (Boolean.TRUE); scrollConfigure.write (Boolean.FALSE); iterationsConfigure.write (Boolean.FALSE); targetConfigure.write (Boolean.FALSE); colourConfigure.write (Boolean.FALSE); currentPax--; packet.copy ((FarmPacket) pax.elementAt (currentPax - 1)); mis[currentColourModel].newPixels (); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/((double) width))).toString ()); int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); final long timeout = tim.read () + 100; tim.after (timeout); fbOption (false); } break; } break; case VISIBLE_BOX: switch (allControl.fairSelect ()) { case MOUSE_EVENT: mouseEvent = (MouseEvent) mouseChannel.read (); if (mouseEvent.getID () == MouseEvent.MOUSE_PRESSED) { int modifiers = mouseEvent.getModifiers (); if ((modifiers & InputEvent.BUTTON1_MASK) != 0) { display.extend (gcSketch); running = false; } else if ((modifiers & InputEvent.BUTTON3_MASK) != 0) { gcImage[0] = draw[currentColourModel]; display.set (gcImage); if (currentPax > 1) backwardConfigure.write (Boolean.TRUE); if (currentPax < maxPax) forwardConfigure.write (Boolean.TRUE); state = INITIAL; } } break; case MOUSE_MOTION_EVENT: mouseEvent = (MouseEvent) mouseMotionChannel.read (); if (mouseEvent.getID () == MouseEvent.MOUSE_MOVED) { box.move (mouseEvent); gcSketch[1] = box.makeGraphicsCommand (); display.change (gcSketch, 1); } break; case KEY_EVENT: keyEvent = (KeyEvent) keyChannel.read (); switch (keyEvent.getID ()) { case KeyEvent.KEY_PRESSED: switch (keyEvent.getKeyCode ()) { case KeyEvent.VK_UP: box.zoomUp (); gcSketch[1] = box.makeGraphicsCommand (); display.change (gcSketch, 1); break; case KeyEvent.VK_DOWN: box.zoomDown (); gcSketch[1] = box.makeGraphicsCommand (); display.change (gcSketch, 1); break; } break; case KeyEvent.KEY_RELEASED: switch (keyEvent.getKeyCode ()) { case KeyEvent.VK_ENTER: // toGraphics.write (gpImage); // romGraphics.read (); display.extend (gcSketch); running = false; break; case KeyEvent.VK_RIGHT: packet.maxIterations *= 2; if (packet.maxIterations > maxMaxIterations) packet.maxIterations = maxMaxIterations; int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); System.out.println ("MaxIterations = " + + packet.maxIterations); break; case KeyEvent.VK_LEFT: packet.maxIterations /= 2; if (packet.maxIterations < minMaxIterations) packet.maxIterations = minMaxIterations; int ppindex = 0; int ppmax = 256; while (ppmax < packet.maxIterations) { ppmax *= 2; ppindex++; } iterationsConfigure.write (new Integer (ppindex)); System.out.println ("MaxIterations = " + + packet.maxIterations); break; case KeyEvent.VK_W: gcSketch[0] = whiteCOLOR; targetConfigure.write (new Integer (0)); display.change (gcSketch, 1); break; case KeyEvent.VK_B: gcSketch[0] = blackCOLOR; targetConfigure.write (new Integer (1)); display.change (gcSketch, 1); break; /* case KeyEvent.VK_X: gcSketch[0] = whiteXOR; targetConfigure.write (new Integer (2)); display.change (gcSketch, 1); break; */ case KeyEvent.VK_S: if (0 != currentColourModel) { currentColourModel = 0; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } colourConfigure.write (new Integer (0)); break; case KeyEvent.VK_F: if (1 != currentColourModel) { currentColourModel = 1; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } colourConfigure.write (new Integer (1)); break; } break; } break; case SCROLL_EVENT: final ItemEvent se = (ItemEvent) scrollChannel.read (); final String schoice = (String) se.getItem (); scrolling = 0; while (schoice != scrollMenu[scrolling]) scrolling++; break; case ITERATIONS_EVENT: final ItemEvent ie = (ItemEvent) iterationsChannel.read (); final String ichoice = (String) ie.getItem (); int iindex = 0; while (ichoice != iterationsMenu[iindex]) iindex++; packet.maxIterations = 256; for (int i = 0; i < iindex; i++) packet.maxIterations *= 2; System.out.println ("MaxIterations = " + + packet.maxIterations); break; case TARGET_EVENT: final ItemEvent te = (ItemEvent) targetChannel.read (); final String tchoice = (String) te.getItem (); int tindex = 0; while (tchoice != targetMenu[tindex]) tindex++; switch (tindex) { case 0: gcSketch[0] = whiteCOLOR; break; case 1: gcSketch[0] = blackCOLOR; break; /* case 2: gcSketch[0] = whiteXOR; break; */ } display.change (gcSketch, 1); break; case COLOUR_EVENT: final ItemEvent ce = (ItemEvent) colourChannel.read (); final String cchoice = (String) ce.getItem (); int cindex = 0; while (cchoice != colourMenu[cindex]) cindex++; if (cindex != currentColourModel) { currentColourModel = cindex; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } break; case FORWARD_EVENT: forwardChannel.read (); break; case BACKWARD_EVENT: backwardChannel.read (); break; } break; } } scrollConfigure.write (Boolean.FALSE); iterationsConfigure.write (Boolean.FALSE); targetConfigure.write (Boolean.FALSE); colourConfigure.write (Boolean.FALSE); forwardConfigure.write (Boolean.FALSE); backwardConfigure.write (Boolean.FALSE); if (newPicture) { packet.left += packet.size*(((double) (box.zoomX - box.dX))/((double) width)); packet.top -= packet.size*(((double) (box.zoomY - box.dY))/((double) width)); packet.size *= ((double) box.dX2)/((double) width); } } private void fbOption (final boolean forwards) { final FarmPacket npacket = (FarmPacket) pax.elementAt (currentPax); final double shrink = doubleWidth/packet.size; final double nwidth = npacket.size*shrink; gcSketch[1] = new GraphicsCommand.DrawRect ( (int) ((npacket.left - packet.left)*shrink), (int) ((packet.top - npacket.top)*shrink), (int) nwidth, (int) (nwidth*aspectRatio) ); display.extend (gcSketch); if (forwards) { forwardConfigure.write ("Confirm"); backwardConfigure.write ("Cancel"); } else { backwardConfigure.write ("Confirm"); forwardConfigure.write ("Cancel"); } if (currentPax == maxPax) forwardConfigure.write (Boolean.FALSE); switch (fbControl.fairSelect ()) { // wait for user case FORWARD_EVENT: forwardChannel.read (); packet.copy (npacket); gcImage[0] = draw[currentColourModel]; display.set (gcImage); mis[currentColourModel].newPixels (); currentPax++; int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/((double) width))).toString ()); break; case BACKWARD_EVENT: backwardChannel.read (); gcImage[0] = draw[currentColourModel]; display.set (gcImage); break; } forwardConfigure.write ("Forward"); backwardConfigure.write ("Backward"); scrollConfigure.write (Boolean.TRUE); iterationsConfigure.write (Boolean.TRUE); targetConfigure.write (Boolean.TRUE); colourConfigure.write (Boolean.TRUE); if (currentPax == 1) backwardConfigure.write (Boolean.FALSE); if (currentPax == maxPax) forwardConfigure.write (Boolean.FALSE); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/MandelbrotMain.java0000644000000000000000000001010711111352066022127 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.net.*; import org.jcsp.net.cns.*; import org.jcsp.net.tcpip.*; import java.net.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ public class MandelbrotMain { public static final String TITLE = "Mandelbrot Set (distributed)"; public static final String DESCR = "Demonstates a distributed farmer/worker/harvester parallelisation. The farmer and harvestor processes " + "will run on this JVM. Workers can run on this machine or elsewhere to generate the actual image."; private static final int DEFAULT_WIDTH = 640, DEFAULT_HEIGHT = 480; public static void main (String[] args) throws Exception { // Get arguments String cnsServer = null; int width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT; for (int i = 0; i < args.length; i++) { if (args[i].equals ("-width")) { width = Integer.parseInt (args[++i]); } else if (args[i].equals ("-height")) { height = Integer.parseInt (args[++i]); } else { cnsServer = args[i]; } } if (cnsServer == null) { NodeKey key = Node.getInstance().init( new TCPIPAddressID( InetAddress.getLocalHost().getHostAddress(), TCPIPCNSServer.DEFAULT_CNS_PORT, true)); CNS.install(key); NodeAddressID cnsAddress = Node.getInstance().getNodeID().getAddresses()[0]; CNSService.install(key, cnsAddress); } else { Node.getInstance ().init (new TCPIPNodeFactory (cnsServer)); } final ActiveClosingFrame activeClosingFrame = new ActiveClosingFrame ("Distributed Mandelbrot"); final ActiveFrame activeFrame = activeClosingFrame.getActiveFrame (); activeFrame.setSize (width, height); final MandelNetwork mandelbrot = new MandelNetwork (activeFrame); activeFrame.pack (); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingFrame, mandelbrot } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/Target.java0000644000000000000000000001033211111352066020461 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; import java.awt.event.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class Target { private final int width; private final int height; public Target (final int width, final int height) { this.width = width; this.height = height; } int zoomX, zoomY; final double initialZoom = 0.1; double zoom = initialZoom; final double zoomAdjust = 1.2; final double maxZoom = 0.75; final double minZoom = 0.03; boolean shiftZoom = false; final double maxShiftZoom = 1.0; int dX, dY, dX2, dY2; public void reset (MouseEvent mouseEvent) { zoom = initialZoom; dX = (int) (((double) width)*(zoom/2.0)); dY = (int) (((double) height)*(zoom/2.0)); dX2 = (int) (((double) width)*zoom); dY2 = (int) (((double) height)*zoom); zoomX = mouseEvent.getX (); zoomY = mouseEvent.getY (); shiftZoom = ((mouseEvent.getModifiers () & InputEvent.SHIFT_MASK) != 0); } public void move (MouseEvent mouseEvent) { zoomX = mouseEvent.getX (); zoomY = mouseEvent.getY (); } public void zoomUp () { zoom *= zoomAdjust; if (shiftZoom) { if (zoom > maxShiftZoom) zoom = maxShiftZoom; } else { if (zoom > maxZoom) zoom = maxZoom; } dX = (int) (((double) width)*(zoom/2.0)); dY = (int) (((double) height)*(zoom/2.0)); dX2 = (int) (((double) width)*zoom); dY2 = (int) (((double) height)*zoom); } public void zoomDown () { zoom /= zoomAdjust; if (zoom < minZoom) zoom = minZoom; dX = (int) (((double) width)*(zoom/2.0)); dY = (int) (((double) height)*(zoom/2.0)); dX2 = (int) (((double) width)*zoom); dY2 = (int) (((double) height)*zoom); } public GraphicsCommand makeGraphicsCommand () { if (!shiftZoom) { if (zoomX < dX) { zoomX = dX; } else if (zoomX >= (width - dX)) { zoomX = (width - dX) - 1; } if (zoomY < dY) { zoomY = dY; } else if (zoomY >= (height - dY)) { zoomY = (height - dY) - 1; } } return new GraphicsCommand.DrawRect (zoomX - dX, zoomY - dY, dX2, dY2); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/MandelWorker.java0000644000000000000000000001327211111352066021633 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.net.*; import org.jcsp.net.tcpip.*; import org.jcsp.net.cns.*; import org.jcsp.demos.util.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ public class MandelWorker implements CSProcess { private static final int NUM_THREADS = 10; public static final String TITLE = "Mandelbrot Set (distributed)"; public static final String DESCR = "Mandelbrot worker process. Please give the name of the machine running the main program interface."; private final SharedChannelOutput toFarmer; private final NetChannelInput fromFarmer; private final NetChannelLocation id; private final SharedChannelOutput toHarvester; private MandelWorker (final SharedChannelOutput toFarmer, final NetChannelInput fromFarmer, final NetChannelLocation id, final SharedChannelOutput toHarvester) { this.toFarmer = toFarmer; this.fromFarmer = fromFarmer; this.id = id; this.toHarvester = toHarvester; } public void run () { final int radius = 2; final MandelPoint mandel = new MandelPoint (0, radius); ResultPacket result = new ResultPacket (); int count = 0; //System.out.println ("Worker " + id + " priority = " + PriParallel.getPriority ()); PriParallel.setPriority (Thread.MIN_PRIORITY); //System.out.println ("Worker " + id + " priority = " + PriParallel.getPriority ()); toFarmer.write (id); // request for work WorkPacket work = (WorkPacket) fromFarmer.read (); final int nPoints = work.X.length; result.points = new byte[nPoints]; while (true) { if ((count % 100) == 0) System.out.println (Thread.currentThread ().getName () + " - Working ... " + count ); count++; mandel.setMaxIterations (work.maxIterations); for (int i = 0; i < nPoints; i++) { final int iterations = mandel.compute (work.X[i], work.y); if ((iterations == work.maxIterations) || (iterations == 0)) { result.points[i] = 0; } else { final byte biterations = (byte) iterations; if (biterations == 0) { result.points[i] = 1; // OK for smooth colouring (rough ==> 127 ???) } else { result.points[i] = biterations; } } } result.j = work.j; toHarvester.write (result); toFarmer.write (id); work = (WorkPacket) fromFarmer.read (); } } public static void main (String[] args) throws Exception { // Start up if (args.length == 0) { Ask.app (TITLE, DESCR); Ask.addPrompt ("CNS Address"); Ask.show (); Node.getInstance ().init (new TCPIPNodeFactory (Ask.readStr ("CNS Address"))); Ask.blank (); } else { Node.getInstance ().init (new TCPIPNodeFactory (args[0])); } // Connect to the farmer and harvester NetChannelInput fromFarmer = NetChannelEnd.createNet2One (); NetChannelLocation id = fromFarmer.getChannelLocation (); System.out.println ("Connecting to farmer"); NetSharedChannelOutput toFarmer = CNS.createAny2Net ("org.jcsp.demos.mandelbrot.net.Farmer"); System.out.println ("Connecting to harvester"); NetSharedChannelOutput toHarvester = CNS.createAny2Net ("org.jcsp.demos.mandelbrot.net.Harvester"); System.out.println ("Ready"); // Create some workers CSProcess workers[] = new CSProcess[NUM_THREADS]; for (int i = 0; i < workers.length; i++) { workers[i] = new MandelWorker (toFarmer, fromFarmer, id, toHarvester); } new Parallel (workers).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/MandelPoint.java0000644000000000000000000000642511111352066021455 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.demos.util.ComplexDouble; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class MandelPoint { protected int maxIterations; protected double radiusSquared; public MandelPoint (final int maxIterations, final int radius) { this.maxIterations = maxIterations; radiusSquared = (double) radius*radius; } public void setMaxIterations (final int maxIterations) { this.maxIterations = maxIterations; } public int compute (final ComplexDouble c) { int n = 0; ComplexDouble z = (ComplexDouble) c.clone (); double zModulusSquared = z.modulusSquared (); while ((n < maxIterations) && (zModulusSquared < radiusSquared)) { z.mult (z).add (c); zModulusSquared = z.modulusSquared (); n++; } return n; } public int compute (final double a, final double b) { int n = 0; double x = a; double y = b; double xSquared = x*x; double ySquared = y*y; while ((n < maxIterations) && ((xSquared + ySquared) < radiusSquared)) { double tmp = (xSquared - ySquared) + a; y = ((2.0d*x)*y) + b; x = tmp; xSquared = x*x; ySquared = y*y; n++; } return n; } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/MandelPack.java0000644000000000000000000000622211111352066021235 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class MandelPack implements Cloneable { public static final int STRIDE_SILENT = 5; public static final int SCROLL_SILENT = 0; public static final int SCROLL_UP = 1; public static final int SCROLL_DOWN = 2; public static final int NO_SCROLL = 3; public int maxIterations, scrolling; public double left, top, size; public GraphicsCommand colouring; public boolean ok; public int[] pixels; public void copy (final MandelPack p) { maxIterations = p.maxIterations; scrolling = p.scrolling; left= p.left; top = p.top; size = p.size; colouring = p.colouring; ok = p.ok; System.arraycopy (p.pixels, 0, pixels, 0, pixels.length); } public Object clone () { try { final MandelPack packet = (MandelPack) super.clone (); packet.pixels = (int[]) pixels.clone (); return packet; } catch (CloneNotSupportedException e) { System.out.println (e); System.exit (-1); return null; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/net/WorkPacket.java0000644000000000000000000000441211111352066021307 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.io.*; /** * @author Quickstone Technologies Limited * @author P.H. Welch (non-networked original code) */ class WorkPacket implements Serializable { public double[] X; public double y; public int j, maxIterations; } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/MandelNetwork.java0000644000000000000000000003240311111352066021222 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ class MandelNetwork implements CSProcess { private final int nWorkers = 10; private final ActiveCanvas activeCanvas; private final MandelControl mandelControl; private final MandelFarmer mandelFarmer; private final MandelHarvester mandelHarvester; private final MandelWorker[] mandelWorker = new MandelWorker[nWorkers]; private final ActiveChoice scrollChoice; private final ActiveChoice iterationsChoice; private final ActiveChoice targetChoice; private final ActiveChoice colourChoice; private final ActiveButton forwardButton; private final ActiveButton backwardButton; private final ActiveButton cancelButton; private final ActiveLabel[] infoLabel; public MandelNetwork(final Container parent) { final int minMaxIterations = 256; final int maxMaxIterations = 16 * 4096; // channels final One2OneChannel mouseChannel = Channel.one2one (new OverWriteOldestBuffer(10)); final One2OneChannel mouseMotionChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel keyChannel = Channel.one2one(new OverWriteOldestBuffer(10)); final One2OneChannel farmer2harvester = Channel.one2one(); final One2OneChannel harvester2farmer = Channel.one2one(); final Any2OneChannel workers2farmer = Channel.any2one(); final One2OneChannel farmer2workers = Channel.one2one(); final Any2OneChannel workers2harvester = Channel.any2one(); final One2OneChannel harvester2workers = Channel.one2one(); final One2OneChannel request = Channel.one2one(); final One2OneChannel reply = Channel.one2one(); final One2OneChannel toGraphics = Channel.one2one(); final One2OneChannel fromGraphics = Channel.one2one(); // processes parent.setLayout(new BorderLayout()); parent.setBackground(Color.black); activeCanvas = new ActiveCanvas(); activeCanvas.addMouseEventChannel(mouseChannel.out ()); activeCanvas.addMouseMotionEventChannel(mouseMotionChannel.out ()); activeCanvas.addKeyEventChannel(keyChannel.out ()); activeCanvas.setGraphicsChannels(toGraphics.in (), fromGraphics.out ()); activeCanvas.setSize(parent.getSize()); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. parent.add("Center", activeCanvas); // menus final Panel south = new Panel(); south.setBackground(Color.green); final One2OneChannel backwardChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel backwardConfigure = Channel.one2one(); backwardButton = new ActiveButton(backwardConfigure.in (), backwardChannel.out (), "Backward"); backwardButton.setBackground(Color.white); backwardButton.setEnabled(false); south.add(backwardButton); final One2OneChannel forwardChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel forwardConfigure = Channel.one2one(); forwardButton = new ActiveButton(forwardConfigure.in (), forwardChannel.out (), "Forward"); forwardButton.setBackground(Color.white); forwardButton.setEnabled(false); south.add(forwardButton); // south.add (new Label (" ", Label.CENTER)); // padding final One2OneChannel scrollChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel scrollConfigure = Channel.one2one(); scrollChoice = new ActiveChoice(scrollConfigure.in (), scrollChannel.out ()); final String[] scrollMenu = { "Silent", "Up", "Down", "None" }; for (int i = 0; i < scrollMenu.length; i++) { scrollChoice.add(scrollMenu[i]); } south.add(new Label("Scrolling", Label.CENTER)); south.add(scrollChoice); final One2OneChannel iterationsChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel iterationsConfigure = Channel.one2one(); iterationsChoice = new ActiveChoice(iterationsConfigure.in (), iterationsChannel.out ()); final String[] iterationsMenu = { "256", "512", "1K", "2K", "4K", "8K", "16K", "32K", "64K" }; for (int i = 0; i < iterationsMenu.length; i++) { iterationsChoice.add(iterationsMenu[i]); } south.add(new Label("Iterations", Label.CENTER)); south.add(iterationsChoice); final One2OneChannel targetChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel targetConfigure = Channel.one2one(); targetChoice = new ActiveChoice(targetConfigure.in (), targetChannel.out ()); /* final String[] targetMenu = {"White", "Black", "Xor"}; */ final String[] targetMenu = { "White", "Black" }; for (int i = 0; i < targetMenu.length; i++) { targetChoice.add(targetMenu[i]); } south.add(new Label("Target", Label.CENTER)); south.add(targetChoice); final One2OneChannel colourChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel colourConfigure = Channel.one2one(); colourChoice = new ActiveChoice(colourConfigure.in (), colourChannel.out ()); final String[] colourMenu = { "Step", "Fade" }; for (int i = 0; i < colourMenu.length; i++) { colourChoice.add(colourMenu[i]); } south.add(new Label("Colours", Label.CENTER)); south.add(colourChoice); south.add(new Label(" ", Label.CENTER)); // padding final One2OneChannel cancelChannel = Channel.one2one(new OverWriteOldestBuffer(1)); final One2OneChannel cancelConfigure = Channel.one2one(); cancelButton = new ActiveButton(cancelConfigure.in (), cancelChannel.out (), "Cancel"); cancelButton.setBackground(Color.white); cancelButton.setEnabled(false); south.add(cancelButton); parent.add("South", south); // labels final Panel north = new Panel(); north.setBackground(Color.green); final String[] infoTitle = { "Top", "Left", "Scale" }; final String[] infoWidth = { "XXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXX" }; final One2OneChannel[] infoConfigure = Channel.one2oneArray(infoTitle.length); infoLabel = new ActiveLabel[infoTitle.length]; for (int i = 0; i < infoTitle.length; i++) { infoLabel[i] = new ActiveLabel(infoConfigure[i].in (), infoWidth[i]); infoLabel[i].setAlignment(Label.CENTER); infoLabel[i].setBackground(Color.white); north.add(new Label(infoTitle[i], Label.CENTER)); north.add(infoLabel[i]); } parent.add("North", north); mandelControl = new MandelControl( minMaxIterations, maxMaxIterations, mouseChannel.in (), mouseMotionChannel.in (), keyChannel.in (), scrollConfigure.out (), scrollChannel.in (), scrollMenu, iterationsConfigure.out (), iterationsChannel.in (), iterationsMenu, targetConfigure.out (), targetChannel.in (), targetMenu, colourConfigure.out (), colourChannel.in (), colourMenu, forwardConfigure.out (), forwardChannel.in (), backwardConfigure.out (), backwardChannel.in (), Channel.getOutputArray (infoConfigure), request.out (), reply.in (), toGraphics.out (), fromGraphics.in ()); mandelFarmer = new MandelFarmer( request.in (), harvester2farmer.in (), farmer2harvester.out (), cancelChannel.in (), cancelConfigure.out (), workers2farmer.in (), farmer2workers.out ()); mandelHarvester = new MandelHarvester( reply.out (), farmer2harvester.in (), harvester2farmer.out (), workers2harvester.in (), harvester2workers.out (), toGraphics.out (), fromGraphics.in ()); for (int i = 0; i < nWorkers; i++) { mandelWorker[i] = new MandelWorker( i, minMaxIterations, maxMaxIterations, farmer2workers.in (), workers2farmer.out (), harvester2workers.in (), workers2harvester.out ()); } } public void run() { /* new Parallel ( new CSProcess[] { activeCanvas, mandelControl, mandelFarmer, mandelHarvester, new Parallel (mandelWorker), scrollChoice, iterationsChoice, targetChoice, colourChoice, forwardButton, backwardButton, cancelButton, new Parallel (infoLabel) } ).run (); */ // this is a workaround for a strange bug when running this as an applet in JDK1.2.x. // That bug does not allow nested Parallels within applets ... as in the above code! final CSProcess[] some = { activeCanvas, mandelControl, mandelFarmer, mandelHarvester, scrollChoice, iterationsChoice, targetChoice, colourChoice, forwardButton, backwardButton, cancelButton }; final CSProcess[] all = new CSProcess[some.length + mandelWorker.length + infoLabel.length]; System.arraycopy(some, 0, all, 0, some.length); System.arraycopy( mandelWorker, 0, all, some.length, mandelWorker.length); System.arraycopy( infoLabel, 0, all, some.length + mandelWorker.length, infoLabel.length); new Parallel(all).run(); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/MandelHarvester.java0000644000000000000000000001420011111352066021527 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.image.*; /** * @author P.H. Welch */ class MandelHarvester implements CSProcess { private final ChannelOutput toControl; private final AltingChannelInput fromFarmer; private final ChannelOutput toFarmer; private final AltingChannelInput fromWorkers; private final ChannelOutput toWorkers; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; public MandelHarvester (final ChannelOutput toControl, final AltingChannelInput fromFarmer, final ChannelOutput toFarmer, final AltingChannelInput fromWorkers, final ChannelOutput toWorkers, final ChannelOutput toGraphics, final ChannelInput fromGraphics) { this.toControl = toControl; this.fromFarmer = fromFarmer; this.toFarmer = toFarmer; this.fromWorkers = fromWorkers; this.toWorkers = toWorkers; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; } public void run () { final Alternative alt = new Alternative ( new AltingChannelInput[] { fromFarmer, fromWorkers } ); final int CANCEL = 0; final int RESULT = 1; final GraphicsCommand[] commands = {null, null}; // final GraphicsProtocol gpChange = new GraphicsProtocol.Change (1, commands); final int width = ((Integer) fromFarmer.read ()).intValue (); final int height = ((Integer) fromFarmer.read ()).intValue (); final MemoryImageSource[] mis = (MemoryImageSource[]) fromFarmer.read (); final Display display = (Display) fromFarmer.read (); final int lastRowStart = width*(height - 1); final GraphicsCommand[] drawLine = new GraphicsCommand [height]; for (int j = 0; j < height; j++) { drawLine[j] = new GraphicsCommand.DrawLine (0, j, width - 1, j); } while (true) { final FarmPacket packet = (FarmPacket) fromFarmer.read (); commands[0] = packet.colouring; packet.ok = true; loop: for (int count = 0; count < height; count++) { switch (alt.priSelect ()) { case CANCEL: int generated = ((Integer) fromFarmer.read ()).intValue (); System.out.println ("MandelHarvester.CANCEL: " + count + " " + generated); for (int i = count; i < generated; i++) { final ResultPacket result = (ResultPacket) fromWorkers.read (); toWorkers.write (result); } System.out.println ("MandelHarvester.CANCEL: " + count + " " + generated); toFarmer.write (Boolean.TRUE); // all work packets cleared packet.ok = false; break loop; case RESULT: final ResultPacket result = (ResultPacket) fromWorkers.read (); switch (packet.scrolling) { case FarmPacket.SCROLL_SILENT: System.arraycopy (result.points, 0, packet.pixels, result.j*width, width); if ((count % FarmPacket.STRIDE_SILENT) == 0) { commands[1] = drawLine[count]; display.change (commands, 1); } break; case FarmPacket.SCROLL_UP: // this one is all wrong !!! System.arraycopy (packet.pixels, width, packet.pixels, 0, lastRowStart); System.arraycopy (result.points, 0, packet.pixels, lastRowStart, width); mis[packet.colourModel].newPixels (); break; case FarmPacket.SCROLL_DOWN: System.arraycopy (result.points, 0, packet.pixels, result.j*width, width); mis[packet.colourModel].newPixels (0, result.j, width, 1); break; case FarmPacket.NO_SCROLL: System.arraycopy (result.points, 0, packet.pixels, result.j*width, width); break; } toWorkers.write (result); break; } } toControl.write (packet); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/ns-Mandelbrot.html0000644000000000000000000000650711113065047021210 0ustar JCSP Mandelbrot

The Mandelbrot Set

[LEFT-MOUSE-CLICK] on the drawing canvas to get a target box that moves with the mouse pointer. The size of this box can be altered by the [UP-ARROW] and [DOWN-ARROW] keys. Its colour can be changed (just black or white) by the Target choice box. The box can be erased by a [RIGHT-MOUSE-CLICK].

Having obtained a target box, move and resize it so that it is over an area of interest. [LEFT-MOUSE-CLICK] again (or press the [CARRIAGE-RETURN] key) to enlarge the area within the box to the full size of the applet canvas.

Whilst the new image is being computed, a progress bar scrolls down the canvas to give an indication of how fast things are going. The relative position of the bar in the canvas corresponds to the relative area of computation currently being performed within the box. This progress bar can be eliminated by selecting the None option in the Scrolling choice box. Other options are Up and Down, which cause the new image to be displayed as it is being computed - however, this usually slows everything down as the image rendering (usually) dominates the computation cost. The Silent option is the default, which yields the progress bar.

The Iterations choice box lets us set the maximum number of iterations for the Mandelbrot calculation. There are very interesting regions where this needs to be set to 32K - find them!

The images can be rendered with two colour maps - Step and Fade selectable from the Colours choice box. Some areas look better with one and some with the other.

Previous images are remembered and may be recovered by clicking the Backward button. Having gone back, we can go Forward again. Two clicks are needed for this: the first shows a target box over the area we have just come from (or are about to go to) and the second allows us to Confirm or Cancel the move.

The coordinates of the top-left point in the image are displayed in the Top and Left labels (above the canvas). The resolution between points is shown in the Scale label.

The Mandelbrot computation is performed by a classical worker process farm. Areas of the image are farmed out to idle workers a few lines at a time. On a (SMP) multiprocessor, real speedup will be obtained as all processors will be used (assuming our JVM runs with native threads). A running computation can be cancelled by clicking the Cancel button (that is only enabled during such a run).

Minor detail: the default size of the target box can be increased only to around 70% of the size of the applet canvas (and has the same aspect ratio). To target an image of the same resolution, but shifted slightly horizontally or vertically, a target box the same size as the canvas is required. This is allowed by using [SHIFT-LEFT-MOUSE-CLICK] to create the box (instead of LEFT-MOUSE-CLICK]). jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/ResultPacket.java0000644000000000000000000000421611111352066021057 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class ResultPacket { public int j; // public int[] points; public byte[] points; } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/Mandelbrot.html0000644000000000000000000001154411113065047020567 0ustar JCSP Mandelbrot

The Mandelbrot Set

[LEFT-MOUSE-CLICK] on the drawing canvas to get a target box that moves with the mouse pointer. The size of this box can be altered by the [UP-ARROW] and [DOWN-ARROW] keys. Its colour can be changed (just black or white) by the Target choice box. The box can be erased by a [RIGHT-MOUSE-CLICK].

Having obtained a target box, move and resize it so that it is over an area of interest. [LEFT-MOUSE-CLICK] again (or press the [CARRIAGE-RETURN] key) to enlarge the area within the box to the full size of the applet canvas.

Whilst the new image is being computed, a progress bar scrolls down the canvas to give an indication of how fast things are going. The relative position of the bar in the canvas corresponds to the relative area of computation currently being performed within the box. This progress bar can be eliminated by selecting the None option in the Scrolling choice box. Other options are Up and Down, which cause the new image to be displayed as it is being computed - however, this usually slows everything down as the image rendering (usually) dominates the computation cost. The Silent option is the default, which yields the progress bar.

The Iterations choice box lets us set the maximum number of iterations for the Mandelbrot calculation. There are very interesting regions where this needs to be set to 32K - find them!

The images can be rendered with two colour maps - Step and Fade selectable from the Colours choice box. Some areas look better with one and some with the other.

Previous images are remembered and may be recovered by clicking the Backward button. Having gone back, we can go Forward again. Two clicks are needed for this: the first shows a target box over the area we have just come from (or are about to go to) and the second allows us to Confirm or Cancel the move.

The coordinates of the top-left point in the image are displayed in the Top and Left labels (above the canvas). The resolution between points is shown in the Scale label.

The Mandelbrot computation is performed by a classical worker process farm. Areas of the image are farmed out to idle workers a few lines at a time. On a (SMP) multiprocessor, real speedup will be obtained as all processors will be used (assuming our JVM runs with native threads). A running computation can be cancelled by clicking the Cancel button (that is only enabled during such a run).

Minor detail: the default size of the target box can be increased only to around 70% of the size of the applet canvas (and has the same aspect ratio). To target an image of the same resolution, but shifted slightly horizontally or vertically, a target box the same size as the canvas is required. This is allowed by using [SHIFT-LEFT-MOUSE-CLICK] to create the box (instead of LEFT-MOUSE-CLICK]). jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/FarmPacket.java0000644000000000000000000000617111111352066020470 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; /** * @author P.H. Welch */ class FarmPacket implements Cloneable { public static final int STRIDE_SILENT = 5; public static final int SCROLL_SILENT = 0; public static final int SCROLL_UP = 1; public static final int SCROLL_DOWN = 2; public static final int NO_SCROLL = 3; public int maxIterations, scrolling, colourModel; public double left, top, size; public GraphicsCommand colouring; public boolean ok; public byte[] pixels; public void copy (final FarmPacket p) { maxIterations = p.maxIterations; scrolling = p.scrolling; colourModel = p.colourModel; left= p.left; top = p.top; size = p.size; colouring = p.colouring; ok = p.ok; System.arraycopy (p.pixels, 0, pixels, 0, pixels.length); } public Object clone () { try { final FarmPacket packet = (FarmPacket) super.clone (); packet.pixels = (byte[]) pixels.clone (); return packet; } catch (CloneNotSupportedException e) { System.out.println (e); System.exit (-1); return null; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/MandelControl.java0000644000000000000000000011025211111352066021210 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.util.*; /** * @author P.H. Welch */ class MandelControl implements CSProcess { private final int minMaxIterations; private final int maxMaxIterations; private final AltingChannelInput mouseChannel; private final AltingChannelInput mouseMotionChannel; private final AltingChannelInput keyChannel; private final ChannelOutput scrollConfigure; private final AltingChannelInput scrollChannel; private final String[] scrollMenu; private final ChannelOutput iterationsConfigure; private final AltingChannelInput iterationsChannel; private final String[] iterationsMenu; private final ChannelOutput targetConfigure; private final AltingChannelInput targetChannel; private final String[] targetMenu; private final ChannelOutput colourConfigure; private final AltingChannelInput colourChannel; private final String[] colourMenu; private final ChannelOutput forwardConfigure; private final AltingChannelInput forwardChannel; private final ChannelOutput backwardConfigure; private final AltingChannelInput backwardChannel; private final ChannelOutput[] infoConfigure; private final ChannelOutput request; private final ChannelInput reply; private final ChannelOutput toGraphics; private final ChannelInput fromGraphics; private final Alternative allControl, fbControl; private final int FORWARD_EVENT = 0; private final int BACKWARD_EVENT = 1; private final int MOUSE_EVENT = 2; private final int MOUSE_MOTION_EVENT = 3; private final int KEY_EVENT = 4; private final int SCROLL_EVENT = 5; private final int ITERATIONS_EVENT = 6; private final int TARGET_EVENT = 7; private final int COLOUR_EVENT = 8; public MandelControl (final int minMaxIterations, final int maxMaxIterations, final AltingChannelInput mouseChannel, final AltingChannelInput mouseMotionChannel, final AltingChannelInput keyChannel, final ChannelOutput scrollConfigure, final AltingChannelInput scrollChannel, final String[] scrollMenu, final ChannelOutput iterationsConfigure, final AltingChannelInput iterationsChannel, final String[] iterationsMenu, final ChannelOutput targetConfigure, final AltingChannelInput targetChannel, final String[] targetMenu, final ChannelOutput colourConfigure, final AltingChannelInput colourChannel, final String[] colourMenu, final ChannelOutput forwardConfigure, final AltingChannelInput forwardChannel, final ChannelOutput backwardConfigure, final AltingChannelInput backwardChannel, final ChannelOutput[] infoConfigure, final ChannelOutput request, final ChannelInput reply, final ChannelOutput toGraphics, final ChannelInput fromGraphics) { this.minMaxIterations = minMaxIterations; this.maxMaxIterations = maxMaxIterations; this.mouseChannel = mouseChannel; this.mouseMotionChannel = mouseMotionChannel; this.keyChannel = keyChannel; this.scrollConfigure = scrollConfigure; this.scrollChannel = scrollChannel; this.scrollMenu = scrollMenu; this.iterationsConfigure = iterationsConfigure; this.iterationsChannel = iterationsChannel; this.iterationsMenu = iterationsMenu; this.targetConfigure = targetConfigure; this.targetChannel = targetChannel; this.targetMenu = targetMenu; this.colourConfigure = colourConfigure; this.colourChannel = colourChannel; this.colourMenu = colourMenu; this.forwardConfigure = forwardConfigure; this.forwardChannel = forwardChannel; this.backwardConfigure = backwardConfigure; this.backwardChannel = backwardChannel; this.infoConfigure = infoConfigure; this.request = request; this.reply = reply; this.toGraphics = toGraphics; this.fromGraphics = fromGraphics; allControl = new Alternative ( new AltingChannelInput[] { forwardChannel, backwardChannel, mouseChannel, mouseMotionChannel, keyChannel, scrollChannel, iterationsChannel, targetChannel, colourChannel } ); fbControl = new Alternative ( new AltingChannelInput[] { forwardChannel, backwardChannel } ); } // key run-time parameters // ----------------------- private final double initialSize = 4.2; private final double initialLeft = -2.1; private int width; // global ? private int height; // global ? private double doubleWidth; // global ? private double aspectRatio; // global ? private Target box; private FarmPacket packet = new FarmPacket (); private final Vector pax = new Vector (); // for saving FarmPacket(ets) private int vecPax = 0; // number in the vector private int maxPax = 0; // number currently valid (maxPax <= vecPax) private int currentPax = 0; // number currently on display (currentPax <= maxPax) private int scrolling = FarmPacket.SCROLL_SILENT; private final int nColourModels = 2; private MemoryImageSource[] mis = new MemoryImageSource[nColourModels]; private int currentColourModel = 0; private final GraphicsCommand whiteXOR = new GraphicsCommand.SetXORMode (Color.white); private final GraphicsCommand whiteCOLOR = new GraphicsCommand.SetColor (Color.white); private final GraphicsCommand blackCOLOR = new GraphicsCommand.SetColor (Color.black); private final GraphicsCommand[] gcFirst = {null}; private final GraphicsCommand[] gcImage = {null}; private final GraphicsCommand[] gcSketch = {whiteCOLOR, null}; private final GraphicsCommand[] draw = new GraphicsCommand[nColourModels]; private final DisplayList display = new DisplayList (); /* private final GraphicsProtocol gpFirst = new GraphicsProtocol.Set (gcFirst); private final GraphicsProtocol gpImage = new GraphicsProtocol.Set (gcImage); private final GraphicsProtocol gpSketch = new GraphicsProtocol.Update (gcSketch); private final GraphicsProtocol gpChangeImage = new GraphicsProtocol.Change (0, gcImage); private final GraphicsProtocol gpChangeSketch = new GraphicsProtocol.Change (1, gcSketch); */ private final CSTimer tim = new CSTimer (); // protected methods // ----------------- protected ColorModel createColorModel (final int minMaxIterations, final int maxMaxIterations) { System.out.println("createColorModel: " + minMaxIterations + " " + maxMaxIterations); byte[] red = new byte[maxMaxIterations + 1]; byte[] green = new byte[maxMaxIterations + 1]; byte[] blue = new byte[maxMaxIterations + 1]; final int redF = 127; final int greenF = 30; final int blueF = 50; red[0] = 0; green[0] = 0; blue[0] = 0; for (int i = 1; i < (maxMaxIterations); i++) { red[i] = (byte) (((i*redF) % 256) - 128); green[i] = (byte) (((i*greenF) % 256) - 128); blue[i] = (byte) (((i*blueF) % 256) - 128); } int j = minMaxIterations; while (j <= maxMaxIterations) { red[j] = 0; green[j] = 0; blue[j] = 0; j *= 2; } System.out.println("createColorModel: --> IndexColorModel"); final int nBitsOfColour = 8; try { return new IndexColorModel (nBitsOfColour, red.length, red, green, blue); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("createColorModel: " + e); System.exit (-1); return null; } } protected void fade (final byte[] downColour, final byte[] upColour, final int start, final int finish, final int step) { int up = 1; int down = 255; for (int i = start; i < finish; i++) { upColour[i] = (byte) up; downColour[i] = (byte) down; up += step; down -= step; } } protected ColorModel createColorModel (final int variety) { System.out.println("createColorModel: 256"); byte[] red = new byte[256]; byte[] green = new byte[256]; byte[] blue = new byte[256]; red[0] = 0; green[0] = 0; blue[0] = 0; switch (variety) { case 0: final int redF = 127; final int greenF = 30; final int blueF = 50; for (int i = 1; i < 256; i++) { red[i] = (byte) (((i*redF) % 256) - 128); green[i] = (byte) (((i*greenF) % 256) - 128); blue[i] = (byte) (((i*blueF) % 256) - 128); } break; case 1: fade (green, blue, 1, 86, 3); fade (blue, red, 86, 171, 3); fade (red, green, 171, 256, 3); break; } System.out.println("createColorModel: --> IndexColorModel"); final int nBitsOfColour = 8; return new IndexColorModel (nBitsOfColour, red.length, red, green, blue); } public void run () { toGraphics.write (GraphicsProtocol.GET_DIMENSION); final Dimension graphicsDim = (Dimension) fromGraphics.read (); System.out.println ("MandelControl: graphics dimension = " + graphicsDim); width = graphicsDim.width; height = graphicsDim.height; doubleWidth = (double) width; // (width - 1) ??? aspectRatio = ((double) height)/doubleWidth; packet.pixels = new byte[width*height]; packet.left = initialLeft; packet.top = (initialSize*aspectRatio)/2.0; packet.size = initialSize; packet.maxIterations = minMaxIterations; // packet.scrolling, packet.colouring and packet.colourModel are maintained separately final Image[] image = new Image[nColourModels]; for (int i = 0; i < nColourModels; i++) { mis[i] = new MemoryImageSource (width, height, createColorModel (i), packet.pixels, 0, width); mis[i].setAnimated (true); mis[i].setFullBufferUpdates (true); toGraphics.write (new GraphicsProtocol.MakeMISImage (mis[i])); image[i] = (Image) fromGraphics.read (); draw[i] = new GraphicsCommand.DrawImage (image[i], 0, 0); } currentColourModel = 0; toGraphics.write (new GraphicsProtocol.SetPaintable (display)); fromGraphics.read (); request.write (new Integer (width)); request.write (new Integer (height)); request.write (mis); request.write (display); box = new Target (width, height); gcFirst[0] = new GraphicsCommand.ClearRect (0, 0, width, height); gcImage[0] = draw[currentColourModel]; // not needed ??? display.set (gcFirst); gcSketch[1] = whiteCOLOR; display.extend (gcSketch); toGraphics.write (GraphicsProtocol.REQUEST_FOCUS); fromGraphics.read (); buildFirstPicture (); // first picture disallows cancel while (true) { defineNextPicture (); // enable ... disable controls buildPicture (); // enable ... disable cancel } } private void buildFirstPicture () { infoConfigure[0].write ("computing ..."); infoConfigure[1].write ("first ..."); infoConfigure[2].write ("image ..."); packet.colouring = gcSketch[0]; packet.scrolling = scrolling; packet.colourModel = currentColourModel; final long t0 = tim.read (); request.write (packet); packet = (FarmPacket) reply.read (); // packet.pixels and packet.ok have been set final long t1 = tim.read (); System.out.println ("buildPicture: " + (t1 - t0) + " milliseconds ..."); gcImage[0] = draw[currentColourModel]; display.set (gcImage); mis[currentColourModel].newPixels (); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); savePacket (); } private void buildPicture () { switch (scrolling) { case FarmPacket.SCROLL_UP: case FarmPacket.SCROLL_DOWN: gcImage[0] = draw[currentColourModel]; display.set (gcImage); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); break; case FarmPacket.SCROLL_SILENT: case FarmPacket.NO_SCROLL: infoConfigure[0].write ("computing ..."); infoConfigure[1].write ("next ..."); infoConfigure[2].write ("image ..."); break; } packet.colouring = gcSketch[0]; packet.scrolling = scrolling; packet.colourModel = currentColourModel; final long t0 = tim.read (); request.write (packet); packet = (FarmPacket) reply.read (); // packet.pixels and packet.ok have been set final long t1 = tim.read (); System.out.println ("buildPicture: " + (t1 - t0) + " milliseconds ..." + packet.ok); if (packet.ok) { savePacket (); } else { packet.copy ((FarmPacket) pax.elementAt (currentPax - 1)); int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); } /* switch (scrolling) { case FarmPacket.SCROLL_UP: case FarmPacket.SCROLL_DOWN: if (! packet.ok) { mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; toGraphics.write (gpImage); fromGraphics.read (); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); } break; case FarmPacket.SCROLL_SILENT: case FarmPacket.NO_SCROLL: gcImage[0] = draw[currentColourModel]; toGraphics.write (gpImage); fromGraphics.read (); if (packet.ok) mis[currentColourModel].newPixels (); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); break; } */ mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.set (gcImage); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/doubleWidth)).toString ()); } private void savePacket () { if (currentPax == vecPax) { try { pax.addElement (packet.clone ()); vecPax++; currentPax++; maxPax = currentPax; } catch (OutOfMemoryError e) { System.out.println ("*** BUST: " + e); final FarmPacket pack = (FarmPacket) pax.elementAt (0); pax.removeElementAt (0); pack.copy (packet); pax.addElement (pack); } } else { ((FarmPacket) pax.elementAt (currentPax)).copy (packet); currentPax++; maxPax = currentPax; } System.out.println ("savePacket: " + currentPax + " " + maxPax + " " + vecPax); } protected void defineNextPicture () { final int INITIAL = 0; final int VISIBLE_BOX = 1; MouseEvent mouseEvent = null; KeyEvent keyEvent = null; scrollConfigure.write (Boolean.TRUE); iterationsConfigure.write (Boolean.TRUE); targetConfigure.write (Boolean.TRUE); colourConfigure.write (Boolean.TRUE); if (currentPax > 1) backwardConfigure.write (Boolean.TRUE); if (currentPax < maxPax) forwardConfigure.write (Boolean.TRUE); System.out.println ("defineNextPicture: " + currentPax + " " + maxPax + " " + vecPax); int state = INITIAL; boolean newPicture = true; boolean running = true; while (running) { while (keyChannel.pending ()) keyChannel.read (); // clear keystrokes while (mouseChannel.pending ()) mouseChannel.read (); // clear mouse clicks toGraphics.write (GraphicsProtocol.REQUEST_FOCUS); fromGraphics.read (); switch (state) { case INITIAL: switch (allControl.fairSelect ()) { case MOUSE_EVENT: mouseEvent = (MouseEvent) mouseChannel.read (); if (mouseEvent.getID () == MouseEvent.MOUSE_PRESSED) { box.reset (mouseEvent); gcSketch[1] = box.makeGraphicsCommand (); display.extend (gcSketch); forwardConfigure.write (Boolean.FALSE); backwardConfigure.write (Boolean.FALSE); state = VISIBLE_BOX; } break; case MOUSE_MOTION_EVENT: mouseEvent = (MouseEvent) mouseMotionChannel.read (); // ignore mouse movements here break; case KEY_EVENT: keyEvent = (KeyEvent) keyChannel.read (); if (keyEvent.getID () == KeyEvent.KEY_RELEASED) { switch (keyEvent.getKeyCode ()) { case KeyEvent.VK_RIGHT: packet.maxIterations *= 2; if (packet.maxIterations > maxMaxIterations) packet.maxIterations = maxMaxIterations; int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); gcSketch[1] = whiteCOLOR; display.extend (gcSketch); newPicture = false; // only changed packet.maxIterations running = false; break; case KeyEvent.VK_LEFT: packet.maxIterations /= 2; if (packet.maxIterations < minMaxIterations) packet.maxIterations = minMaxIterations; int ppindex = 0; int ppmax = 256; while (ppmax < packet.maxIterations) { ppmax *= 2; ppindex++; } iterationsConfigure.write (new Integer (ppindex)); gcSketch[1] = whiteCOLOR; display.extend (gcSketch); newPicture = false; // only changed packet.maxIterations running = false; break; case KeyEvent.VK_W: gcSketch[0] = whiteCOLOR; targetConfigure.write (new Integer (0)); break; case KeyEvent.VK_B: gcSketch[0] = blackCOLOR; targetConfigure.write (new Integer (1)); break; /* case KeyEvent.VK_X: gcSketch[0] = whiteXOR; targetConfigure.write (new Integer (2)); break; */ case KeyEvent.VK_S: if (0 != currentColourModel) { currentColourModel = 0; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } colourConfigure.write (new Integer (0)); break; case KeyEvent.VK_F: if (1 != currentColourModel) { currentColourModel = 1; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } colourConfigure.write (new Integer (1)); break; } } break; case SCROLL_EVENT: final ItemEvent se = (ItemEvent) scrollChannel.read (); final String schoice = (String) se.getItem (); scrolling = 0; while (schoice != scrollMenu[scrolling]) scrolling++; break; case ITERATIONS_EVENT: final ItemEvent ie = (ItemEvent) iterationsChannel.read (); final String ichoice = (String) ie.getItem (); int iindex = 0; while (ichoice != iterationsMenu[iindex]) iindex++; packet.maxIterations = 256; for (int i = 0; i < iindex; i++) packet.maxIterations *= 2; System.out.println ("MaxIterations = " + + packet.maxIterations); gcSketch[1] = whiteCOLOR; display.extend (gcSketch); newPicture = false; // only changed packet.maxIterations running = false; break; case TARGET_EVENT: final ItemEvent te = (ItemEvent) targetChannel.read (); final String tchoice = (String) te.getItem (); int tindex = 0; while (tchoice != targetMenu[tindex]) tindex++; switch (tindex) { case 0: gcSketch[0] = whiteCOLOR; break; case 1: gcSketch[0] = blackCOLOR; break; /* case 2: gcSketch[0] = whiteXOR; break; */ } break; case COLOUR_EVENT: final ItemEvent ce = (ItemEvent) colourChannel.read (); final String cchoice = (String) ce.getItem (); int cindex = 0; while (cchoice != colourMenu[cindex]) cindex++; if (cindex != currentColourModel) { currentColourModel = cindex; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } break; case FORWARD_EVENT: forwardChannel.read (); if (currentPax < maxPax) { // in case the GUI was slow at disabling ... backwardConfigure.write (Boolean.TRUE); scrollConfigure.write (Boolean.FALSE); iterationsConfigure.write (Boolean.FALSE); targetConfigure.write (Boolean.FALSE); colourConfigure.write (Boolean.FALSE); fbOption (true); } break; case BACKWARD_EVENT: backwardChannel.read (); if (currentPax > 1) { // in case the GUI was slow at disabling ... forwardConfigure.write (Boolean.TRUE); scrollConfigure.write (Boolean.FALSE); iterationsConfigure.write (Boolean.FALSE); targetConfigure.write (Boolean.FALSE); colourConfigure.write (Boolean.FALSE); currentPax--; packet.copy ((FarmPacket) pax.elementAt (currentPax - 1)); mis[currentColourModel].newPixels (); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/((double) width))).toString ()); int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); final long timeout = tim.read () + 100; tim.after (timeout); fbOption (false); } break; } break; case VISIBLE_BOX: switch (allControl.fairSelect ()) { case MOUSE_EVENT: mouseEvent = (MouseEvent) mouseChannel.read (); if (mouseEvent.getID () == MouseEvent.MOUSE_PRESSED) { int modifiers = mouseEvent.getModifiers (); if ((modifiers & InputEvent.BUTTON1_MASK) != 0) { display.extend (gcSketch); running = false; } else if ((modifiers & InputEvent.BUTTON3_MASK) != 0) { gcImage[0] = draw[currentColourModel]; display.set (gcImage); if (currentPax > 1) backwardConfigure.write (Boolean.TRUE); if (currentPax < maxPax) forwardConfigure.write (Boolean.TRUE); state = INITIAL; } } break; case MOUSE_MOTION_EVENT: mouseEvent = (MouseEvent) mouseMotionChannel.read (); if (mouseEvent.getID () == MouseEvent.MOUSE_MOVED) { box.move (mouseEvent); gcSketch[1] = box.makeGraphicsCommand (); display.change (gcSketch, 1); } break; case KEY_EVENT: keyEvent = (KeyEvent) keyChannel.read (); switch (keyEvent.getID ()) { case KeyEvent.KEY_PRESSED: switch (keyEvent.getKeyCode ()) { case KeyEvent.VK_UP: box.zoomUp (); gcSketch[1] = box.makeGraphicsCommand (); display.change (gcSketch, 1); break; case KeyEvent.VK_DOWN: box.zoomDown (); gcSketch[1] = box.makeGraphicsCommand (); display.change (gcSketch, 1); break; } break; case KeyEvent.KEY_RELEASED: switch (keyEvent.getKeyCode ()) { case KeyEvent.VK_ENTER: // toGraphics.write (gpImage); // romGraphics.read (); display.extend (gcSketch); running = false; break; case KeyEvent.VK_RIGHT: packet.maxIterations *= 2; if (packet.maxIterations > maxMaxIterations) packet.maxIterations = maxMaxIterations; int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); System.out.println ("MaxIterations = " + + packet.maxIterations); break; case KeyEvent.VK_LEFT: packet.maxIterations /= 2; if (packet.maxIterations < minMaxIterations) packet.maxIterations = minMaxIterations; int ppindex = 0; int ppmax = 256; while (ppmax < packet.maxIterations) { ppmax *= 2; ppindex++; } iterationsConfigure.write (new Integer (ppindex)); System.out.println ("MaxIterations = " + + packet.maxIterations); break; case KeyEvent.VK_W: gcSketch[0] = whiteCOLOR; targetConfigure.write (new Integer (0)); display.change (gcSketch, 1); break; case KeyEvent.VK_B: gcSketch[0] = blackCOLOR; targetConfigure.write (new Integer (1)); display.change (gcSketch, 1); break; /* case KeyEvent.VK_X: gcSketch[0] = whiteXOR; targetConfigure.write (new Integer (2)); display.change (gcSketch, 1); break; */ case KeyEvent.VK_S: if (0 != currentColourModel) { currentColourModel = 0; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } colourConfigure.write (new Integer (0)); break; case KeyEvent.VK_F: if (1 != currentColourModel) { currentColourModel = 1; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } colourConfigure.write (new Integer (1)); break; } break; } break; case SCROLL_EVENT: final ItemEvent se = (ItemEvent) scrollChannel.read (); final String schoice = (String) se.getItem (); scrolling = 0; while (schoice != scrollMenu[scrolling]) scrolling++; break; case ITERATIONS_EVENT: final ItemEvent ie = (ItemEvent) iterationsChannel.read (); final String ichoice = (String) ie.getItem (); int iindex = 0; while (ichoice != iterationsMenu[iindex]) iindex++; packet.maxIterations = 256; for (int i = 0; i < iindex; i++) packet.maxIterations *= 2; System.out.println ("MaxIterations = " + + packet.maxIterations); break; case TARGET_EVENT: final ItemEvent te = (ItemEvent) targetChannel.read (); final String tchoice = (String) te.getItem (); int tindex = 0; while (tchoice != targetMenu[tindex]) tindex++; switch (tindex) { case 0: gcSketch[0] = whiteCOLOR; break; case 1: gcSketch[0] = blackCOLOR; break; /* case 2: gcSketch[0] = whiteXOR; break; */ } display.change (gcSketch, 1); break; case COLOUR_EVENT: final ItemEvent ce = (ItemEvent) colourChannel.read (); final String cchoice = (String) ce.getItem (); int cindex = 0; while (cchoice != colourMenu[cindex]) cindex++; if (cindex != currentColourModel) { currentColourModel = cindex; mis[currentColourModel].newPixels (); gcImage[0] = draw[currentColourModel]; display.change (gcImage, 0); } break; case FORWARD_EVENT: forwardChannel.read (); break; case BACKWARD_EVENT: backwardChannel.read (); break; } break; } } scrollConfigure.write (Boolean.FALSE); iterationsConfigure.write (Boolean.FALSE); targetConfigure.write (Boolean.FALSE); colourConfigure.write (Boolean.FALSE); forwardConfigure.write (Boolean.FALSE); backwardConfigure.write (Boolean.FALSE); if (newPicture) { packet.left += packet.size*(((double) (box.zoomX - box.dX))/((double) width)); packet.top -= packet.size*(((double) (box.zoomY - box.dY))/((double) width)); packet.size *= ((double) box.dX2)/((double) width); } } private void fbOption (final boolean forwards) { final FarmPacket npacket = (FarmPacket) pax.elementAt (currentPax); final double shrink = doubleWidth/packet.size; final double nwidth = npacket.size*shrink; gcSketch[1] = new GraphicsCommand.DrawRect ( (int) ((npacket.left - packet.left)*shrink), (int) ((packet.top - npacket.top)*shrink), (int) nwidth, (int) (nwidth*aspectRatio) ); display.extend (gcSketch); if (forwards) { forwardConfigure.write ("Confirm"); backwardConfigure.write ("Cancel"); } else { backwardConfigure.write ("Confirm"); forwardConfigure.write ("Cancel"); } if (currentPax == maxPax) forwardConfigure.write (Boolean.FALSE); switch (fbControl.fairSelect ()) { // wait for user case FORWARD_EVENT: forwardChannel.read (); packet.copy (npacket); gcImage[0] = draw[currentColourModel]; display.set (gcImage); mis[currentColourModel].newPixels (); currentPax++; int pindex = 0; int pmax = 256; while (pmax < packet.maxIterations) { pmax *= 2; pindex++; } iterationsConfigure.write (new Integer (pindex)); infoConfigure[0].write ((new Double (packet.top)).toString ()); infoConfigure[1].write ((new Double (packet.left)).toString ()); infoConfigure[2].write ((new Double (packet.size/((double) width))).toString ()); break; case BACKWARD_EVENT: backwardChannel.read (); gcImage[0] = draw[currentColourModel]; display.set (gcImage); break; } forwardConfigure.write ("Forward"); backwardConfigure.write ("Backward"); scrollConfigure.write (Boolean.TRUE); iterationsConfigure.write (Boolean.TRUE); targetConfigure.write (Boolean.TRUE); colourConfigure.write (Boolean.TRUE); if (currentPax == 1) backwardConfigure.write (Boolean.FALSE); if (currentPax == maxPax) forwardConfigure.write (Boolean.FALSE); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/MandelbrotMain.java0000644000000000000000000001004311111352066021340 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class MandelbrotMain extends ActiveApplet { public static final String TITLE = "Mandelbrot"; public static final String DESCR = "Generates the mandelbrot set in an interactive browser window. The browser allows the color scheme to be modified, " + "the number of iterations varied and to zoom into the generated image. This demonstration shows the " + "farmer/worker/harvester approach to parallelisation and the handling of AWT events within the farmer to control " + "the image.\n\n" + "The parameters below specify the size of the generated image in pixels.\n\n" + "To zoom into the image, left click and a box will appear to select an area. Use the up/down cursor keys to adjust " + "the size of this area. Click again to zoom."; public static final int minWidth = 640; public static final int minHeight = 350; public static final int maxWidth = 1024; public static final int maxHeight = 768; public void init () { setProcess (new MandelNetwork (this)); } public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 800); Ask.addPrompt ("height", minHeight, maxHeight, 600); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame ("Mandelbrot Set"); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final MandelNetwork mandelbrot = new MandelNetwork (activeFrame); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, mandelbrot } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/Target.java0000644000000000000000000001022011111352066017667 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; import java.awt.event.*; /** * @author P.H. Welch */ class Target { private final int width; private final int height; public Target (final int width, final int height) { this.width = width; this.height = height; } int zoomX, zoomY; final double initialZoom = 0.1; double zoom = initialZoom; final double zoomAdjust = 1.2; final double maxZoom = 0.75; final double minZoom = 0.03; boolean shiftZoom = false; final double maxShiftZoom = 1.0; int dX, dY, dX2, dY2; public void reset (MouseEvent mouseEvent) { zoom = initialZoom; dX = (int) (((double) width)*(zoom/2.0)); dY = (int) (((double) height)*(zoom/2.0)); dX2 = (int) (((double) width)*zoom); dY2 = (int) (((double) height)*zoom); zoomX = mouseEvent.getX (); zoomY = mouseEvent.getY (); shiftZoom = ((mouseEvent.getModifiers () & InputEvent.SHIFT_MASK) != 0); } public void move (MouseEvent mouseEvent) { zoomX = mouseEvent.getX (); zoomY = mouseEvent.getY (); } public void zoomUp () { zoom *= zoomAdjust; if (shiftZoom) { if (zoom > maxShiftZoom) zoom = maxShiftZoom; } else { if (zoom > maxZoom) zoom = maxZoom; } dX = (int) (((double) width)*(zoom/2.0)); dY = (int) (((double) height)*(zoom/2.0)); dX2 = (int) (((double) width)*zoom); dY2 = (int) (((double) height)*zoom); } public void zoomDown () { zoom /= zoomAdjust; if (zoom < minZoom) zoom = minZoom; dX = (int) (((double) width)*(zoom/2.0)); dY = (int) (((double) height)*(zoom/2.0)); dX2 = (int) (((double) width)*zoom); dY2 = (int) (((double) height)*zoom); } public GraphicsCommand makeGraphicsCommand () { if (!shiftZoom) { if (zoomX < dX) { zoomX = dX; } else if (zoomX >= (width - dX)) { zoomX = (width - dX) - 1; } if (zoomY < dY) { zoomY = dY; } else if (zoomY >= (height - dY)) { zoomY = (height - dY) - 1; } } return new GraphicsCommand.DrawRect (zoomX - dX, zoomY - dY, dX2, dY2); } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/MandelWorker.java0000644000000000000000000001104211111352066021036 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; /** * @author P.H. Welch */ class MandelWorker implements CSProcess { private final int id; private final int minMaxIterations; private final int maxMaxIterations; private final ChannelInput fromFarmer; private final ChannelOutput toFarmer; private final ChannelInput fromHarvester; private final ChannelOutput toHarvester; public MandelWorker (final int id, final int minMaxIterations, final int maxMaxIterations, final ChannelInput fromFarmer, final ChannelOutput toFarmer, final ChannelInput fromHarvester, final ChannelOutput toHarvester) { this.id = id; this.minMaxIterations = minMaxIterations; this.maxMaxIterations = maxMaxIterations; this.fromFarmer = fromFarmer; this.toFarmer = toFarmer; this.fromHarvester = fromHarvester; this.toHarvester = toHarvester; } public void run () { final int radius = 2; final MandelPoint mandel = new MandelPoint (0, radius); WorkPacket work = new WorkPacket (); ResultPacket result = new ResultPacket (); int count = 0; System.out.println ("Worker " + id + " priority = " + PriParallel.getPriority ()); PriParallel.setPriority (Thread.MIN_PRIORITY); System.out.println ("Worker " + id + " priority = " + PriParallel.getPriority ()); toFarmer.write (work); work = (WorkPacket) fromFarmer.read (); final int nPoints = work.X.length; result.points = new byte[nPoints]; while (true) { count++; if ((count % 100) == 0) System.out.println ("Worker " + id + " working ... " + count ); mandel.setMaxIterations (work.maxIterations); for (int i = 0; i < nPoints; i++) { final int iterations = mandel.compute (work.X[i], work.y); if ((iterations == work.maxIterations) || (iterations == 0)) { result.points[i] = 0; } else { final byte biterations = (byte) iterations; if (biterations == 0) { result.points[i] = 1; // OK for smooth colouring (rough ==> 127 ???) } else { result.points[i] = biterations; } } } result.j = work.j; toHarvester.write (result); // these communication-pairs could be in PAR fromHarvester.read (); toFarmer.write (work); work = (WorkPacket) fromFarmer.read (); Thread.yield (); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/MandelPoint.java0000644000000000000000000000631311111352066020663 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.demos.util.ComplexDouble; /** * @author P.H. Welch */ class MandelPoint { protected int maxIterations; protected double radiusSquared; public MandelPoint (final int maxIterations, final int radius) { this.maxIterations = maxIterations; radiusSquared = (double) radius*radius; } public void setMaxIterations (final int maxIterations) { this.maxIterations = maxIterations; } public int compute (final ComplexDouble c) { int n = 0; ComplexDouble z = (ComplexDouble) c.clone (); double zModulusSquared = z.modulusSquared (); while ((n < maxIterations) && (zModulusSquared < radiusSquared)) { z.mult (z).add (c); zModulusSquared = z.modulusSquared (); n++; } return n; } public int compute (final double a, final double b) { int n = 0; double x = a; double y = b; double xSquared = x*x; double ySquared = y*y; while ((n < maxIterations) && ((xSquared + ySquared) < radiusSquared)) { double tmp = (xSquared - ySquared) + a; y = ((2.0d*x)*y) + b; x = tmp; xSquared = x*x; ySquared = y*y; n++; } return n; } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/MandelPack.java0000644000000000000000000000611011111352066020443 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.awt.*; /** * @author P.H. Welch */ class MandelPack implements Cloneable { public static final int STRIDE_SILENT = 5; public static final int SCROLL_SILENT = 0; public static final int SCROLL_UP = 1; public static final int SCROLL_DOWN = 2; public static final int NO_SCROLL = 3; public int maxIterations, scrolling; public double left, top, size; public GraphicsCommand colouring; public boolean ok; public int[] pixels; public void copy (final MandelPack p) { maxIterations = p.maxIterations; scrolling = p.scrolling; left= p.left; top = p.top; size = p.size; colouring = p.colouring; ok = p.ok; System.arraycopy (p.pixels, 0, pixels, 0, pixels.length); } public Object clone () { try { final MandelPack packet = (MandelPack) super.clone (); packet.pixels = (int[]) pixels.clone (); return packet; } catch (CloneNotSupportedException e) { System.out.println (e); System.exit (-1); return null; } } } jcsp-1.1-rc4.orig/src/jcsp-demos/mandelbrot/WorkPacket.java0000644000000000000000000000422311111352066020521 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// /** * @author P.H. Welch */ class WorkPacket { public double[] X; public double y; public int j, maxIterations; } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/0000755000000000000000000000000011410045041016416 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget1.java0000644000000000000000000000556511111352066023224 0ustar import org.jcsp.lang.*; import java.awt.Color; import java.util.Random; public class AltingBarrierGadget1 implements CSProcess { private final AltingBarrier[] barrier; private final AltingChannelInput in, click; private final ChannelOutput out, configure; private final Color offColour, standbyColour; private final int offInterval, standbyInterval; private final int playInterval, flashInterval; public AltingBarrierGadget1 ( AltingBarrier[] barrier, AltingChannelInput in, ChannelOutput out, AltingChannelInput click, ChannelOutput configure, Color offColour, Color standbyColour, int offInterval, int standbyInterval, int playInterval, int flashInterval ) { this.barrier = barrier; this.in = in; this.out = out; this.click = click; this.configure = configure; this.offColour = offColour; this.standbyColour = standbyColour; this.offInterval = offInterval; this.standbyInterval = standbyInterval; this.playInterval = playInterval; this.flashInterval = flashInterval; } public void run () { CSTimer tim = new CSTimer (); final Random random = new Random (); final Guard[] standbyGuard = new Guard[barrier.length + 1]; for (int i = 0; i < barrier.length; i++) { standbyGuard[i] = barrier[i]; } standbyGuard[barrier.length] = tim; final int TIMEOUT = barrier.length; Alternative standbyAlt = new Alternative (standbyGuard); configure.write (Boolean.FALSE); // disable mouse clicks // (not used by this gadget) while (true) { configure.write (offColour); tim.sleep (random.nextInt (offInterval)); configure.write (standbyColour); tim.setAlarm (tim.read () + random.nextInt (standbyInterval)); int choice = standbyAlt.fairSelect (); // magic synchronisation if (choice != TIMEOUT) { play (choice, random, tim); } } } private void play (int choice, Random random, CSTimer tim) { final boolean RIGHTMOST = (choice == 0); final boolean LEFTMOST = (choice == (barrier.length - 1)); Color colour = null; if (RIGHTMOST) { colour = new Color (random.nextInt ()); } else { colour = (Color) in.read (); } Color brighter = colour.brighter (); if (!LEFTMOST) out.write (colour); // pass it on final AltingBarrier focus = barrier[choice]; final int count = playInterval/flashInterval; long timeout = tim.read () + flashInterval; boolean bright = true; for (int i = 0; i < count; i++) { configure.write (bright ? brighter : colour); bright = !bright; if (RIGHTMOST) { tim.after (timeout); timeout += flashInterval; } focus.sync (); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/Parcel.java0000644000000000000000000000310311111352066020472 0ustar import java.awt.Color; /** * This contains the variables shared by each (synchronised) playing group. * Safe access is assured by Exclusive-Read-Exclusive-Write (EREW) * operation by each gadget. * The parcel is constructed by the rightmost (leader) gadget and * passed up and down the rail track connecting the group. * Only the gadget currently holding the parcel operates on it. * When it passes it on, it lets go the reference. */ public class Parcel { /** * This is incremented by each group member as the parcel passes through. */ public int count; /** * This is set (randomly) by the group leader at the start * of a new game. */ public final Color colour; /** * This is set true by any group member whose * button has been clicked. * It is routed immediately back towards the leader. * The leader gadget informs the rest of the group when it * receives a poisoned parcel (or when it receivesa non-poisoned * parcel but its own button has been clicked). * This (game over) information is passed in the same cycle by * the leader synchronising on the alting barrier that * caused the game to start and on which the others are waiting * (along with channels on which the parcel may arrive). */ public boolean poisoned = false; /** * A parcel is constructed by the (group leader) gadget at * the start of each game. */ public Parcel (Color colour, int count) { this.colour = colour; this.count = count; } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/Util.java0000644000000000000000000000236711111352066020214 0ustar import org.jcsp.lang.Any2OneChannel; import org.jcsp.lang.ChannelInput; import org.jcsp.lang.ChannelOutput; import org.jcsp.lang.One2OneChannel; public class Util { static ChannelInput[][] get2DInputArray(One2OneChannel[][] channels) { ChannelInput[][] ret = new ChannelInput[channels.length][]; for (int i = 0;i < channels.length;i++) { ret[i] = new ChannelInput[channels[i].length]; for (int j = 0;j < channels[i].length;j++) { ret[i][j] = channels[i][j].in(); } } return ret; } static ChannelOutput[][] get2DOutputArray(One2OneChannel[][] channels) { ChannelOutput[][] ret = new ChannelOutput[channels.length][]; for (int i = 0;i < channels.length;i++) { ret[i] = new ChannelOutput[channels[i].length]; for (int j = 0;j < channels[i].length;j++) { ret[i][j] = channels[i][j].out(); } } return ret; } static ChannelOutput[][] get2DOutputArray(Any2OneChannel[][] channels) { ChannelOutput[][] ret = new ChannelOutput[channels.length][]; for (int i = 0;i < channels.length;i++) { ret[i] = new ChannelOutput[channels[i].length]; for (int j = 0;j < channels[i].length;j++) { ret[i][j] = channels[i][j].out(); } } return ret; } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget2.java0000644000000000000000000001152511111352066023216 0ustar import org.jcsp.lang.*; import java.awt.Color; import java.util.Random; public class AltingBarrierGadget2 implements CSProcess { private final AltingBarrier[] barrier; private final AltingChannelInput leftIn, rightIn, click; private final ChannelOutput leftOut, rightOut, configure; private final Color offColour, standbyColour; private final int offInterval, standbyInterval, playInterval; public AltingBarrierGadget2 ( AltingBarrier[] barrier, AltingChannelInput leftIn, ChannelOutput leftOut, AltingChannelInput rightIn, ChannelOutput rightOut, AltingChannelInput click, ChannelOutput configure, Color offColour, Color standbyColour, int offInterval, int standbyInterval, int playInterval ) { this.barrier = barrier; this.leftIn = leftIn; this.leftOut = leftOut; this.rightIn = rightIn; this.rightOut = rightOut; this.click = click; this.configure = configure; this.offColour = offColour; this.standbyColour = standbyColour; this.offInterval = offInterval; this.standbyInterval = standbyInterval; this.playInterval = playInterval; } public void run () { CSTimer tim = new CSTimer (); final Random random = new Random (); final Guard[] standbyGuard = new Guard[barrier.length + 1]; for (int i = 0; i < barrier.length; i++) { standbyGuard[i] = barrier[i]; } standbyGuard[barrier.length] = tim; final int TIMEOUT = barrier.length; Alternative standbyAlt = new Alternative (standbyGuard); configure.write (Boolean.FALSE); // disable mouse clicks while (true) { configure.write (offColour); tim.sleep (random.nextInt (offInterval)); configure.write (standbyColour); tim.setAlarm (tim.read () + random.nextInt (standbyInterval)); int choice = standbyAlt.fairSelect (); // magic synchronisation if (choice != TIMEOUT) { play (choice, random, tim); } } } private void play (int choice, Random random, CSTimer tim) { final boolean RIGHTMOST = (choice == 0); final boolean LEFTMOST = (choice == (barrier.length - 1)); Parcel parcel = null; if (RIGHTMOST) { parcel = new Parcel (new Color (random.nextInt ()), 0); } else { parcel = (Parcel) rightIn.read (); } configure.write (parcel.colour); configure.write (String.valueOf (parcel.count)); while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks parcel.count++; if (LEFTMOST) { rightOut.write (parcel); // bounce } else { leftOut.write (parcel); // forward } parcel = null; final Guard[] playGuard = {click, tim, leftIn, rightIn, barrier[choice]}; final int CLICK = 0, TIMEOUT = 1, LEFT = 2, RIGHT = 3, BARRIER = 4; final Alternative playAlt = new Alternative (playGuard);; final boolean[] playCondition = {true, RIGHTMOST, true, true, !RIGHTMOST}; if (RIGHTMOST) tim.setAlarm (tim.read () + playInterval); boolean stopping = false; boolean playing = true; while (playing) { switch (playAlt.priSelect (playCondition)) { case CLICK: click.read (); stopping = true; break; case TIMEOUT: // only RIGHTMOST sets a timeout stopping = true; playCondition[TIMEOUT] = false; // disable timeout (only taken once) break; case LEFT: parcel = (Parcel) leftIn.read (); if (parcel.poisoned) stopping = true; if (stopping) { if (RIGHTMOST) { barrier[choice].sync (); // make everyone stop playing = false; // we have the parcel } else { parcel.poisoned = true; rightOut.write (parcel); // forward } } else { configure.write (String.valueOf (parcel.count)); parcel.count++; if (RIGHTMOST) { leftOut.write (parcel); // bounce } else { rightOut.write (parcel); // forward } parcel = null; } break; case RIGHT: parcel = (Parcel) rightIn.read (); if (stopping) { parcel.poisoned = true; rightOut.write (parcel); // bounce } else { configure.write (String.valueOf (parcel.count)); parcel.count++; if (LEFTMOST) { rightOut.write (parcel); // bounce } else { leftOut.write (parcel); // forward } } parcel = null; break; case BARRIER: // RIGHTMOST => not possible playing = false; break; } } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget2Demo0.java0000644000000000000000000000516611111352066024107 0ustar import org.jcsp.demos.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.Color; public class AltingBarrierGadget2Demo0 { public static void main (String[] argv) { // final int nUnits = 30, span = 6; // // final int offInterval = 800, standbyInterval = 1000; // milliseconds // final int playInterval = 10000; // milliseconds final int nUnits = Ask.Int ("\nnUnits = ", 3, 30); final int span = Ask.Int ("span = ", 2, nUnits); final int offInterval = Ask.Int ("off interval (millisecs) = ", 100, 10000); final int standbyInterval = Ask.Int ("standby interval (millisecs) = ", 100, 20000); final int playInterval = Ask.Int ("play interval (millisecs) = ", 1000, 1000000000); final Color offColour = Color.black, standbyColour = Color.lightGray; // make the buttons final One2OneChannel[] click = Channel.one2oneArray (nUnits, new OverWriteOldestBuffer (1)); final One2OneChannel[] configure = Channel.one2oneArray (nUnits); final boolean horizontal = true; final FramedButtonArray buttons = new FramedButtonArray ( "AltingBarrier: Gadget 2, Demo 0", nUnits, 100, nUnits*50, horizontal, Channel.getInputArray(configure), Channel.getOutputArray(click) ); // construct nUnits barriers, each with span front-ends ... AltingBarrier[][] ab = new AltingBarrier[nUnits][]; for (int i = 0; i < nUnits; i++) { ab[i] = AltingBarrier.create (span); } // re-arrange front-ends, ready for distribution to processes ... AltingBarrier[][]barrier = new AltingBarrier[nUnits][span]; for (int i = 0; i < nUnits; i++) { for (int j = 0; j < span; j++) { barrier[i][j] = ab[(i + j) % nUnits][j]; } } // make the track and the gadgets One2OneChannel[] forwards = Channel.one2oneArray (nUnits); One2OneChannel[] backwards = Channel.one2oneArray (nUnits); AltingBarrierGadget2[] gadgets = new AltingBarrierGadget2[nUnits]; for (int i = 0; i < nUnits; i++) { gadgets[i] = new AltingBarrierGadget2 ( barrier[i], forwards[i].in(), backwards[i].out(), backwards[(i + 1)%nUnits].in(), forwards[(i + 1)%nUnits].out(), click[i].in(), configure[i].out(), offColour, standbyColour, offInterval, standbyInterval, playInterval ); } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget0Demo0.java0000644000000000000000000000236311111352066024101 0ustar import org.jcsp.demos.util.*; import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class AltingBarrierGadget0Demo0 { public static void main (String[] argv) { // final int nUnits = 8; final int nUnits = Ask.Int ("\nnUnits = ", 3, 10); // make the buttons final One2OneChannel[] event = Channel.one2oneArray(nUnits); final One2OneChannel[] configure = Channel.one2oneArray (nUnits); final boolean horizontal = true; final FramedButtonArray buttons = new FramedButtonArray ( "AltingBarrier: Gadget 0, Demo 0", nUnits, 120, nUnits*100, horizontal, Channel.getInputArray(configure), Channel.getOutputArray(event) ); // construct an array of front-ends to a single alting barrier final AltingBarrier[] group = AltingBarrier.create (nUnits); // make the gadgets final AltingBarrierGadget0[] gadgets = new AltingBarrierGadget0[nUnits]; for (int i = 0; i < gadgets.length; i++) { gadgets[i] = new AltingBarrierGadget0 (event[i].in(), group[i], configure[i].out()); } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget2Demo1.java0000644000000000000000000000563511111352066024111 0ustar import org.jcsp.demos.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.Color; public class AltingBarrierGadget2Demo1 { public static void main (String[] argv) { // final int width = 20, depth = 15; // // final int span = 6; // // final int offInterval = 800, standbyInterval = 10000; // milliseconds // final int playInterval = 10000 // milliseconds final int width = Ask.Int ("\nwidth = ", 10, 30); final int depth = Ask.Int ("depth = ", 1, 30); final int nUnits = width*depth; final int span = Ask.Int ("span = ", 2, width); final int offInterval = Ask.Int ("off interval (millisecs) = ", 100, 10000); final int standbyInterval = Ask.Int ("standby interval (millisecs) = ", 100, 20000); final int playInterval = Ask.Int ("play interval (millisecs) = ", 1000, 1000000000); final Color offColour = Color.black, standbyColour = Color.lightGray; // make the buttons final One2OneChannel[][] click = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { click[i] = Channel.one2oneArray (width, new OverWriteOldestBuffer (1)); } final One2OneChannel[][] configure = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { configure[i] = Channel.one2oneArray (width); } final FramedButtonGrid buttons = new FramedButtonGrid ( "AltingBarrier: Gadget 2, Demo 1", depth, width, 20 + (depth*50), width*50, Util.get2DInputArray(configure), Util.get2DOutputArray(click) ); // construct nUnits barriers, each with span front-ends ... AltingBarrier[][] ab = new AltingBarrier[nUnits][]; for (int i = 0; i < nUnits; i++) { ab[i] = AltingBarrier.create (span); } // re-arrange front-ends, ready for distribution to processes ... AltingBarrier[][]barrier = new AltingBarrier[nUnits][span]; for (int i = 0; i < nUnits; i++) { for (int j = 0; j < span; j++) { barrier[i][j] = ab[(i + j) % nUnits][j]; } } // make the track and the gadgets One2OneChannel[] forwards = Channel.one2oneArray (nUnits); One2OneChannel[] backwards = Channel.one2oneArray (nUnits); AltingBarrierGadget2[] gadgets = new AltingBarrierGadget2[nUnits]; for (int i = 0; i < nUnits; i++) { gadgets[i] = new AltingBarrierGadget2 ( barrier[i], forwards[i].in(), backwards[i].out(), backwards[(i + 1)%nUnits].in(), forwards[(i + 1)%nUnits].out(), click[i/width][i%width].in(), configure[i/width][i%width].out(), offColour, standbyColour, offInterval, standbyInterval, playInterval ); } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget5Demo0.java0000644000000000000000000001244111111352066024104 0ustar import org.jcsp.demos.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.Color; import java.util.Random; public class AltingBarrierGadget5Demo0 { public static void main (String[] argv) { final int width = Ask.Int ("\nwidth = ", 10, 30); final int depth = Ask.Int ("depth = ", 1, 30); final int span = Ask.Int ("length of arms = ", 1, width/2); final int offInterval = Ask.Int ("off interval (millisecs) = ", 100, 10000); final int standbyInterval = Ask.Int ("standby interval (millisecs) = ", 100, 20000); final int playInterval = Ask.Int ("play interval (millisecs) = ", 1000, 1000000000); final int countInterval = Ask.Int ("count interval (millisecs) = ", 10, 10000); final Color offColour = Color.black, standbyColour = Color.lightGray; // make the buttons final One2OneChannel[][] click = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { click[i] = Channel.one2oneArray (width, new OverWriteOldestBuffer (1)); } final One2OneChannel[][] configure = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { configure[i] = Channel.one2oneArray (width); } final FramedButtonGrid buttons = new FramedButtonGrid ( "AltingBarier: Gadget 5, Demo 0", depth, width, 20 + (depth*50), width*50, Util.get2DInputArray(configure), Util.get2DOutputArray(click) ); // make labels for the buttons (read-only shared by all the gadgets) final String[] label = new String[playInterval/countInterval]; for (int i = 0; i < label.length; i++) { label[i] = String.valueOf (i); } // make the gadgets final Any2OneChannel[][] connect = new Any2OneChannel [depth][]; for (int row = 0; row < depth; row++) { connect[row] = Channel.any2oneArray (width); } final Random random = new Random (); final AltingBarrier[] bar = AltingBarrier.create (width*depth); final AltingBarrierGadget5[][] gadgets = new AltingBarrierGadget5[depth][width]; for (int row = 0; row < depth; row++) { for (int col = 0; col < width; col++) { gadgets[row][col] = new AltingBarrierGadget5 ( connect[row][col].in(), shape (random, row, col, span, Util.get2DOutputArray(connect)), bar[(row*width) + col], click[row][col].in(), configure[row][col].out(), offColour, standbyColour, offInterval, standbyInterval, playInterval, countInterval, label ); } } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } static ChannelOutput[] shape ( Random random, int row, int col, int span, ChannelOutput[][] connect ) { switch (random.nextInt (3)) { case 0: return shapePlus (row, col, span, connect); case 1: return shapeCross (row, col, span, connect); case 2: return shapeCircle (row, col, span, connect); default: return null; } } static ChannelOutput[] shapePlus ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = 4*span; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 1; i <= span; i++) { collect[index] = get (connect, row-i, col); index++; collect[index] = get (connect, row, col+i); index++; collect[index] = get (connect, row+i, col); index++; collect[index] = get (connect, row, col-i); index++; } return collect; } static ChannelOutput[] shapeCross ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = 4*span; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 1; i <= span; i++) { collect[index] = get (connect, row-i, col-i); index++; collect[index] = get (connect, row-i, col+i); index++; collect[index] = get (connect, row+i, col-i); index++; collect[index] = get (connect, row+i, col+i); index++; } return collect; } static ChannelOutput[] shapeCircle ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = (4*span) - 1; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 0; i < (span - 1); i ++) { col++; collect[index] = get (connect, row, col); index++; } col++; for (int i = 0; i < span; i++) { row--; collect[index] = get (connect, row, col); index++; } row--; for (int i = 0; i < span; i++) { col--; collect[index] = get (connect, row, col); index++; } col--; for (int i = 0; i < span; i++) { row++; collect[index] = get (connect, row, col); index++; } return collect; } static ChannelOutput get (ChannelOutput[][] connect, int row, int col) { final int depth = connect.length; row = (row + depth)%depth; final int width = connect[row].length; col = (col + width)%width; return connect[row][col]; } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget4Demo0.java0000644000000000000000000001237611111352066024112 0ustar import org.jcsp.demos.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.Color; import java.util.Random; public class AltingBarrierGadget4Demo0 { public static void main (String[] argv) { final int width = Ask.Int ("\nwidth = ", 10, 30); final int depth = Ask.Int ("depth = ", 1, 30); final int span = Ask.Int ("length of arms = ", 1, width/2); final int offInterval = Ask.Int ("off interval (millisecs) = ", 100, 10000); final int standbyInterval = Ask.Int ("standby interval (millisecs) = ", 100, 20000); final int playInterval = Ask.Int ("play interval (millisecs) = ", 1000, 1000000000); final int countInterval = Ask.Int ("count interval (millisecs) = ", 10, 10000); final Color offColour = Color.black, standbyColour = Color.lightGray; // make the buttons final One2OneChannel[][] click = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { click[i] = Channel.one2oneArray (width, new OverWriteOldestBuffer (1)); } final One2OneChannel[][] configure = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { configure[i] = Channel.one2oneArray (width); } final FramedButtonGrid buttons = new FramedButtonGrid ( "AltingBarier: Gadget 4, Demo 0", depth, width, 20 + (depth*50), width*50, Util.get2DInputArray(configure), Util.get2DOutputArray(click) ); // make labels for the buttons (read-only shared by all the gadgets) final String[] label = new String[playInterval/countInterval]; for (int i = 0; i < label.length; i++) { label[i] = String.valueOf (i); } // make the gadgets final Any2OneChannel[][] connect = new Any2OneChannel [depth][]; for (int row = 0; row < depth; row++) { connect[row] = Channel.any2oneArray (width); } final Random random = new Random (); final Barrier bar = new Barrier (width*depth); final AltingBarrierGadget4[][] gadgets = new AltingBarrierGadget4[depth][width]; for (int row = 0; row < depth; row++) { for (int col = 0; col < width; col++) { gadgets[row][col] = new AltingBarrierGadget4 ( connect[row][col].in(), shape (random, row, col, span, Util.get2DOutputArray(connect)), bar, click[row][col].in(), configure[row][col].out(), offColour, standbyColour, offInterval, standbyInterval, playInterval, countInterval, label ); } } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } static ChannelOutput[] shape ( Random random, int row, int col, int span, ChannelOutput[][] connect ) { switch (random.nextInt (3)) { case 0: return shapePlus (row, col, span, connect); case 1: return shapeCross (row, col, span, connect); case 2: return shapeCircle (row, col, span, connect); default: return null; } } static ChannelOutput[] shapePlus ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = 4*span; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 1; i <= span; i++) { collect[index] = get (connect, row-i, col); index++; collect[index] = get (connect, row, col+i); index++; collect[index] = get (connect, row+i, col); index++; collect[index] = get (connect, row, col-i); index++; } return collect; } static ChannelOutput[] shapeCross ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = 4*span; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 1; i <= span; i++) { collect[index] = get (connect, row-i, col-i); index++; collect[index] = get (connect, row-i, col+i); index++; collect[index] = get (connect, row+i, col-i); index++; collect[index] = get (connect, row+i, col+i); index++; } return collect; } static ChannelOutput[] shapeCircle ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = (4*span) - 1; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 0; i < (span - 1); i ++) { col++; collect[index] = get (connect, row, col); index++; } col++; for (int i = 0; i < span; i++) { row--; collect[index] = get (connect, row, col); index++; } row--; for (int i = 0; i < span; i++) { col--; collect[index] = get (connect, row, col); index++; } col--; for (int i = 0; i < span; i++) { row++; collect[index] = get (connect, row, col); index++; } return collect; } static ChannelOutput get (ChannelOutput[][] connect, int row, int col) { final int depth = connect.length; row = (row + depth)%depth; final int width = connect[row].length; col = (col + width)%width; return connect[row][col]; } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget3Demo0.java0000644000000000000000000001305611111352066024105 0ustar import org.jcsp.demos.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.Color; public class AltingBarrierGadget3Demo0 { static final int PLUS = 0; static final int CROSS = 1; static final int CIRCLE = 2; public static void main (String[] argv) { final int width = Ask.Int ("\nwidth = ", 10, 30); final int depth = Ask.Int ("depth = ", 1, 30); final int kind = Ask.Int ("shape (0 = plus, 1 = cross, 2 = circle): ", PLUS, CIRCLE); int span = 0; switch (kind) { case PLUS: span = Ask.Int ("length of arms = ", 1, width/2); break; case CROSS: span = Ask.Int ("length of arms = ", 1, width/2); break; case CIRCLE: span = Ask.Int ("radius = ", 1, width/2); break; } final int offInterval = Ask.Int ("off interval (millisecs) = ", 100, 10000); final int standbyInterval = Ask.Int ("standby interval (millisecs) = ", 100, 20000); final int playInterval = Ask.Int ("play interval (millisecs) = ", 1000, 1000000000); final int countInterval = Ask.Int ("count interval (millisecs) = ", 10, 10000); final Color offColour = Color.black, standbyColour = Color.lightGray; // make the buttons final One2OneChannel[][] click = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { click[i] = Channel.one2oneArray (width, new OverWriteOldestBuffer (1)); } final One2OneChannel[][] configure = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { configure[i] = Channel.one2oneArray (width); } final FramedButtonGrid buttons = new FramedButtonGrid ( "AltingBarier: Gadget 3, Demo 0", depth, width, 20 + (depth*50), width*50, Util.get2DInputArray(configure), Util.get2DOutputArray(click) ); // make labels for the buttons (read-only shared by all the gadgets) final String[] label = new String[playInterval/countInterval]; for (int i = 0; i < label.length; i++) { label[i] = String.valueOf (i); } // make the gadgets final Any2OneChannel[][] connect = new Any2OneChannel [depth][]; for (int row = 0; row < depth; row++) { connect[row] = Channel.any2oneArray (width); } final AltingBarrierGadget3[][] gadgets = new AltingBarrierGadget3[depth][width]; for (int row = 0; row < depth; row++) { for (int col = 0; col < width; col++) { gadgets[row][col] = new AltingBarrierGadget3 ( connect[row][col].in(), shape (kind, row, col, span, Util.get2DOutputArray(connect)), click[row][col].in(), configure[row][col].out(), offColour, standbyColour, offInterval, standbyInterval, playInterval, countInterval, label ); } } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } static ChannelOutput[] shape ( int kind, int row, int col, int span, ChannelOutput[][] connect ) { switch (kind) { case PLUS: return shapePlus (row, col, span, connect); case CROSS: return shapeCross (row, col, span, connect); case CIRCLE: return shapeCircle (row, col, span, connect); default: return null; } } static ChannelOutput[] shapePlus ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = 4*span; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 1; i <= span; i++) { collect[index] = get (connect, row-i, col); index++; collect[index] = get (connect, row, col+i); index++; collect[index] = get (connect, row+i, col); index++; collect[index] = get (connect, row, col-i); index++; } return collect; } static ChannelOutput[] shapeCross ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = 4*span; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 1; i <= span; i++) { collect[index] = get (connect, row-i, col-i); index++; collect[index] = get (connect, row-i, col+i); index++; collect[index] = get (connect, row+i, col-i); index++; collect[index] = get (connect, row+i, col+i); index++; } return collect; } static ChannelOutput[] shapeCircle ( int row, int col, int span, ChannelOutput[][] connect ) { final int n = (4*span) - 1; final ChannelOutput[] collect = new ChannelOutput[n]; int index = 0; for (int i = 0; i < (span - 1); i ++) { col++; collect[index] = get (connect, row, col); index++; } col++; for (int i = 0; i < span; i++) { row--; collect[index] = get (connect, row, col); index++; } row--; for (int i = 0; i < span; i++) { col--; collect[index] = get (connect, row, col); index++; } col--; for (int i = 0; i < span; i++) { row++; collect[index] = get (connect, row, col); index++; } return collect; } static ChannelOutput get (ChannelOutput[][] connect, int row, int col) { final int depth = connect.length; row = (row + depth)%depth; final int width = connect[row].length; col = (col + width)%width; return connect[row][col]; } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/Shared.java0000644000000000000000000000444211111352066020501 0ustar import org.jcsp.lang.*; import java.awt.Color; /** * This contains the variables shared by each (synchronised) playing group. * Safe access is assured by phased barrier synchronisation honoured * by the group, ensuring Concurrent-Read-Exclusive-Write (CREW) * behaviour for each phase. In fact, a relaxed, but still safe, * extension to CREW is honoured: concurrent writes of the same value * are allowed to one of the fields (the game termination flag, {@link ok}) * during the update phases. *

* {@link #toLeader} gives a channel back to the leader, used by the other * group members to cancel the leader's timeout should they want to end * the game -- it is set just the once by the constructer. It must be an * any-1 channel and overwriting buffered. It is used only * during an update phase. *

*

* The other field values may be used during read phases by all players. * {@link #colour} and {@link #brighter} are defined by the leader at * start of each game. {@link label} is changed by the leader during * update phases. {@link ok} is originally set true by * the leader, but may be set false by any group member * during any update phase. *

*/ public class Shared { /** * This is set true by the group leader * at the start of a new game. It may be safely set * false by any member of the group * (so long as this is during a parcel update phase). */ public boolean ok = false; /** * This is set (randomly) by the group leader at the start * of a new game. */ public Color colour = null; /** * This is set by the group leader at the start * of a new game. */ public Color brighter = null; /** * This is set by the group leader at the start of a new game * and updated during the game (in parcel update phases). */ public String label = null; /** * This is set once by the (group leader) gadget * when this parcel is constructed. */ public final ChannelOutput toLeader; /** * This parcel is constructed by the (group leader) gadget. */ public Shared (ChannelOutput toLeader) { this.toLeader = toLeader; } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget3.java0000644000000000000000000001604511111352066023221 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import java.awt.Color; import java.util.Random; public class AltingBarrierGadget3 implements CSProcess { private final ChannelInput in; private final ChannelOutput[] out; private final AltingChannelInput click; private final ChannelOutput configure; private final Color offColour, standbyColour; private final int offInterval, standbyInterval; private final int playInterval, countInterval; private final String[] label; public AltingBarrierGadget3 ( ChannelInput in, ChannelOutput[] out, AltingChannelInput click, ChannelOutput configure, Color offColour, Color standbyColour, int offInterval, int standbyInterval, int playInterval, int countInterval, String[] label ) { this.in = in; this.out = out; this.click = click; this.configure = configure; this.offColour = offColour; this.standbyColour = standbyColour; this.offInterval = offInterval; this.standbyInterval = standbyInterval; this.playInterval = playInterval; this.countInterval = countInterval; this.label = label; } public void run () { CSTimer tim = new CSTimer (); final Random random = new Random (); // make alting barrier and shared variables // for the group this gadget is leading ... final AltingBarrier[] myAltingBarrier = AltingBarrier.create (out.length + 1); final Any2OneChannel myChannel = Channel.any2one(new OverWritingBuffer (1)); final Shared myShared = new Shared (myChannel.out()); // make receiving arrays for the barrier and shared variables // from the other group leaders final Guard[] standbyGuard = new Guard[out.length + 2]; final int MY_INDEX = out.length; standbyGuard[MY_INDEX] = myAltingBarrier[MY_INDEX]; final int TIMEOUT = out.length + 1; standbyGuard[TIMEOUT] = tim; final Shared[] shared = new Shared[out.length + 1]; shared[MY_INDEX] = myShared; // parallel-I/O distribution of barriers and shared variables new Parallel ( new CSProcess[] { new CSProcess () { public void run () { for (int i = 0; i < out.length; i++) { synchronized (out[i]) { out[i].write (myAltingBarrier[i]); out[i].write (myShared); } } } }, new CSProcess () { public void run () { for (int i = 0; i < out.length; i++) { standbyGuard[i] = (AltingBarrier) in.read (); shared[i] = (Shared) in.read (); } } } } ).run (); // start real work ... Alternative standbyAlt = new Alternative (standbyGuard); configure.write (Boolean.FALSE); // disable mouse clicks while (true) { configure.write (offColour); tim.sleep (random.nextInt (offInterval)); configure.write (standbyColour); tim.setAlarm (tim.read () + random.nextInt (standbyInterval)); int choice = standbyAlt.fairSelect (); // magic synchronisation if (choice == MY_INDEX) { playLeader ( (AltingBarrier) standbyGuard[choice], shared[choice], myChannel.in(), random, tim ); } else if (choice != TIMEOUT) { play ((AltingBarrier) standbyGuard[choice], shared[choice]); } } } private void playLeader ( AltingBarrier bar, Shared shared, AltingChannelInput myChannel, Random random, CSTimer tim ) { while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks while (myChannel.pending ()) myChannel.read (); // clear any buffered cancels int count = 0; long countTimeout = 0; Alternative leaderAlt = new Alternative (new Guard[] {click, myChannel, tim}); final int CLICK = 0, CANCEL = 1, TIM = 2; count = (playInterval/countInterval) - 1; shared.ok = (count >= 0); // initialise shared variables shared.label = label[count]; shared.colour = new Color (random.nextInt ()); shared.brighter = shared.colour.brighter (); bar.sync (); // allow inspection of shared variables boolean bright = true; countTimeout = tim.read () + countInterval; // set first timeout tim.setAlarm (countTimeout); while (shared.ok) { configure.write (bright ? shared.brighter : shared.colour); bright = !bright; configure.write (shared.label); bar.sync (); // allow update of shared variables count--; if (count < 0) { shared.ok = false; // game over } else { shared.label = label[count]; } switch (leaderAlt.priSelect ()) { case CLICK: // our button clicked click.read (); shared.ok = false; // game over break; case CANCEL: // someone else's button clicked myChannel.read (); // (they will have set shared.ok) break; case TIM: // timeout - move on countTimeout += countInterval; tim.setAlarm (countTimeout); break; } bar.sync (); // allow inspection of shared variables } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } private void play (AltingBarrier bar, Shared shared) { while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks Alternative followerAlt = new Alternative (new Guard[] {click, bar}); final int CLICK = 0, BAR = 1; bar.sync (); // allow inspection of shared variables boolean bright = true; while (shared.ok) { configure.write (bright ? shared.brighter : shared.colour); bright = !bright; configure.write (shared.label); bar.sync (); // allow update of shared variables switch (followerAlt.priSelect ()) { case CLICK: // our button clicked click.read (); shared.toLeader.write (null); // cancel leader timeout (if any) shared.ok = false; // game over (we must set this) bar.sync (); // allow inspection of shared variables break; case BAR: // allow inspection of shared variables break; } } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget1Demo1.java0000644000000000000000000000562611111352066024110 0ustar import org.jcsp.demos.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.Color; public class AltingBarrierGadget1Demo1 { public static void main (String[] argv) { // final int width = 30, depth = 20; // // final int span = 6; // // final int offInterval = 800, standbyInterval = 1000; // milliseconds // // final int playInterval = 5000, flashInterval = 500; // milliseconds final int width = Ask.Int ("\nwidth = ", 10, 30); final int depth = Ask.Int ("depth = ", 1, 30); final int nUnits = width*depth; final int span = Ask.Int ("span = ", 2, width); final int offInterval = Ask.Int ("off interval (millisecs) = ", 100, 10000); final int standbyInterval = Ask.Int ("standby interval (millisecs) = ", 100, 20000); final int playInterval = Ask.Int ("play interval (millisecs) = ", 1000, 1000000000); final int flashInterval = Ask.Int ("flash interval (millisecs) = ", 50, 500); final Color offColour = Color.black, standbyColour = Color.lightGray; // make the buttons final One2OneChannel[][] click = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { click[i] = Channel.one2oneArray (width, new OverWriteOldestBuffer (1)); } final One2OneChannel[][] configure = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { configure[i] = Channel.one2oneArray (width); } final FramedButtonGrid buttons = new FramedButtonGrid ( "AltingBarrier: Gadget 1, Demo 1", depth, width, 20 + (depth*50), width*50, Util.get2DInputArray(configure), Util.get2DOutputArray(click) ); // construct nUnits barriers, each with span front-ends ... AltingBarrier[][] ab = new AltingBarrier[nUnits][]; for (int i = 0; i < nUnits; i++) { ab[i] = AltingBarrier.create (span); } // re-arrange front-ends, ready for distribution to processes ... AltingBarrier[][]barrier = new AltingBarrier[nUnits][span]; for (int i = 0; i < nUnits; i++) { for (int j = 0; j < span; j++) { barrier[i][j] = ab[(i + j) % nUnits][j]; } } // make the track and the gadgets One2OneChannel[] track = Channel.one2oneArray (nUnits); AltingBarrierGadget1[] gadgets = new AltingBarrierGadget1[nUnits]; for (int i = 0; i < nUnits; i++) { gadgets[i] = new AltingBarrierGadget1 ( barrier[i], track[(i + 1)%nUnits].in(), track[i].out(), click[i/width][i%width].in(), configure[i/width][i%width].out(), offColour, standbyColour, offInterval, standbyInterval, playInterval, flashInterval ); } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget6.java0000644000000000000000000001606211111352066023223 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import java.awt.Color; import java.util.*; public class AltingBarrierGadget6 implements CSProcess { private final ArrayList in; private final ArrayList[] out; private final Barrier bar; private final AltingChannelInput click; private final ChannelOutput configure; private final Color offColour, standbyColour; private final int offInterval, standbyInterval; private final int playInterval, countInterval; private final String[] label; public AltingBarrierGadget6 ( ArrayList in, ArrayList[] out, Barrier bar, AltingChannelInput click, ChannelOutput configure, Color offColour, Color standbyColour, int offInterval, int standbyInterval, int playInterval, int countInterval, String[] label ) { this.in = in; this.out = out; this.bar = bar; this.click = click; this.configure = configure; this.offColour = offColour; this.standbyColour = standbyColour; this.offInterval = offInterval; this.standbyInterval = standbyInterval; this.playInterval = playInterval; this.countInterval = countInterval; this.label = label; } public void run () { CSTimer tim = new CSTimer (); final Random random = new Random (); // make alting barrier and shared variables // for the group this gadget is leading ... final AltingBarrier[] myAltingBarrier = AltingBarrier.create (out.length + 1); final Any2OneChannel myChannel = Channel.any2one (new OverWritingBuffer (1)); final Shared myShared = new Shared (myChannel.out()); // distribute barriers and shared variables: send phase ... for (int i = 0; i < out.length; i++) { synchronized (out[i]) { out[i].add (myAltingBarrier[i]); out[i].add (myShared); } } // wait for all gadgets to finish output bar.sync (); // distribute barriers and shared variables: collection phase ... final int count = (in.size () / 2); final Guard[] standbyGuard = new Guard[count + 2]; final int MY_INDEX = count; standbyGuard[MY_INDEX] = myAltingBarrier[out.length]; final int TIMEOUT = count + 1; standbyGuard[TIMEOUT] = tim; final Shared[] shared = new Shared[count + 1]; shared[MY_INDEX] = myShared; Iterator iterator = in.iterator (); for (int i = 0; i < count; i++) { standbyGuard[i] = (AltingBarrier) iterator.next (); shared[i] = (Shared) iterator.next (); } iterator = null; // discard no longer needed item // start real work ... Alternative standbyAlt = new Alternative (standbyGuard); configure.write (Boolean.FALSE); // disable mouse clicks while (true) { configure.write (offColour); tim.sleep (random.nextInt (offInterval)); configure.write (standbyColour); tim.setAlarm (tim.read () + random.nextInt (standbyInterval)); int choice = standbyAlt.fairSelect (); // magic synchronisation if (choice == MY_INDEX) { playLeader ( (AltingBarrier) standbyGuard[choice], shared[choice], myChannel.in(), random, tim ); } else if (choice != TIMEOUT) { play ((AltingBarrier) standbyGuard[choice], shared[choice]); } } } private void playLeader ( AltingBarrier bar, Shared shared, AltingChannelInput myChannel, Random random, CSTimer tim ) { while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks while (myChannel.pending ()) myChannel.read (); // clear any buffered cancels int count = 0; long countTimeout = 0; Alternative leaderAlt = new Alternative (new Guard[] {click, myChannel, tim}); final int CLICK = 0, CANCEL = 1, TIM = 2; count = (playInterval/countInterval) - 1; shared.ok = (count >= 0); // initialise shared variables shared.label = label[count]; shared.colour = new Color (random.nextInt (16777216)); shared.brighter = shared.colour.brighter (); bar.sync (); // allow inspection of shared variables boolean bright = true; countTimeout = tim.read () + countInterval; // set first timeout tim.setAlarm (countTimeout); while (shared.ok) { configure.write (bright ? shared.brighter : shared.colour); bright = !bright; configure.write (shared.label); bar.sync (); // allow update of shared variables count--; if (count < 0) { shared.ok = false; // game over } else { shared.label = label[count]; } switch (leaderAlt.priSelect ()) { case CLICK: // our button clicked click.read (); shared.ok = false; // game over break; case CANCEL: // someone else's button clicked myChannel.read (); // (they will have set shared.ok) break; case TIM: // timeout - move on countTimeout += countInterval; tim.setAlarm (countTimeout); break; } bar.sync (); // allow inspection of shared variables } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } private void play (AltingBarrier bar, Shared shared) { while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks Alternative followerAlt = new Alternative (new Guard[] {click, bar}); final int CLICK = 0, BAR = 1; bar.sync (); // allow inspection of shared variables boolean bright = true; while (shared.ok) { configure.write (bright ? shared.brighter : shared.colour); bright = !bright; configure.write (shared.label); bar.sync (); // allow update of shared variables switch (followerAlt.priSelect ()) { case CLICK: // our button clicked click.read (); shared.toLeader.write (null); // cancel leader timeout (if any) shared.ok = false; // game over (we must set this) bar.sync (); // allow inspection of shared variables break; case BAR: // allow inspection of shared variables break; } } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget4.java0000644000000000000000000002032011111352066023211 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import java.awt.Color; import java.util.*; public class AltingBarrierGadget4 implements CSProcess { private final AltingChannelInput in; private final ChannelOutput[] out; private final Barrier bar; private final AltingChannelInput click; private final ChannelOutput configure; private final Color offColour, standbyColour; private final int offInterval, standbyInterval; private final int playInterval, countInterval; private final String[] label; public AltingBarrierGadget4 ( AltingChannelInput in, ChannelOutput[] out, Barrier bar, AltingChannelInput click, ChannelOutput configure, Color offColour, Color standbyColour, int offInterval, int standbyInterval, int playInterval, int countInterval, String[] label ) { this.in = in; this.out = out; this.bar = bar; this.click = click; this.configure = configure; this.offColour = offColour; this.standbyColour = standbyColour; this.offInterval = offInterval; this.standbyInterval = standbyInterval; this.playInterval = playInterval; this.countInterval = countInterval; this.label = label; } public void run () { CSTimer tim = new CSTimer (); final Random random = new Random (); // make alting barrier and shared variables // for the group this gadget is leading ... final AltingBarrier[] myAltingBarrier = AltingBarrier.create (out.length + 1); final Any2OneChannel myChannel = Channel.any2one (new OverWritingBuffer (1)); final Shared myShared = new Shared (myChannel.out()); // parallel-I/O distribution of barriers and shared variables final One2OneChannel finished = Channel.one2one (); // used only once new ProcessManager ( new CSProcess () { public void run () { for (int i = 0; i < out.length; i++) { synchronized (out[i]) { out[i].write (myAltingBarrier[i]); out[i].write (myShared); } } bar.sync (); // wait for all gadgets to finish output finished.out().write (null); // inform this gadget } } ).start (); ArrayList dump = // temporary storage new ArrayList (2*out.length); // (guessed initial size) Alternative distributeAlt = new Alternative (new Guard[] {in, finished.in()}); final int IN = 0, FINISHED = 1; int count = 0; boolean more = true; while (more) { switch (distributeAlt.priSelect ()) { case IN: dump.add (in.read ()); // an AltingBarrier dump.add (in.read ()); // Shared variables count++; break; case FINISHED: finished.in().read (); more = false; break; } } distributeAlt = null; // discard no longer needed item // make receiving arrays for the barrier and shared variables // from the other group leaders final Guard[] standbyGuard = new Guard[count + 2]; final int MY_INDEX = count; standbyGuard[MY_INDEX] = myAltingBarrier[out.length]; final int TIMEOUT = count + 1; standbyGuard[TIMEOUT] = tim; final Shared[] shared = new Shared[count + 1]; shared[MY_INDEX] = myShared; Iterator iterator = dump.iterator (); for (int i = 0; i < count; i++) { standbyGuard[i] = (AltingBarrier) iterator.next (); shared[i] = (Shared) iterator.next (); } iterator = null; // discard no longer needed item dump = null; // discard no longer needed item // start real work ... Alternative standbyAlt = new Alternative (standbyGuard); configure.write (Boolean.FALSE); // disable mouse clicks while (true) { configure.write (offColour); tim.sleep (random.nextInt (offInterval)); configure.write (standbyColour); tim.setAlarm (tim.read () + random.nextInt (standbyInterval)); int choice = standbyAlt.fairSelect (); // magic synchronisation if (choice == MY_INDEX) { playLeader ( (AltingBarrier) standbyGuard[choice], shared[choice], myChannel.in(), random, tim ); } else if (choice != TIMEOUT) { play ((AltingBarrier) standbyGuard[choice], shared[choice]); } } } private void playLeader ( AltingBarrier bar, Shared shared, AltingChannelInput myChannel, Random random, CSTimer tim ) { while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks while (myChannel.pending ()) myChannel.read (); // clear any buffered cancels Alternative leaderAlt = new Alternative (new Guard[] {click, myChannel, tim}); final int CLICK = 0, CANCEL = 1, TIM = 2; int count = (playInterval/countInterval) - 1; shared.ok = (count >= 0); // initialise shared shared shared.label = label[count]; shared.colour = new Color (random.nextInt ()); shared.brighter = shared.colour.brighter (); bar.sync (); // allow inspection of shared variables boolean bright = true; long countTimeout = 0; countTimeout = tim.read () + countInterval; // set first timeout tim.setAlarm (countTimeout); while (shared.ok) { configure.write (bright ? shared.brighter : shared.colour); bright = !bright; configure.write (shared.label); bar.sync (); // allow update of shared variables count--; if (count < 0) { shared.ok = false; // game over } else { shared.label = label[count]; } switch (leaderAlt.priSelect ()) { case CLICK: // our button clicked click.read (); shared.ok = false; // game over break; case CANCEL: // someone else's button clicked myChannel.read (); // (they will have set shared.ok) break; case TIM: // timeout - move on countTimeout += countInterval; tim.setAlarm (countTimeout); break; } bar.sync (); // allow inspection of shared variables } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } private void play (AltingBarrier bar, Shared shared) { while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks Alternative followerAlt = new Alternative (new Guard[] {click, bar}); final int CLICK = 0, BAR = 1; bar.sync (); // allow inspection of shared variables boolean bright = true; while (shared.ok) { configure.write (bright ? shared.brighter : shared.colour); bright = !bright; configure.write (shared.label); bar.sync (); // allow update of shared variables switch (followerAlt.priSelect ()) { case CLICK: // our button clicked click.read (); shared.toLeader.write (null); // cancel leader timeout (if any) shared.ok = false; // game over (we must set this) bar.sync (); // allow inspection of shared variables break; case BAR: // allow inspection of shared variables break; } } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget5.java0000644000000000000000000002036511111352066023223 0ustar import org.jcsp.lang.*; import org.jcsp.util.*; import java.awt.Color; import java.util.*; public class AltingBarrierGadget5 implements CSProcess { private final AltingChannelInput in; private final ChannelOutput[] out; private final AltingBarrier bar; private final AltingChannelInput click; private final ChannelOutput configure; private final Color offColour, standbyColour; private final int offInterval, standbyInterval; private final int playInterval, countInterval; private final String[] label; public AltingBarrierGadget5 ( AltingChannelInput in, ChannelOutput[] out, AltingBarrier bar, AltingChannelInput click, ChannelOutput configure, Color offColour, Color standbyColour, int offInterval, int standbyInterval, int playInterval, int countInterval, String[] label ) { this.in = in; this.out = out; this.bar = bar; this.click = click; this.configure = configure; this.offColour = offColour; this.standbyColour = standbyColour; this.offInterval = offInterval; this.standbyInterval = standbyInterval; this.playInterval = playInterval; this.countInterval = countInterval; this.label = label; } public void run () { CSTimer tim = new CSTimer (); final Random random = new Random (); // make alting barrier and shared variables // for the group this gadget is leading ... final AltingBarrier[] myAltingBarrier = AltingBarrier.create (out.length + 1); final Any2OneChannel myChannel = Channel.any2one (new OverWritingBuffer (1)); final Shared myShared = new Shared (myChannel.out()); // parallel-I/O distribution of barriers and shared variables final AltingBarrier barDash = bar.expand (); new ProcessManager ( new CSProcess () { public void run () { for (int i = 0; i < out.length; i++) { synchronized (out[i]) { out[i].write (myAltingBarrier[i]); out[i].write (myShared); } } barDash.sync (); // wait for all gadgets to finish output barDash.contract (); // discard no longer needed item } } ).start (); ArrayList dump = // temporary storage new ArrayList (2*out.length); // (guessed initial size) Alternative distributeAlt = new Alternative (new Guard[] {in, bar}); final int IN = 0, BAR = 1; int count = 0; boolean more = true; while (more) { switch (distributeAlt.priSelect ()) { case IN: dump.add (in.read ()); // an AltingBarrier dump.add (in.read ()); // Shared variables count++; break; case BAR: more = false; break; } } distributeAlt = null; // discard no longer needed item bar.contract (); // discard no longer needed item // make receiving arrays for the barrier and shared variables // from the other group leaders final Guard[] standbyGuard = new Guard[count + 2]; final int MY_INDEX = count; standbyGuard[MY_INDEX] = myAltingBarrier[out.length]; final int TIMEOUT = count + 1; standbyGuard[TIMEOUT] = tim; final Shared[] shared = new Shared[count + 1]; shared[MY_INDEX] = myShared; Iterator iterator = dump.iterator (); for (int i = 0; i < count; i++) { standbyGuard[i] = (AltingBarrier) iterator.next (); shared[i] = (Shared) iterator.next (); } iterator = null; // discard no longer needed item dump = null; // discard no longer needed item // start real work ... Alternative standbyAlt = new Alternative (standbyGuard); configure.write (Boolean.FALSE); // disable mouse clicks while (true) { configure.write (offColour); tim.sleep (random.nextInt (offInterval)); configure.write (standbyColour); tim.setAlarm (tim.read () + random.nextInt (standbyInterval)); int choice = standbyAlt.fairSelect (); // magic synchronisation if (choice == MY_INDEX) { playLeader ( (AltingBarrier) standbyGuard[choice], shared[choice], myChannel.in(), random, tim ); } else if (choice != TIMEOUT) { play ((AltingBarrier) standbyGuard[choice], shared[choice]); } } } private void playLeader ( AltingBarrier bar, Shared shared, AltingChannelInput myChannel, Random random, CSTimer tim ) { while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks while (myChannel.pending ()) myChannel.read (); // clear any buffered cancels int count = 0; long countTimeout = 0; Alternative leaderAlt = new Alternative (new Guard[] {click, myChannel, tim}); final int CLICK = 0, CANCEL = 1, TIM = 2; count = (playInterval/countInterval) - 1; shared.ok = (count >= 0); // initialise shared variables shared.label = label[count]; shared.colour = new Color (random.nextInt (16777216)); shared.brighter = shared.colour.brighter (); bar.sync (); // allow inspection of shared variables boolean bright = true; countTimeout = tim.read () + countInterval; // set first timeout tim.setAlarm (countTimeout); while (shared.ok) { configure.write (bright ? shared.brighter : shared.colour); bright = !bright; configure.write (shared.label); bar.sync (); // allow update of shared variables count--; if (count < 0) { shared.ok = false; // game over } else { shared.label = label[count]; } switch (leaderAlt.priSelect ()) { case CLICK: // our button clicked click.read (); shared.ok = false; // game over break; case CANCEL: // someone else's button clicked myChannel.read (); // (they will have set shared.ok) break; case TIM: // timeout - move on countTimeout += countInterval; tim.setAlarm (countTimeout); break; } bar.sync (); // allow inspection of shared variables } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } private void play (AltingBarrier bar, Shared shared) { while (click.pending ()) click.read (); // clear any buffered mouse clicks configure.write (Boolean.TRUE); // enable mouse clicks Alternative followerAlt = new Alternative (new Guard[] {click, bar}); final int CLICK = 0, BAR = 1; bar.sync (); // allow inspection of shared variables boolean bright = true; while (shared.ok) { configure.write (bright ? shared.brighter : shared.colour); bright = !bright; configure.write (shared.label); bar.sync (); // allow update of shared variables switch (followerAlt.priSelect ()) { case CLICK: // our button clicked click.read (); shared.toLeader.write (null); // cancel leader timeout (if any) shared.ok = false; // game over (we must set this) bar.sync (); // allow inspection of shared variables break; case BAR: // allow inspection of shared variables break; } } configure.write (Boolean.FALSE); // disable mouse clicks configure.write (""); // clear button label } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget6Demo0.java0000644000000000000000000001250111111352066024102 0ustar import org.jcsp.demos.util.*; import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.plugNplay.*; import java.awt.Color; import java.util.Random; import java.util.ArrayList; public class AltingBarrierGadget6Demo0 { public static void main (String[] argv) { final int width = Ask.Int ("\nwidth = ", 10, 30); final int depth = Ask.Int ("depth = ", 1, 30); final int span = Ask.Int ("length of arms = ", 1, width/2); final int offInterval = Ask.Int ("off interval (millisecs) = ", 100, 10000); final int standbyInterval = Ask.Int ("standby interval (millisecs) = ", 100, 20000); final int playInterval = Ask.Int ("play interval (millisecs) = ", 1000, 1000000000); final int countInterval = Ask.Int ("count interval (millisecs) = ", 10, 10000); final Color offColour = Color.black, standbyColour = Color.lightGray; // make the buttons final One2OneChannel[][] click = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { click[i] = Channel.one2oneArray (width, new OverWriteOldestBuffer (1), width); } final One2OneChannel[][] configure = new One2OneChannel[depth][]; for (int i = 0; i < depth; i++) { configure[i] = Channel.one2oneArray (width); } final FramedButtonGrid buttons = new FramedButtonGrid ( "AltingBarier: Gadget 6, Demo 0", depth, width, 20 + (depth*50), width*50, Util.get2DInputArray(configure), Util.get2DOutputArray(click) ); // make labels for the buttons (read-only shared by all the gadgets) final String[] label = new String[playInterval/countInterval]; for (int i = 0; i < label.length; i++) { label[i] = String.valueOf (i); } // make the gadgets final ArrayList[][] connect = new ArrayList [depth][width]; for (int row = 0; row < depth; row++) { ArrayList[] connectRow = connect[row]; for (int col = 0; col < width; col++) { connectRow[col] = new ArrayList (8*span); // estimate initial size } } final Random random = new Random (); final Barrier bar = new Barrier (width*depth); final AltingBarrierGadget6[][] gadgets = new AltingBarrierGadget6[depth][width]; for (int row = 0; row < depth; row++) { for (int col = 0; col < width; col++) { gadgets[row][col] = new AltingBarrierGadget6 ( connect[row][col], shape (random, row, col, span, connect), bar, click[row][col].in(), configure[row][col].out(), offColour, standbyColour, offInterval, standbyInterval, playInterval, countInterval, label ); } } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } static ArrayList[] shape ( Random random, int row, int col, int span, ArrayList[][] connect ) { switch (random.nextInt (3)) { case 0: return shapePlus (row, col, span, connect); case 1: return shapeCross (row, col, span, connect); case 2: return shapeCircle (row, col, span, connect); default: return null; } } static ArrayList[] shapePlus ( int row, int col, int span, ArrayList[][] connect ) { final int n = 4*span; final ArrayList[] collect = new ArrayList[n]; int index = 0; for (int i = 1; i <= span; i++) { collect[index] = get (connect, row-i, col); index++; collect[index] = get (connect, row, col+i); index++; collect[index] = get (connect, row+i, col); index++; collect[index] = get (connect, row, col-i); index++; } return collect; } static ArrayList[] shapeCross ( int row, int col, int span, ArrayList[][] connect ) { final int n = 4*span; final ArrayList[] collect = new ArrayList[n]; int index = 0; for (int i = 1; i <= span; i++) { collect[index] = get (connect, row-i, col-i); index++; collect[index] = get (connect, row-i, col+i); index++; collect[index] = get (connect, row+i, col-i); index++; collect[index] = get (connect, row+i, col+i); index++; } return collect; } static ArrayList[] shapeCircle ( int row, int col, int span, ArrayList[][] connect ) { final int n = (4*span) - 1; final ArrayList[] collect = new ArrayList[n]; int index = 0; for (int i = 0; i < (span - 1); i ++) { col++; collect[index] = get (connect, row, col); index++; } col++; for (int i = 0; i < span; i++) { row--; collect[index] = get (connect, row, col); index++; } row--; for (int i = 0; i < span; i++) { col--; collect[index] = get (connect, row, col); index++; } col--; for (int i = 0; i < span; i++) { row++; collect[index] = get (connect, row, col); index++; } return collect; } static ArrayList get (ArrayList[][] connect, int row, int col) { final int depth = connect.length; row = (row + depth)%depth; final int width = connect[row].length; col = (col + width)%width; return connect[row][col]; } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget1Demo0.java0000644000000000000000000000515711111352066024106 0ustar import org.jcsp.demos.util.*; import java.awt.Color; import org.jcsp.lang.*; import org.jcsp.plugNplay.*; import org.jcsp.util.*; public class AltingBarrierGadget1Demo0 { public static void main (String[] argv) { // final int nUnits = 30, span = 6; // // final int offInterval = 800, standbyInterval = 1000; // milliseconds // // final int playInterval = 10000, flashInterval = 500; // milliseconds final int nUnits = Ask.Int ("\nnUnits = ", 3, 30); final int span = Ask.Int ("span = ", 2, nUnits); final int offInterval = Ask.Int ("off interval (millisecs) = ", 100, 10000); final int standbyInterval = Ask.Int ("standby interval (millisecs) = ", 100, 20000); final int playInterval = Ask.Int ("play interval (millisecs) = ", 1000, 1000000000); final int flashInterval = Ask.Int ("flash interval (millisecs) = ", 50, 1000); final Color offColour = Color.black, standbyColour = Color.lightGray; // make the buttons final One2OneChannel[] click = Channel.one2oneArray (nUnits, new OverWriteOldestBuffer (1)); final One2OneChannel[] configure = Channel.one2oneArray (nUnits); final boolean horizontal = true; final FramedButtonArray buttons = new FramedButtonArray ( "AltingBarrier: Gadget 1, Demo 0", nUnits, 100, nUnits*50, horizontal, Channel.getInputArray(configure), Channel.getOutputArray(click) ); // construct nUnits barriers, each with span front-ends ... AltingBarrier[][] ab = new AltingBarrier[nUnits][]; for (int i = 0; i < nUnits; i++) { ab[i] = AltingBarrier.create (span); } // re-arrange front-ends, ready for distribution to processes ... AltingBarrier[][]barrier = new AltingBarrier[nUnits][span]; for (int i = 0; i < nUnits; i++) { for (int j = 0; j < span; j++) { barrier[i][j] = ab[(i + j) % nUnits][j]; } } // make the track and the gadgets One2OneChannel[] track = Channel.one2oneArray (nUnits); AltingBarrierGadget1[] gadgets = new AltingBarrierGadget1[nUnits]; for (int i = 0; i < nUnits; i++) { gadgets[i] = new AltingBarrierGadget1 ( barrier[i], track[(i + 1)%nUnits].in(), track[i].out(), click[i].in(), configure[i].out(), offColour, standbyColour, offInterval, standbyInterval, playInterval, flashInterval ); } // run everything new Parallel ( new CSProcess[] { buttons, new Parallel (gadgets) } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/altingBarriers/AltingBarrierGadget0.java0000644000000000000000000000302311111352066023206 0ustar import org.jcsp.lang.*; import java.awt.*; public class AltingBarrierGadget0 implements CSProcess { private final AltingChannelInput click; private final AltingBarrier group; private final ChannelOutput configure; public AltingBarrierGadget0 ( AltingChannelInput click, AltingBarrier group, ChannelOutput configure ) { this.click = click; this.group = group; this.configure = configure; } public void run () { final Alternative clickGroup = new Alternative (new Guard[] {click, group}); final int CLICK = 0, GROUP = 1; int n = 0; configure.write (String.valueOf (n)); while (true) { configure.write (Color.green); // pretty while (!click.pending ()) { n++; // work on our own configure.write (String.valueOf (n)); // work on our own } click.read (); // must consume the click configure.write (Color.red); // pretty boolean group = true; while (group) { switch (clickGroup.priSelect ()) { case CLICK: click.read (); // must consume the click group = false; // end group working break; case GROUP: n--; // work with the group configure.write (String.valueOf (n)); // work with the group break; } } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/index.html0000644000000000000000000001461711113267343015467 0ustar JCSP Applet Demonstrations

JCSP Applet Demonstrations



The following table gives links to several demonstration JCSP Applets.  They illustrate a variety of animation effects and GUI controls.  All make significant use of JCSP concurrency to support the GUI, the application-specific computation and the animation.  The first group are slightly simpler than the second.  All sources are in sub-folders of this (jcsp-demos) folder.

The left column links will run the applets using  Sun's Java PlugIn (but please read the warning below).  The right column runs the same applets using the native JVM supplied by your browser - this needs to be compatible at least with JDK1.1.5 (e.g. Netscape 4.6, IE 5).



 
Sun's Java Plug-In
Browser's Native JVM

 
Flasher
 Flasher
 Balls
 Balls
 Picasso
 Picasso
 MissionControl
  MissionControl

 
 Infect
 Infect
 Mandelbrot
 Mandelbrot
 Bounce
 Bounce
Plasma
 Plasma
Fireworks
 Fireworks
 MultiPong
 MultiPong
 Splat
 Splat


All these applets may be run as applications - change to the xxx source folder, where xxx is one of the above applet names, and run the command: java xxxMain.  For some reason, applications sometimes run more smoothly than their equivalent applets.  Also, for some reason, all the animations (i.e. Balls, Infect, Mandelbrot, Bounce, Plasma and Splat) run much faster and more responsively under JDK1.1.x (where x >= 5) than under JDK1.2 (or JDK1.3/4) - see below.

Warning - Don't Use the Plug-In Configured to Use the JDK1.2 (or 1.3/4) Runtime Environment!

Most of these applets make moderate to heavy use of animation.  Currently, animations do not seem to be one of the strong features of JDK1.2 (nor JDK1.3/4) - they seem very slow compared with JDK1.1.

Our current recommendation is to download the PlugIn version 1.1.3, which installs the JRE1.1.8.  If you already have the PlugIn version 1.2 (or above), it is recommended to configure it to use a JDK1.1.x run-time environment (where x >= 5).  This can be done by firing up the "Java PlugIn Control Panel", clicking on the "Advanced" tab, selecting a 1.1 "Java Run Time Environment" (which must have been previously installed - e.g. by downoloading and installing the PlugIn version 1.1.3) and clicking the "Apply" button.

Note: the native JVMs provided by Netscape 4.6 and IE 5.0 support a JRE1.1 sufficiently high to run these applet demonstrations.

Note: sometimes, IE 5.0 throws an application error when trying to start an applet configured to use Sun's PlugIn .

Note: Sun's PlugIn 1.3 throws a java.security.AccessControlException when the applet thread tries to construct a new thread.  Investigating ... version 1.1.3, (left column) or the native browser JVM (right column above).

Note: we should provide JCSP support for Swing and this is in hand (though in a slightly different way to the JCSP support for AWT).


jcsp-1.1-rc4.orig/src/jcsp-demos/matrix/0000755000000000000000000000000011410045036014756 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/matrix/TestMatrix.java0000644000000000000000000002041011111352066017724 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.util.Random; import org.jcsp.demos.util.Ask; import org.jcsp.lang.*; /** * @author P.H. Welch */ public class TestMatrix { public static final String TITLE = "Matrix"; public static final String DESCR = "Compares the speed of a sequential matrix multiplication algorithm and a parallelised one. The 'seed' " + "parameter is used to initialize a random number generator. The 'limit' parameter sets the range of " + "numbers generated. A, B and C specify the size of the matrices. An A*B matrix is multiplied by a B*C " + "matrix. The number of benchmarks allows a number of trials to be made and an average time taken.\n" + "\n" + "The SEQ uses purely sequential logic. The PAR uses parallel logic but reallocates the threads each time. " + "The reuse-PAR uses the same set of threads each time so no thread allocation overheads get considered."; public static void main (String[] args) { Ask.app (TITLE, DESCR); Ask.addPrompt ("seed", 1, 100, 1); Ask.addPrompt ("limit", 1, 2000, 100); Ask.addPrompt ("A", 1, 4096, 200); Ask.addPrompt ("B", 1, 4096, 200); Ask.addPrompt ("C", 1, 4096, 200); Ask.addPrompt ("benchmarks", 1, 2000, 10); Ask.show (); long seed = Ask.readInt ("seed"); double limit = (double)Ask.readInt ("limit"); int A = Ask.readInt ("A"); int B = Ask.readInt ("B"); int C = Ask.readInt ("C"); int nBenchmarks = Ask.readInt ("benchmarks"); Ask.blank (); Random random = new Random (seed); double[][] X = new double[A][B]; double[][] Y = new double[B][C]; double[][] Z = new double[A][C]; double[][] ZZ = new double[A][C]; System.out.println ("Initialising arrays X[A][B], Y[B][C] ..."); Matrix.randomise (X, limit, random); Matrix.randomise (Y, limit, random); System.out.println ("Printing array X[A][B], ..."); Matrix.print (X, 3, 3); System.out.println ("\nPrinting array Y[B][C] ..."); Matrix.print (Y, 3, 3); CSTimer tim = new CSTimer (); long t0, t1, time; System.out.println ("\nMultiplying X*Y --> ZZ ..."); t0 = tim.read (); Matrix.multiply (X, Y, ZZ); t1 = tim.read (); time = t1 - t0; System.out.println ("Completed in " + time + " milliseconds ..."); System.out.println ("\nPrinting array ZZ[A][C] ..."); Matrix.print (ZZ, 3, 3); //////////////////////////////////////////////////////////////////////////////////// double sum = 0.0d, sumsq = 0.0d; for (int i = 0; i < nBenchmarks; i++) { System.out.println ("\n(SEQ) Multiplying X*Y --> Z ..."); t0 = tim.read (); Matrix.seqMultiply (X, Y, Z); t1 = tim.read (); time = t1 - t0; System.out.println ("[" + (i + 1) + "/" + nBenchmarks + "] Completed in " + time + " milliseconds ..."); sum += time; sumsq += time*time; } System.out.println ("\nPrinting array Z[A][C] ..."); Matrix.print (Z, 3, 3); System.out.println ("\nChecking array Z[A][C] against ZZ[A][C] ..."); if (Matrix.same (Z, ZZ)) { System.out.println ("... checked OK"); } else { System.out.println ("... check FAILED"); } double mean = sum/nBenchmarks; double top = sumsq - ((sum*sum)/nBenchmarks); double stdev = Math.sqrt(top/(nBenchmarks - 1)); System.out.println ("\n[" + A + "][" + B + "] * [" + B + "][" + C + "] ==> [" + A + "][" + C + "]"); System.out.println ("number of benchmarks = " + nBenchmarks); System.out.println ("mean = " + mean); System.out.println ("standard deviation = " + stdev); Matrix.randomise (Z, limit, random); //////////////////////////////////////////////////////////////////////////////////// sum = 0.0d; sumsq = 0.0d; for (int i = 0; i < nBenchmarks; i++) { System.out.println ("\n(PAR) Multiplying X*Y --> Z ..."); t0 = tim.read (); Matrix.parMultiply (X, Y, Z); t1 = tim.read (); time = t1 - t0; System.out.println ("[" + (i + 1) + "/" + nBenchmarks + "] Completed in " + time + " milliseconds ..."); sum += time; sumsq += time*time; } System.out.println ("\nPrinting array Z[A][C] ..."); Matrix.print (Z, 3, 3); System.out.println ("\nChecking array Z[A][C] against ZZ[A][C] ..."); if (Matrix.same (Z, ZZ)) { System.out.println ("... checked OK"); } else { System.out.println ("... check FAILED"); } mean = sum/nBenchmarks; top = sumsq - ((sum*sum)/nBenchmarks); stdev = Math.sqrt(top/(nBenchmarks - 1)); System.out.println ("\n[" + A + "][" + B + "] * [" + B + "][" + C + "] ==> [" + A + "][" + C + "]"); System.out.println ("number of benchmarks = " + nBenchmarks); System.out.println ("mean = " + mean); System.out.println ("standard deviation = " + stdev); Matrix.randomise (Z, limit, random); //////////////////////////////////////////////////////////////////////////////////// Parallel par = Matrix.makeParMultiply (X, Y, Z); sum = 0.0d; sumsq = 0.0d; for (int i = 0; i < nBenchmarks; i++) { System.out.println ("\n(reuse-PAR) Multiplying X*Y --> Z ..."); t0 = tim.read (); par.run (); t1 = tim.read (); time = t1 - t0; System.out.println ("[" + (i + 1) + "/" + nBenchmarks + "] Completed in " + time + " milliseconds ..."); sum += time; sumsq += time*time; } System.out.println ("\nPrinting array Z[A][C] ..."); Matrix.print (Z, 3, 3); System.out.println ("\nChecking array Z[A][C] against ZZ[A][C] ..."); if (Matrix.same (Z, ZZ)) { System.out.println ("... checked OK"); } else { System.out.println ("... check FAILED"); } mean = sum/nBenchmarks; top = sumsq - ((sum*sum)/nBenchmarks); stdev = Math.sqrt(top/(nBenchmarks - 1)); System.out.println ("\n[" + A + "][" + B + "] * [" + B + "][" + C + "] ==> [" + A + "][" + C + "]"); System.out.println ("number of benchmarks = " + nBenchmarks); System.out.println ("mean = " + mean); System.out.println ("standard deviation = " + stdev); Matrix.randomise (Z, limit, random); System.exit (0); } } jcsp-1.1-rc4.orig/src/jcsp-demos/matrix/Matrix.java0000644000000000000000000001656011111352066017077 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.util.Random; import org.jcsp.lang.*; /** * @author P.H. Welch */ public class Matrix { public static void randomise (final double[][] X, final double limit, final Random random) { final double halfLimit = limit/2.0d; for (int i = 0; i < X.length; i++) { final double[] Xi = X[i]; for (int j = 0; j < Xi.length; j++) { Xi[j] = (limit*random.nextDouble ()) - halfLimit; } } } public static void print (final double[][] X, final int rows, final int cols) { for (int i = 0; i < rows; i++) { final double[] Xi = X[i]; for (int j = 0; j < cols; j++) { if ((j%5) == 0) System.out.println (); System.out.print ("\t" + Xi[j]); } } System.out.println (); } public static boolean same (final double[][] X, final double[][] Y) { for (int i = 0; i < X.length; i++) { final double[] Xi = X[i]; final double[] Yi = Y[i]; for (int j = 0; j < Xi.length; j++) { if (Xi[j] != Yi[j]) { System.out.println ("X[" + i + "][" + j + "] = " + Xi[j]); System.out.println ("Y[" + i + "][" + j + "] = " + Yi[j]); return false; } } } return true; } public static void multiply (final double[][] X, final double[][] Y, final double[][] Z) { if (X[0].length != Y.length) { throw new MultiplyBoundsException ("X[0].length != Y.length"); } if (X.length != Z.length) { throw new MultiplyBoundsException ("X.length != Z.length"); } if (Y[0].length != Z[0].length) { throw new MultiplyBoundsException ("Y[0].length != Z[0].length"); } for (int i = 0; i < X.length; i++) { final double[] Xi = X[i]; final double[] Zi = Z[i]; for (int j = 0; j < Y[0].length; j++) { double sum = 0.0d; for (int k = 0; k < Y.length; k++) { sum += Xi[k]*Y[k][j]; } Zi[j] = sum; } } } public static void seqMultiply (final double[][] X, final double[][] Y, final double[][] Z) { if (X[0].length != Y.length) { throw new MultiplyBoundsException ("X[0].length != Y.length"); } if (X.length != Z.length) { throw new MultiplyBoundsException ("X.length != Z.length"); } if (Y[0].length != Z[0].length) { throw new MultiplyBoundsException ("Y[0].length != Z[0].length"); } final CSProcess[] rowProcess = new CSProcess[X.length]; for (int i = 0; i < X.length; i++) { final int ii = i; rowProcess[ii] = new CSProcess () { public void run () { final double[] Xi = X[ii]; final double[] Zi = Z[ii]; final double[][] YY = Y; for (int j = 0; j < YY[0].length; j++) { double sum = 0.0d; for (int k = 0; k < YY.length; k++) { sum += Xi[k]*YY[k][j]; } Zi[j] = sum; } } }; } new Sequence (rowProcess).run (); } public static void parMultiply (final double[][] X, final double[][] Y, final double[][] Z) { if (X[0].length != Y.length) { throw new MultiplyBoundsException ("X[0].length != Y.length"); } if (X.length != Z.length) { throw new MultiplyBoundsException ("X.length != Z.length"); } if (Y[0].length != Z[0].length) { throw new MultiplyBoundsException ("Y[0].length != Z[0].length"); } final CSProcess[] rowProcess = new CSProcess[X.length]; for (int i = 0; i < X.length; i++) { final int ii = i; rowProcess[ii] = new CSProcess () { public void run () { final double[] Xi = X[ii]; final double[] Zi = Z[ii]; final double[][] YY = Y; for (int j = 0; j < YY[0].length; j++) { double sum = 0.0d; for (int k = 0; k < YY.length; k++) { sum += Xi[k]*YY[k][j]; } Zi[j] = sum; } } }; } final Parallel par = new Parallel (rowProcess); par.run (); par.releaseAllThreads (); } public static Parallel makeParMultiply (final double[][] X, final double[][] Y, final double[][] Z) { if (X[0].length != Y.length) { throw new MultiplyBoundsException ("X[0].length != Y.length"); } if (X.length != Z.length) { throw new MultiplyBoundsException ("X.length != Z.length"); } if (Y[0].length != Z[0].length) { throw new MultiplyBoundsException ("Y[0].length != Z[0].length"); } final CSProcess[] rowProcess = new CSProcess[X.length]; for (int i = 0; i < X.length; i++) { final int ii = i; rowProcess[ii] = new CSProcess () { public void run () { final double[] Xi = X[ii]; final double[] Zi = Z[ii]; final double[][] YY = Y; for (int j = 0; j < YY[0].length; j++) { double sum = 0.0d; for (int k = 0; k < YY.length; k++) { sum += Xi[k]*YY[k][j]; } Zi[j] = sum; } } }; } return new Parallel (rowProcess); } public static class MultiplyBoundsException extends RuntimeException { public MultiplyBoundsException (String s) { super (s); } } } jcsp-1.1-rc4.orig/src/jcsp-demos/picasso/0000755000000000000000000000000011410045036015113 5ustar jcsp-1.1-rc4.orig/src/jcsp-demos/picasso/Picasso.html0000644000000000000000000000374211113065047017414 0ustar JCSP Picasso

Picasso

Point the mouse at the applet. [LEFT MOUSE CLICK] toggles in and out of sketching mode. [MIDDLE MOUSE CLICK] toggles in and out of box-target mode. [RIGHT MOUSE CLICK] clears the applet and returns to its initial state. jcsp-1.1-rc4.orig/src/jcsp-demos/picasso/PicassoNetwork.java0000644000000000000000000001002011111352066020724 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.util.*; import org.jcsp.awt.*; import java.awt.*; /** * @author P.H. Welch */ public class PicassoNetwork implements CSProcess { private final ActiveCanvas activeCanvas; private final Picasso picasso; public PicassoNetwork (final Container parent) { final Dimension size = parent.getSize (); parent.setLayout (new BorderLayout ()); parent.setBackground (Color.blue); final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10)); final One2OneChannel mouseMotionEvent = Channel.one2one (new OverWriteOldestBuffer (1)); final DisplayList display = new DisplayList (); final One2OneChannel toGraphics = Channel.one2one (); final One2OneChannel fromGraphics = Channel.one2one (); activeCanvas = new ActiveCanvas (); activeCanvas.setBackground (Color.black); activeCanvas.addMouseEventChannel (mouseEvent.out ()); activeCanvas.addMouseMotionEventChannel (mouseMotionEvent.out ()); activeCanvas.setPaintable (display); activeCanvas.setGraphicsChannels (toGraphics.in (), fromGraphics.out ()); activeCanvas.setSize (size); // If the parent is an applet, the above setSize has no effect and the activeCanvas // is fitted to the "Center" area (see below) of the applet's panel. // If the parent is a frame, the above *does* define the size of the activeCanvas // and the size of the parent is expanded to wrap around when it is packed. System.out.println ("PicassoNetwork adding ActiveCanvas to the parent ..."); parent.add ("Center", activeCanvas); picasso = new Picasso (size, mouseEvent.in (), mouseMotionEvent.in (), display); // picasso = new Picasso (size, mouseEvent, mouseMotionEvent, toGraphics, fromGraphics); } public void run () { System.out.println ("PicassoNetwork starting up ..."); new Parallel ( new CSProcess[] { activeCanvas, picasso } ).run (); } } jcsp-1.1-rc4.orig/src/jcsp-demos/picasso/Picasso.java0000644000000000000000000001620511111352066017365 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import java.awt.*; import java.awt.event.*; import org.jcsp.lang.*; import org.jcsp.awt.*; /** * @author P.H. Welch */ public class Picasso implements CSProcess { final protected int width; final protected int height; final protected AltingChannelInput mouseEvent; final protected AltingChannelInput mouseMotionEvent; // final protected ChannelOutput toGraphics; // final protected ChannelInput fromGraphics; final protected DisplayList display; public Picasso (Dimension size, AltingChannelInput mouseEvent, AltingChannelInput mouseMotionEvent, // ChannelOutput toGraphics, ChannelInput fromGraphics) { DisplayList display) { this.width = size.width; this.height = size.height; this.mouseEvent = mouseEvent; this.mouseMotionEvent = mouseMotionEvent; this.display = display; // this.toGraphics = toGraphics; // this.fromGraphics = fromGraphics; } // final protected DisplayList display = new DisplayList (); final protected String clickMessage = "C L I C K T H E M O U S E T O D R A W"; final protected String clickPlea = "P L E A S E M O V E T H E M O U S E B A C K"; protected GraphicsCommand[] mouseEntered, mouseExited; // fixed commands protected void setMouseEntered () { final GraphicsCommand[] tmp = { new GraphicsCommand.SetColor (Color.cyan), new GraphicsCommand.FillRect (0, 0, width, height), new GraphicsCommand.SetColor (Color.black), new GraphicsCommand.DrawString (clickMessage, (width-(5*clickMessage.length ()))/2, height/2) }; mouseEntered = tmp; } protected void setmouseExited () { final GraphicsCommand[] tmp = { new GraphicsCommand.SetColor (Color.pink), new GraphicsCommand.FillRect (0, 0, width, height), new GraphicsCommand.SetColor (Color.black), new GraphicsCommand.DrawString (clickPlea, (width-(5*clickPlea.length ()))/2, height/2) }; mouseExited = tmp; } final protected GraphicsCommand[] mouseDrawLine = {null}; // filled in dynamically final protected int targetSize = 50; final protected GraphicsCommand[] mouseTarget = {null}; // filled in dynamically protected Point point = new Point (); protected boolean drawing = false; protected boolean targetting = false; protected void handleMouseEvent (final MouseEvent event) { switch (event.getID ()) { case MouseEvent.MOUSE_ENTERED: display.change (mouseEntered, 0); break; case MouseEvent.MOUSE_EXITED: display.change (mouseExited, 0); break; case MouseEvent.MOUSE_PRESSED: int modifiers = event.getModifiers (); if ((modifiers & InputEvent.BUTTON1_MASK) != 0) { if (targetting) { targetting = false; display.set (mouseEntered); } drawing = ! drawing; if (drawing) point = event.getPoint (); } else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) { drawing = false; targetting = ! targetting; display.set (mouseEntered); if (targetting) { point = event.getPoint (); mouseTarget[0] = new GraphicsCommand.DrawRect ( point.x - (targetSize/2), point.y - (targetSize/2), targetSize, targetSize ); display.extend (mouseTarget); } } if ((modifiers & InputEvent.BUTTON3_MASK) != 0) { drawing = false; targetting = false; display.set (mouseEntered); } break; } } protected void handleMouseMotionEvent (final MouseEvent motion) { final Point newPoint = motion.getPoint (); if (drawing) { final GraphicsCommand mouseDrawLine = new GraphicsCommand.DrawLine (point.x, point.y, newPoint.x, newPoint.y); point = newPoint; display.extend (mouseDrawLine); } else { final GraphicsCommand mouseTarget = new GraphicsCommand.DrawRect (newPoint.x - (targetSize/2), newPoint.y - (targetSize/2), targetSize, targetSize); display.change (mouseTarget, mouseEntered.length); } } public void run () { final AltingChannelInput[] mouse = {mouseEvent, mouseMotionEvent}; final int MOUSE_EVENT = 0; final int MOUSE_MOTION_EVENT = 1; final boolean[] preCondition = {true, false}; final Alternative alt = new Alternative (mouse); // toGraphics.write (new GraphicsProtocol.SetPaintable (display)); // fromGraphics.read (); setMouseEntered (); setmouseExited (); display.set (mouseExited); while (true) { preCondition[1] = drawing | targetting; switch (alt.select (preCondition)) { case MOUSE_EVENT: handleMouseEvent ((MouseEvent) mouseEvent.read ()); break; case MOUSE_MOTION_EVENT: handleMouseMotionEvent ((MouseEvent) mouseMotionEvent.read ()); break; } } } } jcsp-1.1-rc4.orig/src/jcsp-demos/picasso/ns-Picasso.html0000644000000000000000000000110611113065047020022 0ustar JCSP Picasso

Picasso

Point the mouse at the applet. [LEFT MOUSE CLICK] toggles in and out of sketching mode. [MIDDLE MOUSE CLICK] toggles in and out of box-target mode. [RIGHT MOUSE CLICK] clears the applet and returns to its initial state. jcsp-1.1-rc4.orig/src/jcsp-demos/picasso/PicassoMain.java0000644000000000000000000000674111111352066020176 0ustar ////////////////////////////////////////////////////////////////////// // // // JCSP ("CSP for Java") Libraries // // Copyright (C) 1996-2008 Peter Welch and Paul Austin. // // 2001-2004 Quickstone Technologies Limited. // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later // // version. // // // // This library is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the implied // // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // // PURPOSE. See the GNU Lesser General Public License for more // // details. // // // // You should have received a copy of the GNU Lesser General // // Public License along with this library; if not, write to the // // Free Software Foundation, Inc., 59 Temple Place, Suite 330, // // Boston, MA 02111-1307, USA. // // // // Author contact: P.H.Welch@kent.ac.uk // // // // // ////////////////////////////////////////////////////////////////////// import org.jcsp.lang.*; import org.jcsp.awt.*; import org.jcsp.demos.util.Ask; /** * @author P.H. Welch */ public class PicassoMain extends ActiveApplet { public static final String TITLE = "Picasso"; public static final String DESCR = "Demonstrates the handling of AWT mouse events by a basic drawing process."; public static final int minWidth = 100; public static final int maxWidth = 1024; public static final int maxHeight = 768; public static final int minHeight = 100; public void init () { setProcess (new PicassoNetwork (this)); } public static void main (String argv[]) { Ask.app (TITLE, DESCR); Ask.addPrompt ("width", minWidth, maxWidth, 640); Ask.addPrompt ("height", minHeight, maxHeight, 480); Ask.show (); final int width = Ask.readInt ("width"); final int height = Ask.readInt ("height"); Ask.blank (); final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame ("Picasso"); final ActiveFrame activeFrame = activeClosingframe.getActiveFrame (); activeFrame.setSize (width, height); final PicassoNetwork picassoNetwork = new PicassoNetwork (activeFrame); activeFrame.pack (); activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2); activeFrame.setVisible (true); activeFrame.toFront (); new Parallel ( new CSProcess[] { activeClosingframe, picassoNetwork } ).run (); } } jcsp-1.1-rc4.orig/build.xml0000644000000000000000000002147011113671251012450 0ustar jcsp-1.1-rc4.orig/GenerateBatchFiles.java0000644000000000000000000000174510701455074015161 0ustar import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class GenerateBatchFiles { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new FileReader(args[0])); String line; while (null != (line = br.readLine())) { line = line.trim(); if (line.length() > 0) { final String demosPkg = "org.jcsp.demos."; String batchName; if (line.startsWith(demosPkg)) { batchName = line.substring(demosPkg.length()); } else { batchName = line; } batchName = batchName.replace('.','_') + ".bat"; FileWriter out = new FileWriter(batchName); out.write("java -classpath \"jcsp-demos.jar;jcsp-demos-util.jar;jcsp.jar\" " + line + "\r\n"); out.close(); } } br.close(); } catch (IOException e) { e.printStackTrace(); } } } jcsp-1.1-rc4.orig/LICENCE.txt0000644000000000000000000005751010701455074012443 0ustar GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS jcsp-1.1-rc4.orig/demos-list.txt0000644000000000000000000000452710701455074013461 0ustar org.jcsp.demos.alting.FairPlexTimeTest org.jcsp.demos.alting.PollingTest org.jcsp.demos.alting.PriPlexTimeTest org.jcsp.demos.alting.RegulateTest org.jcsp.demos.alting.StressedAlt org.jcsp.demos.alting.ints.FairPlexTimeIntTest org.jcsp.demos.alting.ints.PollingIntTest org.jcsp.demos.alting.ints.PriPlexTimeIntTest org.jcsp.demos.alting.ints.RegulateIntTest org.jcsp.demos.alting.ints.StressedAltInt org.jcsp.demos.altingBarriers.AltingBarrierGadget0Demo0 org.jcsp.demos.altingBarriers.AltingBarrierGadget1Demo0 org.jcsp.demos.altingBarriers.AltingBarrierGadget1Demo1 org.jcsp.demos.altingBarriers.AltingBarrierGadget2Demo0 org.jcsp.demos.altingBarriers.AltingBarrierGadget2Demo1 org.jcsp.demos.altingBarriers.AltingBarrierGadget3Demo0 org.jcsp.demos.altingBarriers.AltingBarrierGadget4Demo0 org.jcsp.demos.altingBarriers.AltingBarrierGadget5Demo0 org.jcsp.demos.altingBarriers.AltingBarrierGadget6Demo0 org.jcsp.demos.balls.balls0.BallsMain0 org.jcsp.demos.balls.balls1.BallsMain1 org.jcsp.demos.balls.balls2.BallsMain2 org.jcsp.demos.bounce.BounceMain org.jcsp.demos.bucket.BucketExample1 org.jcsp.demos.bucket.BucketExample2 org.jcsp.demos.call.Any2AnyMain org.jcsp.demos.call.Any2OneMain org.jcsp.demos.call.One2AnyMain org.jcsp.demos.call.One2OneMain org.jcsp.demos.commstime.CommsTime org.jcsp.demos.commstime.CommsTimeSymmetric org.jcsp.demos.crew.CrewCollege org.jcsp.demos.eratosthenes.Eratosthenes org.jcsp.demos.fireworks.FireworksMain org.jcsp.demos.hamming.Hamming2 org.jcsp.demos.infect.InfectMain org.jcsp.demos.jcspchat.ChatPlusClientMain org.jcsp.demos.jcspchat.ChatPlusServerMain org.jcsp.demos.mandelbrot.MandelbrotMain org.jcsp.demos.mandelbrot.net.MandelbrotMain org.jcsp.demos.mandelbrot.net.MandelWorker org.jcsp.demos.matrix.TestMatrix org.jcsp.demos.missionControl.MissionControl org.jcsp.demos.outputGuards.PathologicalDemo org.jcsp.demos.philosophers.callChannel.PhilCall org.jcsp.demos.philosophers.channel.PhilMain org.jcsp.demos.philosophers.deadlock.DeadMain org.jcsp.demos.picasso.PicassoMain org.jcsp.demos.plasma.PlasmaMain org.jcsp.demos.raytrace.Main org.jcsp.demos.raytrace.Worker org.jcsp.demos.raytrace.WorkerConst org.jcsp.demos.splat.SplatMain org.jcsp.demos.wotNoChickens.callChannel.CallCollege org.jcsp.demos.wotNoChickens.channel.College org.jcsp.demos.wotNoChickens.starve.StarveCollege