device


Device, sensor

Standar devices
Sensors
Properties
Drivers
AUD
clean       coe       COM
DAT       datas       tran       device       dim       drivers
end
fourier
IMA       ITR
KIN
file
MEM       MID       module       MOU
options
TCP       traj       type
UDP
validate       var
XXX
See also

Standard devices

Standard peripherals exist (depending on the machine and the system):
       mouse
       audio
They can be redefined by:
device(id)type("MOU"): associates the mouse to the id device id.
device(id)type("AUD")dim(n): associates the audio signal to the id device id.
device(id)type("SOR")dim(n): associates the fft audio to the id device id.

Sensors

Sensors are associated with various inputs (intertrax, polhemus, webcam, ...).
datas are vectors of various sizes.
Drivers must be programmed using:
       files written by the driver see FIC
       shared memory, see an example in WebCam.c.
       socketsUDP, see an example in device_UDP_serveur.func et device_UDP_client.func.
       socketsTCP
       MIDI

Properties

device(id)com1 com2 ...

Returns the property com1 com2 ... of device id.

device(id)com1 com2=p

Assignes the property com1 com2 of the device id.
        All combinations of commands are possible, just as drivers treat.
clean        coe
tran        dim
module
period
time
var

clean

device(id)clean
       Do "flush" on device id.

coe

device(id)coe=c1,c2,c3;
       Multiplie the sensor vector by (c1,c2,c3).

tran

device(id)tran=x,y,z;
        id device values will be translated to (x, y, z).

dim device(id)

Returns the np number of vectors and their size dimp.

dim device(id)=np,dimp

Change these parameters.
Notes:
(1,3) default.
For the ("ITR"): np=1, dimp=3 (orientation rx, ry, rz).
For the polhemus ("POL"): np=1, dimp=6 (positionx y z, and orientation rx, ry, rz).
For an image ("IMA"): np = number of rows, dimp = number of columns.

module

device module;
        Returns the average of the amplitudes of all active devices.
device(id)module;
        Returns the amplitude of device(id).

period

device(id)period=n;         Assigns a buffer of n samples to calculate the period.
device(id)period(0);         Returns the buffer of n samples.
device(id)period;
        Returns the period of the amplitude of the signal (stored in the buffer FIFO).

time

device(id)time=t;
       Specifies a timeout.

var

device(id)var;
        Receives datas from Device id (NIL if it is in writing).
device(id)var=datas;
        Send datas to the device id.

Drivers

driver_anyflo.        driver_C.

Langage anyflo

A driver written in anyflo sends vectors using the command:
device(id)var=v;
These vectors are recovered in anyflo by the command:
p=device(id)var;

Langage C

Examples are given in:
mem_part.htm.
Management (very simple) of the shared memory.

WebCam.c
Driver of a web cam.
itrax          kroonde          sound          webcam

itrax_mem.exe

Is a program allowing to run Intertrax with shared memory. Must be:
1) launch Isdemo32.exe
        Detect -> Port 1 38400 Bauds
        Accept
        Quit
2) launch itrax_mem.exe
3) in order to initite:
        type("MEM")device(1)name("ITRAX");
4) to read:
        p=device(1);
itrax_soc.exe
Is a program allowing to run Intertrax with a socket. Must be:
1) launch Isdemo32.exe
2) launch itrax_soc.exe
Must stop and relaunch the driver each anyflo is launched.
3) In order to initiate:
        type("UDP")device(1)name("host_driver")period(1)float
host_driver is the name de l´ordinateur sur lequel tourne itrax_soc.exe (ce peut être le même que celui sur lequel tourne anyflo.exe)
4) to read:
        p=device(1);

kroonde_mem.exe

Is a program allowing to run KROONDE. Must be:
1) plug the Kroonde.
2) launch kroonde_mem.exe (opening the shared memory KROONDE)
3) to initiate a device do:
        type("MEM")device(1)name("KROONDE")
4) to read:
        p=device(1): Retourne les valeurs des capteurs présents.

sound0.exe

Is a program allowing to run with a shared memory. Must be:
launch anyflo.exe
        a file threadID is writing containing thbe anyflo ID
perhaps do (generaly not)
write system
        to forcing the threadID file to be wrote
launch sound0.exe
        read the threadID file, the two programs are linked
Initiate:
        type("MEM")name("SOUND0")device(1);
read sounds:
        device(1)read("nom0.wav")number(0);
        device(1)read("nom1.wav")number(1);
        etc ...
play sound number n
        device(1)play(n)
we can add sounds by:
        device(1)read("nomn.wav")number(n);
device(id)cut(s)
        retutns 1 if sound s is playing, else 0
device(id)STOP(s)
        cuts sound ss
device(id)period(s,p)
        gives the periodicity (p=0: no, p=1: yes) for sound s
