forked from frigaut/yorick-opra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opra_svipc.i
71 lines (58 loc) · 1.69 KB
/
opra_svipc.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require,"svipc.i";
require,"opra_pyk.i";
func opra_svipc_init(dpi)
{
extern pyk_debug, _yorick_gui_proc;
extern am_master;
extern shmkey,semkey;
randomize;
shmkey = long(random()*1e7);
semkey = long(random()*1e7);
// shmkey = 0x0badcafe;
// semkey = 0x0badbeef;
write,format="shmkey = %#x\n",shmkey;
write,format="semkey = %#x\n",semkey;
// init SHM and SEM stuff:
shm_init,shmkey,slots=20;
sem_init,semkey,nums=20;
shm_write,shmkey,"stop",&([0]);
shm_write,shmkey,"next_stage",&([0]);
shm_write,shmkey,"quit?",&([0]);
shm_write,shmkey,"quit!",&([0]);
shm_write,shmkey,"do plots",&([0]);
shm_write,shmkey,"opra_structs",&([0]);
// spawn GUI yorick process
// build command
pyk_cmd=["yorick","-q","-i","opra_gui.i",swrite(format="%d",dpi),
swrite(format="%d",shmkey),swrite(format="%d",semkey)]
// spawn it and attach to _pyk_callback (see pyk.i):
_yorick_gui_proc = spawn(pyk_cmd, _pyk_callback);
extern quit;
quit = opra_quit;
set_idler,poll_quit;
return;
}
func write_yao_struct_to_shm(wfs,dm)
{
shm_free,shmkey,"yao_structs";
s = vsave("wfs",wfs,"dm",dm);
shm_write,shmkey,"yao_structs",&s;
}
func read_yao_struct_from_shm(&wfs,&dm)
{
restore,openb(shm_read(shmkey,"yao_structs"));
}
func write_opra_struct_to_shm(a,op,opp,mircube)
{
if (mircube==[]) mircube=[0];
shm_free,shmkey,"opra_structs";
s = vsave("op",op,"opp",opp,"a",a,"mircube",mircube,\
"lmfititer_pass",lmfititer_pass,"lmfit_itmax", \
lmfit_itmax,"lmfititer",lmfititer);
shm_write,shmkey,"opra_structs",&s;
}
func read_opra_struct_from_shm(&a,&op,&opp,&mircube)
{
extern lmfititer_pass,lmfit_itmax,lmfititer;
restore,openb(shm_read(shmkey,"opra_structs"));
}