Differences From Artifact [52de56a8f5]:

To Artifact [cf0f480a8c]:


1
2
3
4
5
6
7
8
9
10
11
12
13



14
15
16
17
18
19
20
#! /bin/sh

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

# Bourne shell script: rbg2abg_m
#
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



###############################################################

# Raw bond graph to structured acausal bond graph: mfile format
# The structured BG is described by four matrices:
#   junctions: describes the junctions -
#     Column 1   Index of component (see components)
#     Column 2.. Indices of bonds on junction (see jbonds)













>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /bin/sh

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

# Bourne shell script: rbg2abg_m
#
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1996/08/05 12:22:16  peter
## Initial revision
##
###############################################################

# Raw bond graph to structured acausal bond graph: mfile format
# The structured BG is described by four matrices:
#   junctions: describes the junctions -
#     Column 1   Index of component (see components)
#     Column 2.. Indices of bonds on junction (see jbonds)
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












91
92
93
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.


# Remove the old log file
rm -f rbg2abg_m.log
rm -f $1_abg.m
rm -f warning.txt; touch warning.txt

#Inform user
echo Creating $1_abg.m

# Use matrix manipulation to accomplish the transformation
$MATRIX > rbg2abg_m.log  2>>rbg2abg_m.log << EOF

  warningfile = 'warning.txt';
  %Convert from the fig version of the bonds to a structured version
  [rbonds,rstrokes,rcomponents,rports,n_ports] = $1_rbg;
  [bonds,components] = rbg2abg(rbonds,rstrokes,rcomponents,rports,warningfile);

  %Write the function m-file for the causal bond graph
  filename = '$1_abg.m';
  c = '%';
  fprintf(filename, 'function [bonds,components,n_ports] = $1_abg\n');
  fprintf(filename, '%s [bonds,components] = $1_abg\n', c);
  fprintf(filename, '%s Acausal bond graph created by MTT on %s\n\n', ...
                     c, date);
  mat2mfile(bonds, 'bonds', filename);
  mat2mfile(components, 'components', filename);
  fprintf(filename, 'n_ports = %1.0f;\n', n_ports);


EOF



cat warning.txt






















<





|

|


|















>
>
|
>
>
>
>
>
>
>
>
>
>
>
>



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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.


# Remove the old log file
rm -f rbg2abg_m.log
rm -f $1_abg.m


#Inform user
echo Creating $1_abg.m

# Use matrix manipulation to accomplish the transformation
$MATRIX > rbg2abg_m.log  2>mtt_err << EOF

  infofile = 'mtt_info.txt';
  %Convert from the fig version of the bonds to a structured version
  [rbonds,rstrokes,rcomponents,rports,n_ports] = $1_rbg;
  [bonds,components] = rbg2abg(rbonds,rstrokes,rcomponents,rports,infofile);

  %Write the function m-file for the causal bond graph
  filename = '$1_abg.m';
  c = '%';
  fprintf(filename, 'function [bonds,components,n_ports] = $1_abg\n');
  fprintf(filename, '%s [bonds,components] = $1_abg\n', c);
  fprintf(filename, '%s Acausal bond graph created by MTT on %s\n\n', ...
                     c, date);
  mat2mfile(bonds, 'bonds', filename);
  mat2mfile(components, 'components', filename);
  fprintf(filename, 'n_ports = %1.0f;\n', n_ports);


EOF

touch mtt_info.txt
cat mtt_info.txt

# Test for errors and print if any
err_length=$(wc -c <mtt_error)
if [ $err_length != "0" ]
then
  echo MTT has failed with the following errors '...'
  cat mtt_error
  exit 1
else
  exit 0
fi






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