Examples
device(1)period(7,1): sound 7 periodic
device(1)period(7,0): sound 7 no no periodic
device(1)no
        detach the driver (sound0 is not accessible anymore)
device(1)yes
        atach driver to anyflo (sound0 is accessible again)

sound2.exe

Programme allowing to acced audio via shared memory. For initialize:
        type("MEM")device(1)name("AUDIO");
Pour read:
        p=device(1)read;

WebCam.exe

Is a program allowing to read a webcam image with a shared memory. Must be:
1) launch WebCam.exe with options:
WebCam n=c x=dx pos=x,y a=t v=m
size of the image (15 default)
dx=size of the captured image (120 default)
pos=x,y low left position (0,0 delfaut)
or pos=win y is read as second value in file win
waits t images per second (0 par default)
v=minimum value of luminance (0 default)
1) launch a web cam, adjust the image size with this of WebCam.exe and drag it, must be above (in particular when clicking in the anyflo window).
3) launch anyflo.exe with a window such as the previous image is visible.
4) Initiate:
        type("MEM")name("WEBCAM")device(1);
5) read the webcam:
        device(1)image: returns luminance size c*c
        device(1)image speed: returns speed image
        device(1)CG: returns 3 CG center, left and right
        device(1)CG(v): returns v times the 3 CG speeds
        device(1)CG image: returns the 3 CG
Note:
The flying reads can make the device command return NIL, so test it. Example:
        p=device(1)CG;n=dim(p);if(n==9){cg=p;...} else return;
        p=device(1)image;n=dim(p);if(n==(c*c)){im=p;...} else return;

end device(id)

Closes the id device.
In the case of a UDP socket thereof is stopped.

device traj

device traj t vol(id)

        Returns the property device of trajectory type t of volume id.

device(idv,c)traj t vol(id)

        Changes this property.
Note:
the trajectory type t of volume id is modulated by c * pos, where ppos is the value of device idv.

device type

syntaxe          AUD          COM          DAT          IMA          ITR          LIR          MEM          MID          MOU          SOR          TCP          UDP          XXX

General syntaxe: device(id)type("TYP")...

       Creates the device identifier id, type TYP and default properties.
Some properties propr1, propr2, ... of the device can be declared at the time of declaration by the options:
device(id)type("TYP")propr1(p1)propr2(p2)...;
They can be modified by:
       propri device(id)=pi;
propri device(id);
Returns propri property of device id.
       TYP est:
AUD COM DAT ITR LIR MEM MID MOU SOR TCP UDP XXX
Options:
       dim(dimx,dimy,dimz):
              TYP=AUD: audio is initialized to 2^dimx échantillons.
              TYP=IMA: dimx and dimy are the dimensions of the capture window.
       poi(x,y,z):
              TYP=IMA: x et y sont les coordonnées du coin bas left de la fenêtre de capture.
       var(np,dimp): a buffer of np sensor vectors (dimension dimp) is reserved a buffer of size np vectors sensors dimp is reserved.
       coe(cx,cy,cz): defines multipliers: device(id)coe(cx,cy,cz).
       tran(dx,dy,dz): defines translation: device(id)tran(dx,dy,dz).
       debug(d): mode debug.
       envelope(ne): defines the pitch of the envelope: device(id)envelope(ne).
       yes(1):
              TYP=IMA: the capture window is a clicked position.
              TYP=MEM: blocking read.
      
       simple TYP=MEM: dialogue protocol anyflo off (there can be only one of this type) see
How exange informations between a C program and anyflo

device(id)type("AUD") dim(n)

Audio (size 2 ^ n) is associated with the device id.
device(id)var: returns audio var.

device(id)type("COMn")

        Serial port n.

device(id)type("DAT")name("name")

        Sensor values are stored in the ASCII file name according to the matrix (np * dimp)
V0=c0,0 c0,1 ... c0,dimp-1
V1=c1,0 c1,1 ... c1,dimp-1
V2=c2,0 c2,1 ... c2,dimp-1
...
Vnp-1=cnp-1,0 cnp-1,1 ... cnp-1,dimp-1

Example:
1.1 1.2 1.3
2.1 2.2 2.3
At initialization, this file is read and placed in var device(id) to float, its dimensions (np, dimp) are placed in dim device(id).
read device(id): rereads the file name (in case of change of the latter).
np=dimp=1 (default only one value).
dimp is the number of fields (parallel sensors).
np is the number of samplings.
dim device(id)
        Returns np, dimp, cpt (cpt is a counter to read circularly).
       Returns vector Vn (with 0 <= n < np).
var(n,i) device(id)
       Returns vector Vn[i] (with 0 <= i < dimp).
var(n,i1,i2)device(id)
       Returns vector Vn[i1,i2] (avec 0 <= i1 < dimp && 0 <= i2 < dimp).
read device(id)
       Reraed file name (if changed) in device id.

device(id)type("KIN")

        KINET (DEVELOPING).

