Home   Documentation   Demonstrations   Download

AMICO: Documentation / AMICO Modules / Communicator

 

The most basic module. It implements basic AMICO TCP and UDP interfaces, and provides variable exchange, derivation, and maintance services.

  

How To Run

     java -jar %AMICO_HOME%/bin/amico.jar [<conf-url>]

 


Configuration File(s)

 

A main configuration file:
 

This is a minimal configuration file that uses default parameters for missing attributes.
Use this file if you want to use default settings.

---------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<config>

   <init> <!-- A link to files with initial variables. URLs are given relative to the current directory  -->
        <init-variables url="file:examples/configurations/communicator/init-variables.xml"/>
   </init>
   <transformations> <!-- A link to files with variable transformations. URLs are given relative to the current directory  -->
        <transformation url="file:examples/configurations/communicator/derived-variables-faces.xsl"/>
        <transformation url="file:examples/configurations/communicator/derived-variables-rfid.xsl"/>
   </transformations>
</config>

This is a full configuration file that overrides default parameters.

---------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<config number-of-transformation-steps="4" show-gui="yes" tcp-port="3320" udp-port="3321">
<init> <!-- A link to files with initial variables. URLs are given relative to the current directory  -->
     <init-variables url="file:examples/configurations/communicator/init-variables.xml"/>
</init>
<transformations> <!-- A link to files with variable transformations. URLs are given relative to the current directory  -->
     <transformation url="file:examples/configurations/communicator/derived-variables-faces.xsl"/>
     <transformation url="file:examples/configurations/communicator/derived-variables-rfid.xsl"/>
</transformations>
</config>

 

 A configuration file for init variables (linked from a main configuration file):
 

<?xml version="1.0" encoding="UTF-8"?>

<variables>

    <variable name="user-id" group="user-profile" description="ID of the user.">3456782</variable>

    <variable name="user-lang" group="user-profile" description="ID of the user.">en</variable>

    <variable name="min-distance" group="camera-settings" description="Distance in meters">1</variable>

    <variable name="max-distance" group="camera-settings" description="Distance in meters">2</variable>

</variables>

 

A variable transformation file (linked from a main configuration file, or loaded by LOAD TRANSFORMATION protocol command):
 

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <variables>
        <xsl:apply-templates/>
    </variables>
</xsl:template>

<xsl:template match="/variables/variable[@name='age']">
    <variable name='legal-age' group="derived">
        <xsl:if test=". &gt;= 18">yes</xsl:if>
        <xsl:if test=". &lt; 18">no</xsl:if>
    </variable>
</xsl:template>
<xsl:template match="/variables/variable[@name='legal-age']">
    <variable name='legal-action' group="derived">
        <xsl:if test=". = 'no'">redirect('start')</xsl:if>
        <xsl:if test=". = 'yes'">none</xsl:if>
    </variable>
</xsl:template>
<xsl:template match="/variables/variable[@name='screen-size']">
    <variable name='player-width' group="derived">
        <xsl:value-of select="substring-before(., ',')"/>
    </variable>
    <variable name='player-height' group="derived">
        <xsl:value-of select="substring-after(., ',')"/>
    </variable>
</xsl:template>
<xsl:template match="/variables/variable[@name='sesame-query-result']">
    <variable name='sesame-header' group="derived">
        <xsl:value-of select="tableQueryResult/header/columnName"/>
    </variable>
</xsl:template>
<xsl:template match="variable"/>
</xsl:stylesheet>

 

User interface

AMICO communicator also has a simple user interface, which enables you to see all basic and derived variables, as well as to update or delete some of the basic variables. NOTE: This interface appears only if you set attribute show-gui="yes" in the main configuration file.
 

 

Example of using communicator from other programs

 

If you want to develop new AMICO module, or to directly use AMICO TCP command interface, than thios code can be useful.

 

import java.net.*;

import java.io.*;

public class CommTest {

    public static void main(String[] args) {

        try {

            Socket communicator = new Socket( "localhost", 3320 );

            BufferedReader in = new BufferedReader( new InputStreamReader( communicator.getInputStream() ) );

            OutputStreamWriter out = new PrintWriter( new OutputStreamWriter( communicator.getOutputStream() ) );

           

            out.println( "UPDATE age 26" );

            out.println( "GETALLXML" );

           

            String line;

            while ((line = in.readLine()) != null) {

                System.out.prinltn( line );
            }

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

}

 

 

Validation Logos