Working on client -> frameserver -> ws_udp.js -> visionneuse.html stack
parent
bffff1a33a
commit
e760498b3b
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
for j in range(0,height):
|
||||
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"
|
||||
|
||||
# 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)
|
||||
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:
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
||||
rgbargbargbargbargbargbargbargba
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
Server::Server(int _port )
|
||||
{
|
||||
port = _port;
|
||||
displaycounter = 0;
|
||||
packetcounter = 0;
|
||||
consoleinit = false;
|
||||
port = _port;
|
||||
displaycounter = 0;
|
||||
packetcounter = 0;
|
||||
consoleinit = false;
|
||||
mode = FRAME;
|
||||
selected_buffer=0;
|
||||
launch_threads();
|
||||
|
@ -68,7 +68,7 @@ void Server::listen()
|
|||
|
||||
|
||||
// DEBUG OUTPUT RAW BUFFER DATA from packet
|
||||
// std::cout << recv_buf.data() << std::endl;
|
||||
//std::cout << recv_buf.data() << std::endl;
|
||||
|
||||
// check whether this is a valid packet and discard it if it isn't
|
||||
// note, this is a very hack way of comparing strings...
|
||||
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,12 +285,12 @@ void Server::mix()
|
|||
// implement alpha blending
|
||||
for(int x = 0; x < size; x++)
|
||||
{
|
||||
temp_frame = buffers[x]->get();
|
||||
temp_frame = buffers[x]->get();
|
||||
for(int i = 0; i < HEIGHT; i++)
|
||||
{
|
||||
for(int j = 0; j < WIDTH; j++)
|
||||
{
|
||||
temp_alpha = (float)temp_frame.windows[i][j][CHANNELS-1]/255;
|
||||
temp_alpha = (float)temp_frame.windows[i][j][CHANNELS-1]/255;
|
||||
for(int a = 0; a < CHANNELS; a++)
|
||||
{
|
||||
// this works for the colors and for the alpha channel
|
||||
|
@ -350,53 +353,55 @@ 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);
|
||||
exit(1);
|
||||
}
|
||||
start_color(); /* Start color */
|
||||
|
||||
init_pair(1,COLOR_RED,COLOR_BLACK);
|
||||
init_pair(2,COLOR_GREEN,COLOR_BLACK);
|
||||
init_pair(3,COLOR_BLUE,COLOR_BLACK);
|
||||
init_pair(4,COLOR_BLACK,COLOR_WHITE);
|
||||
init_pair(1,COLOR_RED,COLOR_BLACK);
|
||||
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;
|
||||
threads.push_back( Glib::Thread::create( sigc::mem_fun(this, &Server::input), false) );
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
{
|
||||
// we'll be accessing some data to provide statistics, lock the Server!!!
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
mvprintw(0,0,"Clients %d | F2 Frame | F3 Values | F4 Clients | F5 Stats | input: %d ", buffers.size(),console_input );
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
mvprintw(0,0,"Clients %d | F2 Frame | F3 Values | F4 Clients | F5 Stats | input: %d ", buffers.size(),console_input );
|
||||
switch(mode)
|
||||
{
|
||||
case FRAME:
|
||||
console_printframe(frame);
|
||||
break;
|
||||
case FRAME_VALUES:
|
||||
console_printframe_values(frame);
|
||||
break;
|
||||
case CLIENTS:
|
||||
console_printclients();
|
||||
break;
|
||||
break;
|
||||
case FRAME_VALUES:
|
||||
console_printframe_values(frame);
|
||||
break;
|
||||
case CLIENTS:
|
||||
console_printclients();
|
||||
break;
|
||||
default:
|
||||
console_printframe(frame);
|
||||
}
|
||||
refresh(); /* Print it on to the real screen */
|
||||
}
|
||||
usleep( 20000 );
|
||||
}
|
||||
endwin(); /* End curses mode */
|
||||
usleep( 20000 );
|
||||
}
|
||||
endwin(); /* End curses mode */
|
||||
}
|
||||
|
||||
void Server::input()
|
||||
{
|
||||
int c;
|
||||
int c;
|
||||
|
||||
// get the number of buffers in a threadsafe manner (see Server::get_size() )
|
||||
int size = get_size();
|
||||
|
@ -432,7 +437,7 @@ void Server::input()
|
|||
case '0':
|
||||
default:
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
console_input = c;
|
||||
}
|
||||
}
|
||||
|
@ -568,7 +573,6 @@ void Server::console_printclients()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Server::console_printstats()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
struct frame_t
|
||||
{
|
||||
unsigned char z;
|
||||
unsigned char z;
|
||||
unsigned char windows[HEIGHT][WIDTH][CHANNELS];
|
||||
unsigned char segments[SEGWIDTH][SEGNUM][SEGCHANNELS];
|
||||
// int windows[HEIGHT][WIDTH][CHANNELS];
|
||||
|
|
Loading…
Reference in New Issue