Binary files rt_v35/.nfs0000000001f16b0400000031 and rt_v36/.nfs0000000001f16b0400000031 differ diff -urN rt_v35/cg.py rt_v36/cg.py --- rt_v35/cg.py 2018-05-09 21:43:25.000000000 +0900 +++ rt_v36/cg.py 2018-05-11 05:48:58.000000000 +0900 @@ -37,7 +37,7 @@ ut.mkdir_if_not(name) codec = ut.arg_s('codec', 'H264') - img.cli.v_open(name, cnt.fps, w, h, zm) + img.cli_vwt.open(name, cnt.fps, w, h, zm) eye_f = way.liss_eye() wh2eye = lstx.opt( [ ax.wh_map(w, h), fcx.new(dz), ax.zoom_z(-1), ax.rot_x(90) ] ) @@ -53,10 +53,10 @@ f = wf.draw f(eye2g, wh2eye, sc_sz) - img.cli.v_add_img() + img.cli_vwt.add_img() if 'no_show' not in sys.argv: wsec = max( cnt.wait_sec(), 0 ) fn_img = val.cli.get_prop('saved_fn_img') img.show(fn_img, '', wsec, zm) - img.cli.v_close() + img.cli_vwt.close() # EOF diff -urN rt_v35/cmd_send.py rt_v36/cmd_send.py --- rt_v35/cmd_send.py 2018-05-08 20:47:52.000000000 +0900 +++ rt_v36/cmd_send.py 2018-05-11 05:48:58.000000000 +0900 @@ -25,8 +25,8 @@ print( rmt_call(rmt_base, cmd) ) sys.exit(0) - exp_lst = [1,2,9] # val, img, copy - fwd_lst = [0] + list( range(3,9) ) + exp_lst = [1,2,3,9] # val, img, vwt, copy + fwd_lst = [0] + list( range(4,9) ) rmt_host = ut.arg_s('host', '') if not rmt_host: diff -urN rt_v35/cross.c rt_v36/cross.c --- rt_v35/cross.c 2018-05-09 21:31:17.000000000 +0900 +++ rt_v36/cross.c 2018-05-11 05:48:58.000000000 +0900 @@ -370,7 +370,7 @@ int main(int ac, char **av) { - int port = SOCK_PORT + 14; + int port = SOCK_PORT + 15; void *funcs[] = { srv_cross, }; diff -urN rt_v35/dat.py rt_v36/dat.py --- rt_v35/dat.py 2018-05-02 01:00:51.000000000 +0900 +++ rt_v36/dat.py 2018-05-11 05:48:58.000000000 +0900 @@ -210,6 +210,22 @@ 'm2g': [ ax.zoom_all(7), ax.slide_x(-10) ] } ] +rxs_test = [ { + 'kind': 'ball', + 'rtd': rtd, + 'm2g': [ ax.zoom_all(10), ax.slide([-15*4,-15*3,-15*2]) ], + 'rxs': [ + ( 'm2g', 'append', 4, [ ax.slide_x(30) ] ), + ( 'm2g', 'append', 3, [ ax.slide_y(30) ] ), + ( 'm2g', 'append', 2, [ ax.slide_z(30) ] ), + ] +},{ + 'kind': 'ball', + 'rtd': { 'diff': 0.3 }, + 'maps': [ { 'fn': 'IMG_3999_3.mov', 'fn_r': 'IMG_3999_4.mov', 'r': 0.3, 'rep': (1,1) } ], + 'm2g': [ ax.zoom_all(r) ], +} ] + lights = [ { 'p': mt.arr( [1,-1,-1] ) * 30, 'e': 2.5 }, { 'p': mt.arr( [-1,1,1] ) * 30, 'e': 2.5 }, @@ -447,6 +463,24 @@ return sum( map( d_setup, [d0,d1] ), [] ) ### + if 'rxs' in d: + rxs = d.get('rxs') + if not rxs: + d.pop('rxs') + return d_setup(d) + (targ_k, i_a, n, lx) = rxs.pop(0) + + targ = d.get(targ_k, []) + ds = [] + for i in range(n): + d_ = d.copy() + d_['rxs'] = rxs[:] # ! + d_[targ_k] = targ[:] + ds.append(d_) + targ = lx + targ if i_a == 'insert' else targ + lx + return sum( map( d_setup, ds ), [] ) + ### + if_not_set_opt( d, 'l2m', [] ) if_not_set_opt( d, 'm2g', [] ) if_not_set_opt( d, 'l2g', d.get('l2m') + d.get('m2g') ) diff -urN rt_v35/img.c rt_v36/img.c --- rt_v35/img.c 2018-05-09 21:31:17.000000000 +0900 +++ rt_v36/img.c 2018-05-11 05:48:58.000000000 +0900 @@ -1,42 +1,46 @@ #include "img.h" -#define IMG_WH 0 -#define IMG_COL 1 - -#define IMG_V_OPEN 2 -#define IMG_V_CLOSE 3 -#define IMG_V_SET 4 -#define IMG_V_LINE 5 -#define IMG_V_ADD_IMG 6 -#define IMG_V_CUR_SEC 7 -#define IMG_V_GET_CNT 8 -#define IMG_V_SETS 9 - - -static int fd = -1; - -void -img_conn(void) +int +fd_conn(int *fd, int port) { char *host = "localhost"; - int port = SOCK_PORT + 12; - if(fd < 0){ - fd = conn_host_port(host, port); + if(*fd < 0){ + *fd = conn_host_port(host, port); } - if(fd < 0){ - fprintf(stderr, "? img boot\n"); + if(*fd < 0){ + fprintf(stderr, "? boot port=%d\n", port); } + return *fd; } void -img_close(void) +fd_close(int *fd) { - if(fd < 0){ + if(*fd < 0){ return; } - close(fd); - fd = -1; + close(*fd); + *fd = -1; +} + +/**/ + +#define IMG_WH 0 +#define IMG_COL 1 + +static int fd_img = -1; + +int +img_conn(void) +{ + return fd_conn(&fd_img, SOCK_PORT + 12); +} + +void +img_close(void) +{ + fd_close(&fd_img); } void @@ -44,8 +48,7 @@ { int cmd = IMG_WH; int rets_sz = sizeof(*wh)*2; - - img_conn(); + int fd = img_conn(); sock_cli_call(fd, cmd, sizeof(fn), (char *)&fn, &rets_sz, (char *)wh); } @@ -56,8 +59,7 @@ int args_sz = sizeof(fn) + sizeof(sec) + sizeof(x) + sizeof(y) + sizeof(*def_col)*3 + sizeof(rep_x) + sizeof(rep_y); int rets_sz = sizeof(*ret_col)*3; char args_buf[ args_sz ], *bp = args_buf; - - img_conn(); + int fd = img_conn(); bp = COPY_TO_BP(bp, fn); bp = COPY_TO_BP(bp, sec); @@ -72,15 +74,37 @@ /**/ +#define VWT_OPEN 0 +#define VWT_CLOSE 1 +#define VWT_SET 2 +#define VWT_LINE 3 +#define VWT_ADD_IMG 4 +#define VWT_CUR_SEC 5 +#define VWT_GET_CNT 6 +#define VWT_SETS 7 + +static int fd_vwt = -1; + +int +vwt_conn(void) +{ + return fd_conn(&fd_vwt, SOCK_PORT + 13); +} + +void +vwt_fd_close(void) +{ + fd_close(&fd_vwt); +} + void -v_open(char *name, double fps, int w, int h, double zm) +vwt_open(char *name, double fps, int w, int h, double zm) { - int cmd = IMG_V_OPEN; + int cmd = VWT_OPEN; int name_sz = strlen(name); int args_sz = sizeof(name_sz) + name_sz + sizeof(fps) + sizeof(w) + sizeof(h) + sizeof(zm); char args_buf[ args_sz ], *bp = args_buf; - - img_conn(); + int fd = vwt_conn(); bp = COPY_TO_BP(bp, name_sz); bp = COPY_SZ_TO_BP(bp, name, name_sz); @@ -93,22 +117,20 @@ } void -v_close(void) +vwt_close(void) { - int cmd = IMG_V_CLOSE; - - img_conn(); + int cmd = VWT_CLOSE; + int fd = vwt_conn(); sock_cli_call(fd, cmd, 0, NULL, NULL, NULL); } void -v_set_xy(int x, int y, int *col) +vwt_set(int x, int y, int *col) { - int cmd = IMG_V_SET; + int cmd = VWT_SET; int args_sz = sizeof(x) + sizeof(y) + sizeof(*col)*3; char args_buf[ args_sz ], *bp = args_buf; - - img_conn(); + int fd = vwt_conn(); bp = COPY_TO_BP(bp, x); bp = COPY_TO_BP(bp, y); @@ -118,13 +140,12 @@ } void -v_line(int sx, int sy, int ex, int ey, int *col) +vwt_line(int sx, int sy, int ex, int ey, int *col) { - int cmd = IMG_V_LINE; + int cmd = VWT_LINE; int args_sz = sizeof(sx) + sizeof(sy) + sizeof(ex) + sizeof(ey) + sizeof(*col)*3; char args_buf[ args_sz ], *bp = args_buf; - - img_conn(); + int fd = vwt_conn(); bp = COPY_TO_BP(bp, sx); bp = COPY_TO_BP(bp, sy); @@ -136,34 +157,33 @@ } void -v_add_img(void) +vwt_add_img(void) { - int cmd = IMG_V_ADD_IMG; - - img_conn(); + int cmd = VWT_ADD_IMG; + int fd = vwt_conn(); sock_cli_call(fd, cmd, 0, NULL, NULL, NULL); } double -v_cur_sec(void) +vwt_cur_sec(void) { - int cmd = IMG_V_CUR_SEC; + int cmd = VWT_CUR_SEC; double sec = 0; int rets_sz = sizeof(sec); + int fd = vwt_conn(); - img_conn(); sock_cli_call(fd, cmd, 0, NULL, &rets_sz, (char *)&sec); return sec; } int -v_get_cnt(int n, int *ret_xy_lst) +vwt_get_cnt(int n, int *ret_xy_lst) { - int cmd = IMG_V_GET_CNT; + int cmd = VWT_GET_CNT; int rets_sz = 0, i, x, y; char *rets, *bp; + int fd = vwt_conn(); - img_conn(); bp = rets = sock_cli_call(fd, cmd, sizeof(n), (char *)&n, &rets_sz, NULL); bp = COPY_FROM_BP(bp, n); @@ -180,14 +200,13 @@ } void -v_sets(int x, int y, int col_n, int *col) +vwt_sets(int x, int y, int col_n, int *col) { - int cmd = IMG_V_SETS; + int cmd = VWT_SETS; int col_sz = sizeof(*col)*3*col_n; int args_sz = sizeof(x) + sizeof(y) + sizeof(col_n) + col_sz; char *args = malloc(args_sz), *bp = args; - - img_conn(); + int fd = vwt_conn(); bp = COPY_TO_BP(bp, x); bp = COPY_TO_BP(bp, y); diff -urN rt_v35/img.h rt_v36/img.h --- rt_v35/img.h 2018-05-09 21:31:17.000000000 +0900 +++ rt_v36/img.h 2018-05-11 05:48:58.000000000 +0900 @@ -3,20 +3,25 @@ #include "sock.h" -void img_conn(void); +int img_conn(void); void img_close(void); void img_wh(int fn, int *wh); void img_col(int fn, double sec, int x, int y, int *def_col, int rep_x, int rep_y, int *ret_col); -void v_open(char *name, double fps, int w, int h, double zm); -void v_close(void); -void v_set_xy(int x, int y, int *col); /* named for v.h */ -void v_line(int sx, int sy, int ex, int ey, int *col); -void v_add_img(void); -double v_cur_sec(void); -int v_get_cnt(int n, int *ret_xy_lst); -void v_sets(int x, int y, int col_n, int *col); +/**/ + +int vwt_conn(void); +void vwt_fd_close(void); + +void vwt_open(char *name, double fps, int w, int h, double zm); +void vwt_close(void); +void vwt_set(int x, int y, int *col); /* named for v.h */ +void vwt_line(int sx, int sy, int ex, int ey, int *col); +void vwt_add_img(void); +double vwt_cur_sec(void); +int vwt_get_cnt(int n, int *ret_xy_lst); +void vwt_sets(int x, int y, int col_n, int *col); #endif diff -urN rt_v35/img.py rt_v36/img.py --- rt_v35/img.py 2018-05-09 21:31:17.000000000 +0900 +++ rt_v36/img.py 2018-05-11 05:33:21.000000000 +0900 @@ -273,24 +273,32 @@ e.cur_sec = lambda : e.v.cur_sec() if e.v else 0 + #e.lock_cnt = ut.new_lock() def get_cnt(n): - lst = [] + (rn, x, y) = (0, -1, -1) if e.cnt: + #e.lock_cnt.lock() for i in range(n): if not e.cnt.up(show=False, show_fin=False): break - lst.append( e.cnt.cur() ) - return lst + if x < 0: + (x, y) = e.cnt.cur() + rn += 1 + #e.lock_cnt.unlock() + return (rn, x, y) e.get_cnt = get_cnt + #e.lock_sets = ut.new_lock() def sets(x, y, cols): (w, h) = e.wh() i = y * w + x + #e.lock_sets.lock() for col in cols: if col: e.set(x, y, col) i += 1 (x, y) = (i%w, i//w) + #e.lock_sets.unlock() e.sets = sets return e @@ -385,24 +393,31 @@ cmd_infs = [ { 'cmd': 'wh', 'func': wh, 'args': '(i4)', 'rets': '(i4,i4)' }, { 'cmd': 'col', 'func': col, 'args': '(i4,f8,i4,i4,col,(i4,i4))', 'rets': 'col' }, +] - { 'cmd': 'v_open', 'func': v_funcs.open, 'args': '(str,f8,i4,i4,f8)' }, - { 'cmd': 'v_close', 'func': v_funcs.close }, - { 'cmd': 'v_set', 'func': v_funcs.set, 'args': '(i4,i4,col)' }, - { 'cmd': 'v_line', 'func': v_funcs.line, 'args': '(i4,i4,i4,i4,col)' }, - { 'cmd': 'v_add_img', 'func': v_funcs.add_img }, - { 'cmd': 'v_cur_sec', 'func': v_funcs.cur_sec, 'rets': 'f8' }, - { 'cmd': 'v_get_cnt', 'func': v_funcs.get_cnt, 'args': '(i4)', 'rets': '[(i4,i4)]' }, - { 'cmd': 'v_sets', 'func': v_funcs.sets, 'args': '(i4,i4,[col])' }, +cmd_infs_vwt = [ + { 'cmd': 'open', 'func': v_funcs.open, 'args': '(str,f8,i4,i4,f8)' }, + { 'cmd': 'close', 'func': v_funcs.close }, + { 'cmd': 'set', 'func': v_funcs.set, 'args': '(i4,i4,col)' }, + { 'cmd': 'line', 'func': v_funcs.line, 'args': '(i4,i4,i4,i4,col)' }, + { 'cmd': 'add_img', 'func': v_funcs.add_img }, + { 'cmd': 'cur_sec', 'func': v_funcs.cur_sec, 'rets': 'f8' }, + { 'cmd': 'get_cnt', 'func': v_funcs.get_cnt, 'args': '(i4)', 'rets': '(i4,i4,i4)' }, + { 'cmd': 'sets', 'func': v_funcs.sets, 'args': '(i4,i4,[col])' }, ] cli = sock.new_client('srv.img', cmd_infs) +cli_vwt = sock.new_client('srv.vwt', cmd_infs_vwt) if __name__ == "__main__": if ut.arg_is(1, 'boot'): sock.server('srv.img', cmd_infs) sys.exit(0) + if ut.arg_is(1, 'boot_vwt'): + sock.server('srv.vwt', cmd_infs_vwt) + sys.exit(0) + if len(sys.argv[1:]) < 2: print( 'Usage: {} boot [port=xxxx]'.format(sys.argv[0]) ) print( ' boot videos server mode , def_port=1236' ) diff -urN rt_v35/rt.c rt_v36/rt.c --- rt_v35/rt.c 2018-05-09 21:31:17.000000000 +0900 +++ rt_v36/rt.c 2018-05-11 05:25:11.000000000 +0900 @@ -272,18 +272,18 @@ } void -set_cols(double *eyep, struct lstx *wh2g, double d_, double sec, int xys_n, int *xys) +set_cols(double *eyep, struct lstx *wh2g, double d_, double sec, int w, int n, int x, int y) { - int i, x, y; + int i, idx = y * w + x; double lp[3], p[3]; struct line l_g; - int cols_n = xys_n; + int cols_n = n; int *cols = malloc( sizeof(*cols)*3*cols_n ), *col = cols; lp[2] = -d_; - for(i=0; i