Overview
Comment:split is obsolete in Octave, replaced with strsplit and strtok. Semi-colons removed during debugging for more verbose log file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 79e538ff13fd4899ba116c04a8b26feff6d8679d91bf3dbddcf51ca2c2e8a4f2
User & Date: geraint@users.sourceforge.net on 2012-10-15 19:17:19
Other Links: branch diff | manifest | tags
Context
2012-10-15
19:18:03
split is obsolete in Octave, replaced with strsplit check-in: 4b9ee6dce3 user: geraint@users.sourceforge.net tags: origin/master, trunk
19:17:19
split is obsolete in Octave, replaced with strsplit and strtok. Semi-colons removed during debugging for more verbose log file. check-in: 79e538ff13 user: geraint@users.sourceforge.net tags: origin/master, trunk
2009-11-02
16:54:03
Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char check-in: 5d73f2403a user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/ibg2abg.m from [c68472150c] to [ac24c78571].

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
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







+
-
+





-
-
+
+


-
-
+
+


-
-
+
+


-
-
+
+

+



-
+


-
+


-
+


-
+



-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+







  ################################
  ## create component structure ##
  ################################
  
  ## loop over each bond in ibg.m file
  for [bond, bond_name] = bonds
    ## get the bond number
    bond_name
    i = str2num(split(bond_name, "bond")(2,:));
    i = str2num(strtok(bond_name, "bond"))

    ## populate "head" and "tail" structures
    ## then copy the contents to an overall structure

    ## track (signed) vector bond number within each component
    head.index = +i;
    tail.index = -i;
    head.index = +i
    tail.index = -i

    ## extract type of component at each end
    head_type = deblank(split(bond.head.component, ":")(1,:));
    tail_type = deblank(split(bond.tail.component, ":")(1,:));
    head_type = deblank(char(strsplit(bond.head.component, ":"))(1,:))
    tail_type = deblank(char(strsplit(bond.tail.component, ":"))(1,:))

    ## extract name of component at each end
    head_name = deblank(split(bond.head.component, ":")(2,:));
    tail_name = deblank(split(bond.tail.component, ":")(2,:));
    head_name = deblank(char(strsplit(bond.head.component, ":"))(2,:))
    tail_name = deblank(char(strsplit(bond.tail.component, ":"))(2,:))

    ## extract port label data
    head.label = bond.head.ports;
    tail.label = bond.tail.ports;
    head.label = bond.head.ports
    tail.label = bond.tail.ports

    disp("--checking head and tail for components or ports --") 
    ## determine whether internal port or subsystem
    ## and fix names of ports
    if (strcmp(head_type, "SS") & (index(head_name, "[") == 1))
      head_comp_or_port = "port";
      head_comp_or_port = "port"
      head_name = mtt_strip_name(head_name);
    else
      head_comp_or_port = "comp";
      head_comp_or_port = "comp"
    endif
    if (strcmp(tail_type, "SS") & (index(tail_name, "[") == 1))
      tail_comp_or_port = "port";
      tail_comp_or_port = "port"
      tail_name = mtt_strip_name(tail_name);
    else
      tail_comp_or_port = "comp";
      tail_comp_or_port = "comp"
    endif

    ## copy data to object structure (objects)
    eval(sprintf("objects.%s.%s.type = '%s';",
		 head_comp_or_port, head_name, head_type));
    eval(sprintf("objects.%s.%s.type = '%s';",
		 tail_comp_or_port, tail_name, tail_type));

    eval(sprintf("objects.%s.%s.bond%i = head;", 
		 head_comp_or_port, head_name, i));
    eval(sprintf("objects.%s.%s.bond%i = tail;", 
		 tail_comp_or_port, tail_name, i));
    cmd = sprintf("objects.%s.%s.type = '%s';",
		  head_comp_or_port, head_name, head_type)
    eval(cmd)
    cmd = sprintf("objects.%s.%s.type = '%s';",
		  tail_comp_or_port, tail_name, tail_type)
    eval(cmd)
    
    cmd = sprintf("objects.%s.%s.bond%i = head;", 
		  head_comp_or_port, head_name, i)
    eval(cmd)
    cmd = sprintf("objects.%s.%s.bond%i = tail;", 
		  tail_comp_or_port, tail_name, i)
    eval(cmd)
  endfor    

  disp("--finished extracting data from ibg.m --")
  objects
    
  ## object structure:
  ##
299
300
301
302
303
304
305
306

307
308
309
310


311
312
313
314


315
316
317
318
319
320
321
305
306
307
308
309
310
311

312
313
314


315
316
317
318


319
320
321
322
323
324
325
326
327







-
+


-
-
+
+


-
-
+
+







  #########################################
  ## assign a unique number to each bond ##
  #########################################

  unique_bond_number = 0;
  
  for [bond, bond_name] = bonds
    i = str2num(split(bond_name, "bond")(2,:));
    i = str2num(strtok(bond_name, "bond"));

    ## extract type of component at each end
    head.type = deblank(split(bond.head.component, ":")(1,:));
    tail.type = deblank(split(bond.tail.component, ":")(1,:));
    head.type = deblank(char(strsplit(bond.head.component, ":"))(1,:));
    tail.type = deblank(char(strsplit(bond.tail.component, ":"))(1,:));

    ## extract name of component at each end
    head_name = deblank(split(bond.head.component, ":")(2,:));
    tail_name = deblank(split(bond.tail.component, ":")(2,:));
    head_name = deblank(char(strsplit(bond.head.component, ":"))(2,:));
    tail_name = deblank(char(strsplit(bond.tail.component, ":"))(2,:));
 
    ## determine whether internal port or subsystem
    ## and fix names of ports
    if (strcmp(head.type, "SS") & (index(head_name, "[") == 1))
      head_comp_or_port = "port";
      head_name = mtt_strip_name(head_name);
    else


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