Working on client -> frameserver -> ws_udp.js -> visionneuse.html stack

master
cyrille 2013-09-22 22:17:12 +02:00
parent bffff1a33a
commit e760498b3b
6 changed files with 75 additions and 62 deletions

11
clients/README Normal file
View File

@ -0,0 +1,11 @@
The goal is to make a nice python client library that allows us to quickly make new clients.
First goal is to get cellular.py and plasma.py to work through full stack.
plasma.py sends packets to:
frameserver, which sends packets to:
ws_udp.js, which sends it to the visionneuse.html client.
PROBLEMS:
- For some reason the cellular.py packet is not being processed by the frameserver
- When running plasma.py there is an alignment error in visionneuse.hml

View File

@ -84,7 +84,7 @@ def i2c(rgba):
def send_update():
#zero out the data buffer
data = hash
data = data + z_buffer
data = data + z_buffer # 12 bytes
# write frame data
for y in xrange(height):
@ -106,7 +106,7 @@ def send_update():
UDPSock.sendto(data,(remote_host,remote_port))
# initialize map
set_wdata(0,0,0)
set_wdata(67,67,67)
set_sdata(0,0,255)
# set start seed

View File

@ -7,6 +7,9 @@ from math import *
# Set the socket parameters
local_port = 5001
# direct html udp port
#remote_port = 4422
# production port
remote_port = 4321
# TODO: autodetect interface address for remote application
@ -26,20 +29,20 @@ UDPSock.bind((outgoing_if, local_port))
segmentsfile = open('segments','r')
hash = "abcdefghij"
hash = "s2l\n<8<18 " # 10 bytes
alpha = chr(255)
z_buffer = chr(1) + "\n"
width = 7
height = 12
width = 12
height = 8
segments = 8
segwidth = 12
segchannels = 4
segchannels = 3
sleeptime = 0.02
sleeptime = 0.2
t = 0
#timer will hold the elapsed time in seconds
@ -49,15 +52,22 @@ while (1):
#zero out the data buffer
data = hash
data += z_buffer
for i in range(0,width):
# windows
for j in range(0,height):
for i in range(0,width):
pixel = 0.5 + 0.5*sin(2*pi*(float(i+1)/width)+t*frequency)*sin(2*pi*(float(j+1)/height)+t*frequency)
data = data + chr(int(255*pixel)) + alpha
data = data + "\n"
char = chr(int(127 * pixel))
data += char + char + char + alpha
data += "\n"
# segment/text display
for i in range(0,segwidth):
for j in range(0,segments):
for a in range(0,segchannels):
data += chr( 127 + int(128*sin(2*pi*(1+i)*(1+j)*(1+a)*t*frequency/200)))
val = 63 + int(63*sin(2*pi*(1+i)*(1+j)*t*frequency/200))
data += chr(val)
data += alpha
data += "\n"
t+=1
if not data:

View File

@ -1,12 +0,0 @@
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba
rgbargbargbargbargbargbargbargba

View File

@ -173,7 +173,7 @@ void Server::listen()
void Server::send()
{
const int length = WIDTH*HEIGHT*CHANNELS + SEGWIDTH*SEGNUM*SEGCHANNELS;
const int length = 12 + HEIGHT*(WIDTH*CHANNELS+1) + SEGWIDTH*(SEGNUM*SEGCHANNELS+1);
static char data[length];
while(1)
@ -188,9 +188,10 @@ void Server::send()
{
for(int k = 0; k < CHANNELS; k++)
{
data[i*WIDTH*CHANNELS + CHANNELS*j + k] = frame.windows[i][j][k];
data[i*(WIDTH*CHANNELS+1) + j*CHANNELS + k] = frame.windows[i][j][k];
}
}
data[i*(WIDTH*CHANNELS+1) + (WIDTH*CHANNELS)] = '\n';
}
for(int i = 0; i < SEGWIDTH; i++)
@ -199,10 +200,12 @@ void Server::send()
{
for(int k = 0; k < SEGCHANNELS; k++)
{
data[WIDTH*HEIGHT*CHANNELS +
i*SEGNUM*SEGCHANNELS + SEGCHANNELS*j + k] = frame.segments[i][j][k];
data[HEIGHT*(WIDTH*CHANNELS+1) +
i*(SEGNUM*SEGCHANNELS+1) + j*SEGCHANNELS + k] = frame.segments[i][j][k];
}
}
data[HEIGHT*(WIDTH*CHANNELS+1) +
i*(SEGNUM*SEGCHANNELS+1) + (SEGNUM*SEGCHANNELS)] = '\n';
}
}
@ -350,7 +353,8 @@ void Server::console()
noecho();
if(has_colors() == FALSE)
{ endwin();
{
endwin();
printf("Your terminal does not support color\n");
// not sure what happens here because of threads!
exit(1);
@ -361,6 +365,7 @@ void Server::console()
init_pair(2,COLOR_GREEN,COLOR_BLACK);
init_pair(3,COLOR_BLUE,COLOR_BLACK);
init_pair(4,COLOR_BLACK,COLOR_WHITE);
{
Glib::Mutex::Lock lock(mutex_);
consoleinit = true;
@ -568,7 +573,6 @@ void Server::console_printclients()
}
}
void Server::console_printstats()
{
}

View File

@ -22,9 +22,9 @@
#define WINDOWOFFSET (WIDTH*CHANNELS+1)*HEIGHT
// 8 segments per window, 12 segments per floor, RGBA
#define SEGNUM 8
// 12 windows wide, 8 segment per window, RGBA
#define SEGWIDTH 12
#define SEGNUM 8
#define SEGCHANNELS 4
#define BUFLEN HEADEROFFSET+WINDOWOFFSET+(SEGNUM*SEGCHANNELS+1)*SEGWIDTH