Overview
Comment:Script to create cbg.dia files from abg.dia, ibg.m, connections.dat and cbg.m.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: fbfb49ce87a3fa3c16d2ccd279c9b319601364390d00919962fb28677302293a
User & Date: geraint@users.sourceforge.net on 2004-08-26 00:06:28
Other Links: branch diff | manifest | tags
Context
2004-08-26
00:07:06
Added rule to create cbg.dia. check-in: ab09c2c2f6 user: geraint@users.sourceforge.net tags: origin/master, trunk
00:06:28
Script to create cbg.dia files from abg.dia, ibg.m, connections.dat and cbg.m. check-in: fbfb49ce87 user: geraint@users.sourceforge.net tags: origin/master, trunk
00:05:09
Creates _connections.dat. Records component names at the end of each (possibly vector-expanded) bond. check-in: ad0591cdc4 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Added mttroot/mtt/bin/trans/cbg_m2dia version [dbd56a874e].



























































































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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

### cbg_m2dia
##
## Creates cbg.dia from:
## abg.dia, ibg.m, connections.dat, cbg.m
##
## Copyright (C) 2004 by Geraint Paul Bevan

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################

set -e

sys=$1
name=$2

## need to fix MTT to create connections.dat using make
## in the meantime:
mtt -q ${sys} connections dat

dia=${sys}_abg.dia
if [ ! -f ${dia} ]; then
    # probably not a dia model
    exit;
fi

echo Creating ${name}_cbg.dia -- component type ${sys}

con=${sys}_connections.dat
out=${name}_cbg.dia

${MATRIX:-octave} -q <<EOF > cbg_m2dia_spec.txt
ibg	= ${sys}_ibg;
cbg	= ${name}_cbg;

## get connections data: ${sys}_connections
## structure with two cell arrays: head and tail 
## the index of each array element is the bond index
## the value of each array element is a component name
load -ascii ${sys}_connections.dat;
con	= ${sys}_connections;

nibgbonds = length (fieldnames (ibg.bonds));
ncbgbonds = length (con.head);

## map cbg data to connection data
for [bond, bond_name] = ibg.bonds

  head = bond.head.component;
  tail = bond.tail.component;

  i = index (head, ':');
  head = substr (head, i+1, length(head)-i);

  i = index (tail, ':');
  tail = substr (tail, i+1, length(tail)-i);

  ## index of bond in diagram
  idia = str2num (strrep (bond_name, "bond", ""));

  ## find index of bond in cbg
  e(idia) = f(idia) = 0;
  for i = 1 : ncbgbonds
    if (strcmp (con.head{i}, deblank (head)) && ...
	strcmp (con.tail{i}, deblank (tail)))
      e (idia) = cbg.bonds (i, 1); # effort
      f (idia) = cbg.bonds (i, 2); # flow
   endif
  endfor
endfor

espec	= "--change_effort_causality ";
fspec	= "--change_flow_causality   ";
for i = 1 : nibgbonds
  espec = sprintf ("%s%d:%d;", espec, i, e(i));
  fspec = sprintf ("%s%d:%d;", fspec, i, f(i));
endfor
disp (espec)
disp (fspec)
EOF

spec=`cat cbg_m2dia_spec.txt`

/usr/local/src/mtt/mttroot/mtt/bin/trans/dia2abg.pl \
    --diagram_name    $sys	\
    --dia_input_file  $dia	\
    --dia_output_file $out	\
    $spec


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]