device(id)type("LIR") name("fic")dim(n)

        fic file containing n characters is associated with the device id.
var perip(id) returns the contents of the file ascii fic.
a driver permanently writes ascii values in the file fic.
Note: this type of device can not be known by its number (since his name assignes the file read).
See device_READ.js that launches 2 anyflos running functions respectively device_READ_1.func is the server and the client is device_READ_2.func.

device(id_device)type("IMA")

       Definition of a device type image.
Options:
dim(dx,dy): size of the image (15,15 default).
poi(x,y): position of the lower-left corner of the image (0,0 by default).
device(id_device)var image(id_ima);: captures and returns to image id_ima, the image of the window (x, y, dx, dy).

device(id)type("ITR") number(p)

        opens INTERTRAX on port p for the device id:
1) Connecter Itrax on serial port (USB3)
2) isdemo32.32.exe
     Detect -> Port 1 38400 Bauds
     Accept
     Quitter
You can also read it with the shared memory:
device(id)type("MEM") number(p)
It took first launch the driver itrax_mem2.exe

device(id)type("MEM") name("nnn")

        Shared memory name "nnn"
Options:
dim=n1,n2: size n1=size of buffer server (14401 = 4*120*120+1 default) and n2=size of buffer client (100 default).
simple: direct communication protocol anyflo off, the server writes characters directly in shared memory, the client reads directly in one place see How to exchange information between a C program and anyflo.

First example :
Click on shared_memory.js
This java script java launches for anyflos.
In the top left window the server is running:
       it captures the mouse positions and sends them to clients.
In windows right two clients are running, They recover the position sent by the server and use it to position volumes.
in the lower left window a help is running.
Operation:
Move the mouse in the server window.
       We then see the volumes in the client windows take the same positions.
Codes are in:
       env/shared_memory_serveur.func.
       env/shared_memory_client1.func.
       env/shared_memory_client2.func.
       env/shared_memory_help.func.

Second example :
Click on audio_memory.js
This java script java launches two anyflos.
In the top left window the server is running:
       it captures the audio max and sends them to clients.
In window bellow one client is running, Ir recovers the value sent by the server and use it to position volumes.
Operation:
Speak in the micro.
       We then see the volumes in the client windows move.
Codes are in:
       env/audio_server.func.
       env/audio_client.func.

Exemple

An example is the programmed driver of a webcam in WebCam.c.

device(id)type("MID") number(p)

DEVELOPING
        Ouvre MIDI sur le port p pour le périphérique id

device(id)type("MOU")

       The mouse is associated to device id.
Options:
mouse(m): mouse(m().
normal: mouse normal.

device(id)var

Returns mouse.

device(id) [number(port)]type("TCP")lead

DEVELOPING
        Etablit un serveur en protocole TCP/IP sur le port (12345 par défaut) de la machine
type("TCP") name("host") device(id) [number(port)] [char] [float] [time att]
        Etablit un client en protocole TCP/IP communiquant avec un serveur lancé sur la machine host par le port (12345 par défaut)
        Si char est présent: Mode char (par défaut)
        Si float est présent: Mode float (la string passée par la socket est décodée en flottants)
        Définit le timeout en millisecondes (1000 par défaut)

device(id)type("SOR") dim(n)

        The FFT (size 2^n) is associated to device id.

device(id)type("UDP")

        Establishes an UDP server communicating with the machine.
Options:
        dim(n):maximum size of transferts (n=1024 default).
        lead: opening as server.
        texture(port): port used by socket (port=8889 default).
        name("Ms"): Ms=server name.
        name("Ms")name("Mc"): Ms=serveur name, Mc=client name.
        name("xxx.xxx.xxx.xxx"): IP of the machine (for example "127.0.0.1").
If this option is not, the name of the local computer is the default.
Example:
If a anyflo runs on the machine named M1 and another anyflo running on another machine named M2 (or the same) sockets allow interaction between these two programs:
On machine M1 lauch UDP server:
        device(1)type("UDP")lead name("M1")
On machine M2 launch UDP client:
        device(2)type("UDP")name("M1")name("M2");
On machine M2 send message:
        device(2)var="ABC";
On machine M1 receive this message:
        p=device(1)var; /* p contains "ABC" */

device(id)type("XXX")

        Defines a device named XXX (standadrs different types) to be managed by the user in the function PERIPH_UTIL (long * PD0, long * result, long * end, long * pd_eg) file utilb.c.

device validate

device(id)validate

        Returns 1 if the device id is valid, 0 if it is disabled or -1 if not defined.

device(id)validate=v

       v=1: valid, v=0: inhibits device id.

end device(id)


         Closes the device id.

Périphériques prédéfinis

mouse.
         If the system includes a mouse must metter its indicator to 1 in the file envb.h
Interactively no mouse disconnects the mouse and yes mouse connects.

See also:

clean memory
dim device
edit device