summaryrefslogtreecommitdiff
path: root/code/glue/da-controlled-sim-wrapper
blob: 918de4a3fe86f041141781f99812152d5fb5463c (plain)
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
#!/bin/sh

# check param count
if [ ! $# -eq 7 ]; then
    echo 'wrong parameter count (see the source for parameter order)' >&2
    # 1. model name (e.g. the "if" from "sim-if")
    # 2. controller name (relative to trainer-dir)
    # 3. input_neuron_file
    # 4. input_synapse_file
    # 5. output_neuron_file
    # 6. output_synapse_file
    # 7. performance output
    exit 1
fi

# determine the path of the simulaton program
SIM=`dirname $0`/../core/sim-$1
if [ ! -x $SIM ]; then
    echo "executable ($SIM) does not exist" >&2
    exit 1
fi

# determine the path of the controller programm
CTL=`dirname $0`/../trainer/$2-$1
if [ ! -x $CTL ]; then
    echo "executable ($CTL) does not exist" >&2
    exit 1
fi


# create tmp dir
FIFODIR=`mktemp -td fasimu.XXXXXXXXXX`

# create fifos
mkfifo $FIFODIR/spike_in
mkfifo $FIFODIR/spike_out
mkfifo $FIFODIR/trace_in
mkfifo $FIFODIR/global_in
mkfifo $FIFODIR/global_out

# TODO: check if an additional i/o file is an executable

# launch controller and simulator
#echo $CTL - $FIFODIR/trace_in $FIFODIR/global_in $FIFODIR/global_out $FIFODIR/spike_in $FIFODIR/spike_out "2> trainer.err &"
$CTL $7 $FIFODIR/trace_in $FIFODIR/global_in $FIFODIR/global_out $FIFODIR/spike_in $FIFODIR/spike_out 2> trainer.err &

#echo $SIM "2> sim.err" $3 $4 $FIFODIR/spike_in $FIFODIR/global_in $5 $6 $FIFODIR/spike_out $FIFODIR/global_out $FIFODIR/trace_in
$SIM 2> sim.err $3 $4 $FIFODIR/spike_in $FIFODIR/global_in $5 $6 $FIFODIR/spike_out $FIFODIR/global_out $FIFODIR/trace_in

# hint: simulator params are
    # input_neuron_file
    # input_synapse_file
    # input_spike_file
    # input_global_file
    # output_neuron_file
    # output_synapse_file
    # output_spike_file
    # output_global_file
    # trace_commando_file

# delete tmp dir
rm -R $FIFODIR
contact: Jan Huwald // Impressum