2007-02 About Agentsv & Communication API

Agents list

Key ones:

Rest:

How do they work ?

Agents collaborate in following way:

  • TODO

Design

Idea. Abstraction model drawing.
( G - GUI is a subtype of UI - User Interface. For more info look at agents list.)

Agents speak to each other.
It's abstraction model realized thought api.

Implementations

Abstraction model can be implemented in many different ways,
but implementation details are always hidden behind communication api structure and in effect… transparent and invisible for agents.

Current implementations are:

  • Base on standard I/O
  • Based in Simple TCP/IP Queue

standard i/o

Communication API implementation based on I/O standard streams
which main purpose is to boost agents development.

It can be also used to run agents in a lot of many simple tasks.
More information about that feature you can find on draft page: 2007-03-02 Stdio Communication Api's Implementation .

queue simple tcp/ip


( G - GUI is a subtype of UI - User Interface. For more info look at agents list.)
That implementation organises all agents around one Simple TCP/IP Queue agent.
Of course, centralized structure is hidden behind communication api and invisible for other agents.
It's current default implementation.

Communication API


This point describes api, through which Agents speak to each other.

Example of use

int ret;
long id, len;
const long bufsize = 1024 * 1024;
char *buf = new char[bufsize];
while( condition ){
    len = bufsize;
    id = scsrecvas(MY_TYPE_NUMBER, buf, &len, 0);
    if( id < 0 ) { scsraiseerror("Error");  return ret; }
    /* 
       processing data
     */
    ret = scssendto(TARGET_AGENT, buf, len, 0);
    if( ret != 0 ) { scsraiseerror("Error");  return ret; };
    ret = scsconfirm(MY_TYPE_NUMBER, id, 0);
    if( ret != 0 ) { scsraiseerror("Error");  return ret; };
};

Receive As

Receive As - long scsrecvas(long who, void *buf, long *len, int flags)
By this function agent volunteers to receive message as one of who agents.
who - "as who?" agent want to receive (TODOANG -> "as who?" ~ jako kto )
buf
len set this as size of buffer. Function sets this as size of received data.
flags - now always 0
Returns On success : message id (positive number >0 ) . On fail: negative number.

Example of use:
Agent J want to receive message to him:

id = scsrecvas( SCS_JUDGE, buf, bufsize, 0);
if( id < 0 ) { scsraiseerror(...);  return ret; }

Send To

Send To - int scssendto(long towho, const void *buf, long len, int flags)
towho - to what agent (addressee)
buf - buffer with data
len - data size
flags - now always 0
Returns 0 on success.

Example of use:
Agent Ch sends message to agent J:

ret= scssendto( SCS_JUDGE, buf, len, 0);
if( ret != 0 ) { scsraiseerror(...);  return ret; };

Confirm

Confirm - int scsconfirm(long who, long id, int flags)
By this function agent confirms that previously received message was processed.
who - who agent is
id - received message id
flags - now always 0
Returns On success : 0 .

Example of use:
Agent J want to receive message to him:

id = scsrecvas( SCS_JUDGE, buf, bufsize, 0);
/*
...
here is processing
...
*/
ret = scsconfirm(SCS_JUDGE, id, 0);
if( ret != 0 ) { scsraiseerror(...);  return ret; };
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.