Changed comments for the libraries network, serial, and hardware i/o

This commit is contained in:
Anadroid
2020-09-10 16:07:03 +02:00
parent db91449e33
commit 42b0efb8b8
4 changed files with 186 additions and 69 deletions
@@ -31,15 +31,13 @@ import java.lang.reflect.*;
import java.net.*;
/**
* ( begin auto-generated from Client.xml )
*
* A client connects to a server and sends data back and forth. If anything
* goes wrong with the connection, for example the host is not there or is
* listening on a different port, an exception is thrown.
*
* ( end auto-generated )
* @webref net
* @brief The client class is used to create client Objects which connect to a server to exchange data.
* @webBrief The client class is used to create client Objects which connect to a server to exchange data.
* @instanceName client any variable of type Client
* @usage Application
* @see_external LIB_net/clientEvent
@@ -148,14 +146,12 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_stop.xml )
*
* Disconnects from the server. Use to shut the connection when you're
* finished with the Client.
*
* ( end auto-generated )
* @webref client:client
* @brief Disconnects from the server
* @webBrief Disconnects from the server
* @usage application
*/
public void stop() {
@@ -306,14 +302,12 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_active.xml )
*
* Returns true if this client is still active and hasn't run
* into any trouble.
*
* ( end auto-generated )
* @webref client:client
* @brief Returns true if this client is still active
* @webBrief Returns true if this client is still active
* @usage application
*/
public boolean active() {
@@ -322,14 +316,12 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_ip.xml )
*
* Returns the IP address of the computer to which the Client is attached.
*
* ( end auto-generated )
* @webref client:client
* @usage application
* @brief Returns the IP address of the machine as a String
* @webBrief Returns the IP address of the machine as a String
*/
public String ip() {
if (socket != null){
@@ -340,15 +332,13 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_available.xml )
*
* Returns the number of bytes available. When any client has bytes
* available from the server, it returns the number of bytes.
*
* ( end auto-generated )
* @webref client:client
* @usage application
* @brief Returns the number of bytes in the buffer waiting to be read
* @webBrief Returns the number of bytes in the buffer waiting to be read
*/
public int available() {
synchronized (bufferLock) {
@@ -358,14 +348,12 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_clear.xml )
*
* Empty the buffer, removes all the data stored there.
*
* ( end auto-generated )
* @webref client:client
* @usage application
* @brief Clears the buffer
* @webBrief Clears the buffer
*/
public void clear() {
synchronized (bufferLock) {
@@ -376,16 +364,14 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_read.xml )
*
* Returns a number between 0 and 255 for the next byte that's waiting in
* the buffer. Returns -1 if there is no byte, although this should be
* avoided by first cheacking <b>available()</b> to see if any data is available.
*
* ( end auto-generated )
* @webref client:client
* @usage application
* @brief Returns a value from the buffer
* @webBrief Returns a value from the buffer
*/
public int read() {
synchronized (bufferLock) {
@@ -402,15 +388,13 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_readChar.xml )
*
* Returns the next byte in the buffer as a char. Returns -1 or 0xffff if
* nothing is there.
*
* ( end auto-generated )
* @webref client:client
* @usage application
* @brief Returns the next byte in the buffer as a char
* @webBrief Returns the next byte in the buffer as a char
*/
public char readChar() {
synchronized (bufferLock) {
@@ -421,7 +405,6 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_readBytes.xml )
*
* Reads a group of bytes from the buffer. The version with no parameters
* returns a byte array of all data in the buffer. This is not efficient,
@@ -431,7 +414,6 @@ public class Client implements Runnable {
* of bytes read. If more bytes are available than can fit into the
* <b>byteBuffer</b>, only those that fit are read.
*
* ( end auto-generated )
* <h3>Advanced</h3>
* Return a byte array of anything that's in the serial buffer.
* Not particularly memory/speed efficient, because it creates
@@ -440,7 +422,7 @@ public class Client implements Runnable {
*
* @webref client:client
* @usage application
* @brief Reads everything in the buffer
* @webBrief Reads everything in the buffer
*/
public byte[] readBytes() {
synchronized (bufferLock) {
@@ -518,7 +500,6 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_readBytesUntil.xml )
*
* Reads from the port into a buffer of bytes up to and including a
* particular character. If the character isn't in the buffer, 'null' is
@@ -531,10 +512,9 @@ public class Client implements Runnable {
* not large enough, -1 is returned and an error is printed to the message
* area. If nothing is in the buffer, 0 is returned.
*
* ( end auto-generated )
* @webref client:client
* @usage application
* @brief Reads from the buffer of bytes up to and including a particular character
* @webBrief Reads from the buffer of bytes up to and including a particular character
* @param interesting character designated to mark the end of the data
*/
public byte[] readBytesUntil(int interesting) {
@@ -615,7 +595,6 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_readString.xml )
*
* Returns the all the data from the buffer as a String. This method
* assumes the incoming characters are ASCII. If you want to transfer
@@ -623,10 +602,9 @@ public class Client implements Runnable {
* representation of your choice (i.e. UTF8 or two-byte Unicode data), and
* send it as a byte array.
*
* ( end auto-generated )
* @webref client:client
* @usage application
* @brief Returns the buffer as a String
* @webBrief Returns the buffer as a String
*/
public String readString() {
byte b[] = readBytes();
@@ -636,12 +614,10 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_readStringUntil.xml )
*
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns
* <b>null</b> if it doesn't find what you're looking for.
*
* ( end auto-generated )
* <h3>Advanced</h3>
* <p/>
* If you want to move Unicode data, you can first convert the
@@ -650,7 +626,7 @@ public class Client implements Runnable {
*
* @webref client:client
* @usage application
* @brief Returns the buffer as a String up to and including a particular character
* @webBrief Returns the buffer as a String up to and including a particular character
* @param interesting character designated to mark the end of the data
*/
public String readStringUntil(int interesting) {
@@ -661,14 +637,12 @@ public class Client implements Runnable {
/**
* ( begin auto-generated from Client_write.xml )
*
* Writes data to a server specified when constructing the client.
*
* ( end auto-generated )
* @webref client:client
* @usage application
* @brief Writes bytes, chars, ints, bytes[], Strings
* @webBrief Writes bytes, chars, ints, bytes[], Strings
* @param data data to write
*/
public void write(int data) { // will also cover char
@@ -33,7 +33,6 @@ import java.net.*;
/**
* ( begin auto-generated from Server.xml )
*
* A server sends and receives data to and from its associated clients
* (other programs connected to it). When a server is started, it begins
@@ -42,10 +41,10 @@ import java.net.*;
* commonly used so be sure to not select one of these. For example, web
* servers usually use port 80 and POP mail uses port 110.
*
* ( end auto-generated )
* @webref net
* @usage application
* @brief The server class is used to create server objects which send and receives data to and from its associated clients (other programs connected to it).
* @webBrief The server class is used to create server objects which send
* and receives data to and from its associated clients (other programs connected to it).
* @instanceName server any variable of type Server
*/
public class Server implements Runnable {
@@ -115,13 +114,11 @@ public class Server implements Runnable {
/**
* ( begin auto-generated from Server_disconnect.xml )
*
* Disconnect a particular client.
*
* ( end auto-generated )
* @brief Disconnect a particular client.
* @webref server:server
* @webBrief Disconnect a particular client.
* @param client the client to disconnect
*/
public void disconnect(Client client) {
@@ -186,14 +183,12 @@ public class Server implements Runnable {
/**
* ( begin auto-generated from Server_active.xml )
*
* Returns true if this server is still active and hasn't run
* into any trouble.
*
* ( end auto-generated )
* @webref server:server
* @brief Return true if this server is still active.
* @webBrief Return true if this server is still active.
*/
public boolean active() {
return thread != null;
@@ -216,13 +211,11 @@ public class Server implements Runnable {
int lastAvailable = -1;
/**
* ( begin auto-generated from Server_available.xml )
*
* Returns the next client in line with a new message.
*
* ( end auto-generated )
* @brief Returns the next client in line with a new message.
* @webref server
* @webBrief Returns the next client in line with a new message.
* @usage application
*/
public Client available() {
@@ -254,17 +247,15 @@ public class Server implements Runnable {
/**
* ( begin auto-generated from Server_stop.xml )
*
* Disconnects all clients and stops the server.
*
* ( end auto-generated )
* <h3>Advanced</h3>
* Use this to shut down the server if you finish using it while your applet
* is still running. Otherwise, it will be automatically be shut down by the
* host PApplet using dispose(), which is identical.
* @brief Disconnects all clients and stops the server.
* @webref server
* @webBrief Disconnects all clients and stops the server.
* @usage application
*/
public void stop() {
@@ -332,14 +323,12 @@ public class Server implements Runnable {
/**
* ( begin auto-generated from Server_write.xml )
*
* Writes a value to all the connected clients. It sends bytes out from the
* Server object.
*
* ( end auto-generated )
* @webref server
* @brief Writes data to all connected clients
* @webBrief Writes data to all connected clients
* @param data data to write
*/
public void write(int data) { // will also cover char