tecscde 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rubocop.yml +125 -0
  4. data/.rubocop_todo.yml +188 -0
  5. data/CHANGELOG.md +3 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE +46 -0
  8. data/LICENSE.ja +32 -0
  9. data/README.ja.md +200 -0
  10. data/README.md +35 -0
  11. data/Rakefile +27 -0
  12. data/bin/tecscde +64 -0
  13. data/glade/tecscde-cell-property.glade +205 -0
  14. data/glade/tecscde-celltype-property.glade +172 -0
  15. data/glade/tecscde-celltype.glade +414 -0
  16. data/glade/tecscde-export.glade +161 -0
  17. data/glade/test-cell-plugin.rb +51 -0
  18. data/glade/test-cell-property.rb +35 -0
  19. data/glade/test-export.rb +35 -0
  20. data/glade/test-palette.rb +26 -0
  21. data/lib/tcflow.rb +148 -0
  22. data/lib/tecscde.rb +65 -0
  23. data/lib/tecscde/NewCell.png +0 -0
  24. data/lib/tecscde/SelectArrow.png +0 -0
  25. data/lib/tecscde/attr_tree_view.rb +253 -0
  26. data/lib/tecscde/cell_plugin_dialog.glade +294 -0
  27. data/lib/tecscde/cell_plugin_dialog.rb +89 -0
  28. data/lib/tecscde/celltype_tree_view.rb +105 -0
  29. data/lib/tecscde/change_set_control.rb +35 -0
  30. data/lib/tecscde/change_set_control/change_set.rb +32 -0
  31. data/lib/tecscde/change_set_control/change_set_manager.rb +62 -0
  32. data/lib/tecscde/command.rb +35 -0
  33. data/lib/tecscde/control.rb +491 -0
  34. data/lib/tecscde/highlighted_objects.rb +180 -0
  35. data/lib/tecscde/logger.rb +74 -0
  36. data/lib/tecscde/main_view_and_model.rb +80 -0
  37. data/lib/tecscde/palette.glade +553 -0
  38. data/lib/tecscde/palette.rb +174 -0
  39. data/lib/tecscde/preferences.glade +117 -0
  40. data/lib/tecscde/preferences.rb +44 -0
  41. data/lib/tecscde/tecs_model.rb +1137 -0
  42. data/lib/tecscde/tecs_model/hbar.rb +68 -0
  43. data/lib/tecscde/tecs_model/tm_c_port.rb +122 -0
  44. data/lib/tecscde/tecs_model/tm_c_port_array.rb +98 -0
  45. data/lib/tecscde/tecs_model/tm_cell.rb +496 -0
  46. data/lib/tecscde/tecs_model/tm_e_port.rb +126 -0
  47. data/lib/tecscde/tecs_model/tm_e_port_array.rb +78 -0
  48. data/lib/tecscde/tecs_model/tm_join.rb +293 -0
  49. data/lib/tecscde/tecs_model/tm_join_bar.rb +146 -0
  50. data/lib/tecscde/tecs_model/tm_port.rb +238 -0
  51. data/lib/tecscde/tecs_model/tm_port_array.rb +246 -0
  52. data/lib/tecscde/tecs_model/tm_region.rb +107 -0
  53. data/lib/tecscde/tecs_model/tm_uneditable.rb +68 -0
  54. data/lib/tecscde/tecs_model/vbar.rb +68 -0
  55. data/lib/tecscde/templates/_cell_info.cde.erb +15 -0
  56. data/lib/tecscde/templates/_join_info.cde.erb +28 -0
  57. data/lib/tecscde/templates/main.cde.erb +49 -0
  58. data/lib/tecscde/tm_object.rb +91 -0
  59. data/lib/tecscde/version.rb +4 -0
  60. data/lib/tecscde/view.rb +58 -0
  61. data/lib/tecscde/view/cairo_matrix.rb +90 -0
  62. data/lib/tecscde/view/canvas.rb +59 -0
  63. data/lib/tecscde/view/constants.rb +114 -0
  64. data/lib/tecscde/view/main_view.rb +1245 -0
  65. data/lib/tecsflow.rb +475 -0
  66. data/lib/tecsflow/C_parser.tab.rb +2471 -0
  67. data/lib/tecsflow/C_parser.y.rb +1087 -0
  68. data/lib/tecsflow/classes.rb +421 -0
  69. data/lib/tecsgen.rb +581 -0
  70. data/lib/tecsgen/core/C_parser.tab.rb +2477 -0
  71. data/lib/tecsgen/core/C_parser.y +1032 -0
  72. data/lib/tecsgen/core/bnf-deb.tab.rb +5193 -0
  73. data/lib/tecsgen/core/bnf.tab.rb +5193 -0
  74. data/lib/tecsgen/core/bnf.y +2211 -0
  75. data/lib/tecsgen/core/componentobj.rb +7901 -0
  76. data/lib/tecsgen/core/ctypes.rb +226 -0
  77. data/lib/tecsgen/core/expression.rb +1031 -0
  78. data/lib/tecsgen/core/gen_xml.rb +374 -0
  79. data/lib/tecsgen/core/generate.rb +5206 -0
  80. data/lib/tecsgen/core/location.rb +116 -0
  81. data/lib/tecsgen/core/messages.rb +101 -0
  82. data/lib/tecsgen/core/optimize.rb +456 -0
  83. data/lib/tecsgen/core/plugin.rb +332 -0
  84. data/lib/tecsgen/core/pluginModule.rb +165 -0
  85. data/lib/tecsgen/core/syntaxobj.rb +1234 -0
  86. data/lib/tecsgen/core/tecs_lang.rb +306 -0
  87. data/lib/tecsgen/core/tecsgen.rb +453 -0
  88. data/lib/tecsgen/core/tecsinfo.rb +860 -0
  89. data/lib/tecsgen/core/tool_info.rb +258 -0
  90. data/lib/tecsgen/core/types.rb +1632 -0
  91. data/lib/tecsgen/core/unjoin_plugin.rb +218 -0
  92. data/lib/tecsgen/core/value.rb +650 -0
  93. data/lib/tecsgen/messages/messages_console_en_US.rb +1171 -0
  94. data/lib/tecsgen/messages/messages_console_ja_JP.rb +1171 -0
  95. data/lib/tecsgen/messages/messages_file_en_US.rb +334 -0
  96. data/lib/tecsgen/messages/messages_file_ja_JP.rb +163 -0
  97. data/lib/tecsgen/plugin/ATK1AlarmPlugin.rb +196 -0
  98. data/lib/tecsgen/plugin/ATK1DelayTaskPlugin.rb +106 -0
  99. data/lib/tecsgen/plugin/ATK1EventPlugin.rb +147 -0
  100. data/lib/tecsgen/plugin/ATK1ISRPlugin.rb +174 -0
  101. data/lib/tecsgen/plugin/ATK1KernelPlugin.rb +287 -0
  102. data/lib/tecsgen/plugin/ATK1ResourcePlugin.rb +124 -0
  103. data/lib/tecsgen/plugin/ATK1TaskPlugin.rb +220 -0
  104. data/lib/tecsgen/plugin/C2TECSBridgePlugin.rb +210 -0
  105. data/lib/tecsgen/plugin/CellPlugin.rb +61 -0
  106. data/lib/tecsgen/plugin/CelltypePlugin.rb +72 -0
  107. data/lib/tecsgen/plugin/CompositePlugin.rb +66 -0
  108. data/lib/tecsgen/plugin/DomainPlugin.rb +89 -0
  109. data/lib/tecsgen/plugin/HRP2AlarmHandlerPlugin.rb +76 -0
  110. data/lib/tecsgen/plugin/HRP2Cache.rb +1 -0
  111. data/lib/tecsgen/plugin/HRP2CyclicHandlerPlugin.rb +75 -0
  112. data/lib/tecsgen/plugin/HRP2DataqueuePlugin.rb +68 -0
  113. data/lib/tecsgen/plugin/HRP2EventflagPlugin.rb +68 -0
  114. data/lib/tecsgen/plugin/HRP2FixedSizeMemoryPoolPlugin.rb +68 -0
  115. data/lib/tecsgen/plugin/HRP2HandlerPlugin.rb +117 -0
  116. data/lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb +372 -0
  117. data/lib/tecsgen/plugin/HRP2ObjectPlugin.rb +94 -0
  118. data/lib/tecsgen/plugin/HRP2Plugin.rb +140 -0
  119. data/lib/tecsgen/plugin/HRP2PostHook.rb +111 -0
  120. data/lib/tecsgen/plugin/HRP2PriorityDataqueuePlugin.rb +66 -0
  121. data/lib/tecsgen/plugin/HRP2RPCPlugin.rb +319 -0
  122. data/lib/tecsgen/plugin/HRP2SVCPlugin.rb +473 -0
  123. data/lib/tecsgen/plugin/HRP2SemaphorePlugin.rb +67 -0
  124. data/lib/tecsgen/plugin/HRP2TaskPlugin.rb +200 -0
  125. data/lib/tecsgen/plugin/HRPHandlerPlugin.rb +125 -0
  126. data/lib/tecsgen/plugin/HRPKernelObjectManager.rb +72 -0
  127. data/lib/tecsgen/plugin/HRPKernelObjectPlugin.rb +333 -0
  128. data/lib/tecsgen/plugin/HRPObjectPlugin.rb +93 -0
  129. data/lib/tecsgen/plugin/HRPPlugin.rb +356 -0
  130. data/lib/tecsgen/plugin/HRPRPCPlugin.rb +407 -0
  131. data/lib/tecsgen/plugin/HRPSVCPlugin.rb +859 -0
  132. data/lib/tecsgen/plugin/HRPTaskPlugin.rb +107 -0
  133. data/lib/tecsgen/plugin/Mruby2CBridgePlugin.rb +86 -0
  134. data/lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb +264 -0
  135. data/lib/tecsgen/plugin/MrubyBridgeCelltypePlugin.rb +293 -0
  136. data/lib/tecsgen/plugin/MrubyBridgeCompositePlugin.rb +49 -0
  137. data/lib/tecsgen/plugin/MrubyBridgePlugin.rb +67 -0
  138. data/lib/tecsgen/plugin/MrubyBridgeSignaturePlugin.rb +1307 -0
  139. data/lib/tecsgen/plugin/MrubyInfoBridgePlugin.rb +14 -0
  140. data/lib/tecsgen/plugin/MrubyInfoBridgeSignaturePlugin.rb +994 -0
  141. data/lib/tecsgen/plugin/MultiPlugin.rb +57 -0
  142. data/lib/tecsgen/plugin/NotifierPlugin.rb +1217 -0
  143. data/lib/tecsgen/plugin/OpaqueMarshalerPlugin.rb +81 -0
  144. data/lib/tecsgen/plugin/OpaqueRPCPlugin.rb +323 -0
  145. data/lib/tecsgen/plugin/RPCPlugin.rb +266 -0
  146. data/lib/tecsgen/plugin/RepeatCellPlugin.rb +166 -0
  147. data/lib/tecsgen/plugin/RepeatJoinPlugin.rb +130 -0
  148. data/lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb +357 -0
  149. data/lib/tecsgen/plugin/SharedRPCPlugin.rb +329 -0
  150. data/lib/tecsgen/plugin/SignaturePlugin.rb +77 -0
  151. data/lib/tecsgen/plugin/TECS2CBridgePlugin.rb +178 -0
  152. data/lib/tecsgen/plugin/TECSInfoPlugin.rb +280 -0
  153. data/lib/tecsgen/plugin/ThroughPlugin.rb +333 -0
  154. data/lib/tecsgen/plugin/TracePlugin.rb +484 -0
  155. data/lib/tecsgen/plugin/lib/GenHRP2Marshaler.rb +761 -0
  156. data/lib/tecsgen/plugin/lib/GenOpaqueMarshaler.rb +1107 -0
  157. data/lib/tecsgen/plugin/lib/GenParamCopy.rb +365 -0
  158. data/lib/tecsgen/plugin/lib/GenTransparentMarshaler.rb +683 -0
  159. data/lib/tecsgen/plugin/lib/MrubyBridgeCelltypePluginModule.rb +283 -0
  160. data/lib/tecsgen/plugin/lib/MrubyBridgeSignaturePluginModule.rb +277 -0
  161. data/lib/tecsgen/version.rb +6 -0
  162. data/samples/FigureSamples/active/active.cde +104 -0
  163. data/samples/FigureSamples/active/active.cdl +20 -0
  164. data/samples/FigureSamples/active/active.pdf +0 -0
  165. data/samples/FigureSamples/active/active.png +0 -0
  166. data/samples/FigureSamples/active/gen/tmp_C_src.c +36 -0
  167. data/samples/FigureSamples/active/gen/tmp_cygwin_tecs.h +1908 -0
  168. data/samples/FigureSamples/active/gen/tmp_plugin_post_code.cdl +0 -0
  169. data/samples/FigureSamples/allocator/allocator-internal.png +0 -0
  170. data/samples/FigureSamples/allocator/allocator.cde +171 -0
  171. data/samples/FigureSamples/allocator/allocator.cdl +58 -0
  172. data/samples/FigureSamples/allocator/allocator.png +0 -0
  173. data/samples/FigureSamples/basic/Makefile +87 -0
  174. data/samples/FigureSamples/basic/SimpleSample-trace.cdl +50 -0
  175. data/samples/FigureSamples/basic/SimpleSample.cde +91 -0
  176. data/samples/FigureSamples/basic/SimpleSample.cdl +47 -0
  177. data/samples/FigureSamples/basic/basic.cde +93 -0
  178. data/samples/FigureSamples/basic/basic.cdl +46 -0
  179. data/samples/FigureSamples/basic/basic.png +0 -0
  180. data/samples/FigureSamples/callback/callback.cde +130 -0
  181. data/samples/FigureSamples/callback/callback.cdl +29 -0
  182. data/samples/FigureSamples/callback/callback.png +0 -0
  183. data/samples/FigureSamples/carray/carray.cde +144 -0
  184. data/samples/FigureSamples/carray/carray.cdl +38 -0
  185. data/samples/FigureSamples/carray/carray.png +0 -0
  186. data/samples/FigureSamples/cearray/cearray.cde +314 -0
  187. data/samples/FigureSamples/cearray/cearray.cdl +60 -0
  188. data/samples/FigureSamples/cearray/cearray.png +0 -0
  189. data/samples/FigureSamples/composite/composite-internal.png +0 -0
  190. data/samples/FigureSamples/composite/composite.cde +216 -0
  191. data/samples/FigureSamples/composite/composite.cdl +95 -0
  192. data/samples/FigureSamples/composite/composite.png +0 -0
  193. data/samples/FigureSamples/earray/earray.cde +142 -0
  194. data/samples/FigureSamples/earray/earray.cdl +38 -0
  195. data/samples/FigureSamples/earray/earray.png +0 -0
  196. data/samples/FigureSamples/join/Makefile +87 -0
  197. data/samples/FigureSamples/join/join.cde +132 -0
  198. data/samples/FigureSamples/join/join.cdl +40 -0
  199. data/samples/FigureSamples/join/join.png +0 -0
  200. data/samples/FigureSamples/relay/Makefile +99 -0
  201. data/samples/FigureSamples/relay/relay-internal.png +0 -0
  202. data/samples/FigureSamples/relay/relay.cde +284 -0
  203. data/samples/FigureSamples/relay/relay.cdl +52 -0
  204. data/samples/FigureSamples/relay/relay.png +0 -0
  205. data/samples/FigureSamples/rpc/Makefile +123 -0
  206. data/samples/FigureSamples/rpc/rpc-expand.png +0 -0
  207. data/samples/FigureSamples/rpc/rpc.cde +245 -0
  208. data/samples/FigureSamples/rpc/rpc.png +0 -0
  209. data/samples/FigureSamples/rpc/rpc_sample.cdl +53 -0
  210. data/samples/SimpleSample/Makefile +25 -0
  211. data/samples/SimpleSample/SimpleSample/Makefile +86 -0
  212. data/samples/SimpleSample/SimpleSample/Makefile-trace +91 -0
  213. data/samples/SimpleSample/SimpleSample/README.txt +106 -0
  214. data/samples/SimpleSample/SimpleSample/SimpleSample-trace.cdl +50 -0
  215. data/samples/SimpleSample/SimpleSample/SimpleSample.cdl +45 -0
  216. data/samples/SimpleSample/SimpleSample/src/tSample.c +77 -0
  217. data/samples/SimpleSample/SimpleSample/src/tSimple.c +48 -0
  218. data/samples/SimpleSample/SimpleSample/src/tecs-types.h +27 -0
  219. data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile +51 -0
  220. data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile-trace +91 -0
  221. data/samples/SimpleSample/SimpleSampleOpaqueRPC/README.txt +106 -0
  222. data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample-trace.cdl +80 -0
  223. data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample.cdl +77 -0
  224. data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSample/Makefile +112 -0
  225. data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSimple/Makefile +109 -0
  226. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSample.c +80 -0
  227. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSimple.c +47 -0
  228. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tTaskMain.c +66 -0
  229. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tecs-types.h +27 -0
  230. data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile +125 -0
  231. data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile-trace +130 -0
  232. data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample-trace.cdl +54 -0
  233. data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample.cdl +53 -0
  234. data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSample.c +80 -0
  235. data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSimple.c +54 -0
  236. data/tecscde.gemspec +41 -0
  237. metadata +353 -0
@@ -0,0 +1,146 @@
1
+ #
2
+ # TECSCDE - TECS Component Diagram Editor
3
+ #
4
+ # Copyright (C) 2014-2019 by TOPPERS Project
5
+ #
6
+ # The above copyright holders grant permission gratis to use,
7
+ # duplicate, modify, or redistribute (hereafter called use) this
8
+ # software (including the one made by modifying this software),
9
+ # provided that the following four conditions (1) through (4) are
10
+ # satisfied.
11
+ #
12
+ # (1) When this software is used in the form of source code, the above
13
+ # copyright notice, this use conditions, and the disclaimer shown
14
+ # below must be retained in the source code without modification.
15
+ #
16
+ # (2) When this software is redistributed in the forms usable for the
17
+ # development of other software, such as in library form, the above
18
+ # copyright notice, this use conditions, and the disclaimer shown
19
+ # below must be shown without modification in the document provided
20
+ # with the redistributed software, such as the user manual.
21
+ #
22
+ # (3) When this software is redistributed in the forms unusable for the
23
+ # development of other software, such as the case when the software
24
+ # is embedded in a piece of equipment, either of the following two
25
+ # conditions must be satisfied:
26
+ #
27
+ # (a) The above copyright notice, this use conditions, and the
28
+ # disclaimer shown below must be shown without modification in
29
+ # the document provided with the redistributed software, such as
30
+ # the user manual.
31
+ #
32
+ # (b) How the software is to be redistributed must be reported to the
33
+ # TOPPERS Project according to the procedure described
34
+ # separately.
35
+ #
36
+ # (4) The above copyright holders and the TOPPERS Project are exempt
37
+ # from responsibility for any type of damage directly or indirectly
38
+ # caused from the use of this software and are indemnified by any
39
+ # users or end users of this software from any and all causes of
40
+ # action whatsoever.
41
+ #
42
+ # THIS SOFTWARE IS PROVIDED "AS IS." THE ABOVE COPYRIGHT HOLDERS AND
43
+ # THE TOPPERS PROJECT DISCLAIM ANY EXPRESS OR IMPLIED WARRANTIES,
44
+ # INCLUDING, BUT NOT LIMITED TO, ITS APPLICABILITY TO A PARTICULAR
45
+ # PURPOSE. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS AND THE
46
+ # TOPPERS PROJECT BE LIABLE FOR ANY TYPE OF DAMAGE DIRECTLY OR
47
+ # INDIRECTLY CAUSED FROM THE USE OF THIS SOFTWARE.
48
+ #
49
+
50
+ require "tecscde/tm_object"
51
+
52
+ module TECSCDE
53
+ class TECSModel
54
+ class TmJoinBar < TECSCDE::TmObject
55
+ # @position::Integer(mm) # horizontal(x) or vertical(y) position
56
+ # @owner::TmJoin (Reverse Reference)
57
+ def initialize(position, owner_join)
58
+ @position = position
59
+ @owner = owner_join
60
+ modified {}
61
+ end
62
+
63
+ #=== TmJoinBar#get_position ***
64
+ def get_position
65
+ @position
66
+ end
67
+
68
+ def set_position(position)
69
+ modified do
70
+ @position = TECSCDE::TECSModel.round_length_val(position)
71
+ end
72
+ end
73
+
74
+ def moved(inc)
75
+ set_position(@position + inc)
76
+ end
77
+
78
+ # def set_join join
79
+ # @owner = join
80
+ # end
81
+
82
+ #=== TmJoinBar#get_join ***
83
+ def get_join
84
+ @owner
85
+ end
86
+
87
+ #=== TmJoinBar#move ***
88
+ # actually moving previous next bar
89
+ # 1st bar and last bar can not be moved (necessary cport, eport move)
90
+ def move(x_inc, y_inc)
91
+ modified do
92
+ bar_prev = nil
93
+ bars = @owner.bars
94
+
95
+ if bars.length >= 1 && bars[bars.length - 1] == self
96
+ @owner.eport.move(x_inc, y_inc)
97
+ return # last bar
98
+ end
99
+
100
+ bars.each do |bar|
101
+ if bar.equal?(self)
102
+ break
103
+ end
104
+ bar_prev = bar
105
+ end
106
+
107
+ if bar_prev # prev_bar is nil if self is 1st bar
108
+ # p "bar_prev exist"
109
+ if bar_prev.horizontal?
110
+ xm = bar_prev.get_position + x_inc
111
+ bar_prev.set_position(model.clip_x(xm))
112
+ else
113
+ ym = bar_prev.get_position + y_inc
114
+ bar_prev.set_position(model.clip_y(ym))
115
+ end
116
+ else
117
+ # 1st bar
118
+ @owner.cport.move(x_inc, y_inc)
119
+ end
120
+ end
121
+ end
122
+
123
+ #=== TmJoinBar#clone_for_undo
124
+ def clone_for_undo
125
+ bu = clone
126
+ bu.copy_from(self)
127
+ bu
128
+ end
129
+
130
+ def horizontal?
131
+ raise NotImplementedError
132
+ end
133
+
134
+ def vertical?
135
+ raise NotImplementedError
136
+ end
137
+
138
+ def type
139
+ raise NotImplementedError
140
+ end
141
+ end
142
+ end
143
+ end
144
+
145
+ require "tecscde/tecs_model/hbar"
146
+ require "tecscde/tecs_model/vbar"
@@ -0,0 +1,238 @@
1
+ #
2
+ # TECSCDE - TECS Component Diagram Editor
3
+ #
4
+ # Copyright (C) 2014-2019 by TOPPERS Project
5
+ #
6
+ # The above copyright holders grant permission gratis to use,
7
+ # duplicate, modify, or redistribute (hereafter called use) this
8
+ # software (including the one made by modifying this software),
9
+ # provided that the following four conditions (1) through (4) are
10
+ # satisfied.
11
+ #
12
+ # (1) When this software is used in the form of source code, the above
13
+ # copyright notice, this use conditions, and the disclaimer shown
14
+ # below must be retained in the source code without modification.
15
+ #
16
+ # (2) When this software is redistributed in the forms usable for the
17
+ # development of other software, such as in library form, the above
18
+ # copyright notice, this use conditions, and the disclaimer shown
19
+ # below must be shown without modification in the document provided
20
+ # with the redistributed software, such as the user manual.
21
+ #
22
+ # (3) When this software is redistributed in the forms unusable for the
23
+ # development of other software, such as the case when the software
24
+ # is embedded in a piece of equipment, either of the following two
25
+ # conditions must be satisfied:
26
+ #
27
+ # (a) The above copyright notice, this use conditions, and the
28
+ # disclaimer shown below must be shown without modification in
29
+ # the document provided with the redistributed software, such as
30
+ # the user manual.
31
+ #
32
+ # (b) How the software is to be redistributed must be reported to the
33
+ # TOPPERS Project according to the procedure described
34
+ # separately.
35
+ #
36
+ # (4) The above copyright holders and the TOPPERS Project are exempt
37
+ # from responsibility for any type of damage directly or indirectly
38
+ # caused from the use of this software and are indemnified by any
39
+ # users or end users of this software from any and all causes of
40
+ # action whatsoever.
41
+ #
42
+ # THIS SOFTWARE IS PROVIDED "AS IS." THE ABOVE COPYRIGHT HOLDERS AND
43
+ # THE TOPPERS PROJECT DISCLAIM ANY EXPRESS OR IMPLIED WARRANTIES,
44
+ # INCLUDING, BUT NOT LIMITED TO, ITS APPLICABILITY TO A PARTICULAR
45
+ # PURPOSE. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS AND THE
46
+ # TOPPERS PROJECT BE LIABLE FOR ANY TYPE OF DAMAGE DIRECTLY OR
47
+ # INDIRECTLY CAUSED FROM THE USE OF THIS SOFTWARE.
48
+ #
49
+
50
+ require "tecscde/tm_object"
51
+ require "tecscde/tecs_model/hbar"
52
+ require "tecscde/tecs_model/vbar"
53
+
54
+ module TECSCDE
55
+ class TECSModel
56
+ class TmPort < TECSCDE::TmObject
57
+ # @edge_side::Integer()
58
+ # @offset::Integer(mm) # distance from top or left side
59
+ # @owner::TmCell | TmXPortArray (Reverse Reference)
60
+ # @port_def:: ::Port
61
+ # @subscript::Integer | Nil
62
+
63
+ attr_reader :offset
64
+
65
+ #=== TmPort#move
66
+ def move(x_inc, y_inc)
67
+ modified do
68
+ # p "move x=#{x_inc} y=#{y_inc}"
69
+ _x, _y, w, h = owner_cell.get_geometry
70
+ case @edge_side
71
+ when EDGE_LEFT, EDGE_RIGHT
72
+ offs = TECSModel.round_length_val(@offset + y_inc)
73
+ if offs < 0 || offs > h
74
+ return
75
+ end
76
+ x_inc = 0
77
+ when EDGE_TOP, EDGE_BOTTOM
78
+ offs = TECSCDE::TECSModel.round_length_val(@offset + x_inc)
79
+ # p "offs=#{offs} x=#{x} w=#{w}"
80
+ if offs < 0 || offs > w
81
+ return
82
+ end
83
+ y_inc = 0
84
+ end
85
+ @offset = offs
86
+ moved_edge(x_inc, x_inc, y_inc, y_inc)
87
+ end
88
+ end
89
+
90
+ #=== TmPort#moved_edge
91
+ # moved cell's edge
92
+ # x_inc_l::Float : left edge moved, value is incremental
93
+ # x_inc_r::Float : right edge moved, value is incremental
94
+ # y_inc_t::Float : top edge moved, value is incremental
95
+ # y_inc_b::Float : bottom edge moved, value is incremental
96
+ def moved_edge(x_inc_l, x_inc_r, y_inc_t, y_inc_b)
97
+ case @edge_side
98
+ when EDGE_TOP, EDGE_LEFT
99
+ moved(x_inc_l, y_inc_t)
100
+ when EDGE_BOTTOM
101
+ moved(x_inc_l, y_inc_b)
102
+ when EDGE_RIGHT
103
+ moved(x_inc_r, y_inc_t)
104
+ end
105
+ end
106
+
107
+ #=== tmport#get_normal_bar_of_edge
108
+ # (1) (6) bar from call port. this indicate A position.
109
+ # join::TmJoin
110
+ def get_normal_bar_of_edge(join)
111
+ pos = get_cell.get_edge_position_in_normal_dir(@edge_side) + CPGAP * TECSModel.get_sign_of_normal(@edge_side)
112
+ if TECSCDE::TECSModel.vertical?(@edge_side)
113
+ TECSCDE::TECSModel::HBar.new(pos, join)
114
+ else
115
+ TECSCDE::TECSModel::VBar.new(pos, join)
116
+ end
117
+ end
118
+
119
+ #=== TmPort#get_position_in_tangential_dir
120
+ def get_position_in_tangential_dir
121
+ x, y, _width, _height = get_cell.get_geometry
122
+ TECSCDE::TECSModel.vertical?(@edge_side) ? y + @offset : x + @offset
123
+ end
124
+
125
+ def get_position_in_normal_dir
126
+ get_cell.get_edge_position_in_normal_dir(@edge_side)
127
+ end
128
+
129
+ def get_sign_of_normal
130
+ TECSCDE::TECSModel.get_sign_of_normal(@edge_side)
131
+ end
132
+
133
+ def get_edge_side
134
+ @edge_side
135
+ end
136
+
137
+ def get_edge_side_name
138
+ case @edge_side
139
+ when EDGE_TOP
140
+ :EDGE_TOP
141
+ when EDGE_BOTTOM
142
+ :EDGE_BOTTOM
143
+ when EDGE_LEFT
144
+ :EDGE_LEFT
145
+ when EDGE_RIGHT
146
+ :EDGE_RIGHT
147
+ end
148
+ end
149
+
150
+ def get_cell
151
+ if @owner.is_a?(TECSCDE::TECSModel::TmCell)
152
+ @owner
153
+ else
154
+ @owner.owner
155
+ end
156
+ end
157
+
158
+ def get_position
159
+ x, y, w, h = get_cell.get_geometry
160
+ case @edge_side
161
+ when EDGE_TOP
162
+ [x + @offset, y]
163
+ when EDGE_BOTTOM
164
+ [x + @offset, y + h]
165
+ when EDGE_LEFT
166
+ [x, y + @offset]
167
+ when EDGE_RIGHT
168
+ [x + w, y + @offset]
169
+ end
170
+ end
171
+
172
+ def get_name
173
+ @port_def.get_name
174
+ end
175
+
176
+ #=== TmPort# get_signature
177
+ # RETURN::Signature
178
+ def get_signature
179
+ @port_def.get_signature
180
+ end
181
+
182
+ def get_subscript
183
+ @subscript
184
+ end
185
+
186
+ def set_subscript(subscript)
187
+ modified do
188
+ @subscript = subscript
189
+ end
190
+ end
191
+
192
+ #=== TmPort#array?
193
+ def array?
194
+ false
195
+ end
196
+
197
+ #=== TmPort#set_position
198
+ def set_position(edge_side, offset)
199
+ modified do
200
+ @edge_side = edge_side
201
+ @offset = TECSCDE::TECSModel.round_length_val(offset)
202
+ end
203
+ end
204
+
205
+ #=== TmPort#delete_highlighted
206
+ # delete_highlighted if this port is a member of unsubscripted array.
207
+ def delete_highlighted
208
+ return unless @owner.editable?
209
+ return unless @owner.is_a?(TECSCDE::TECSModel::TmPortArray)
210
+ @owner.delete_highlighted(self)
211
+ end
212
+
213
+ #=== TmPort#insert
214
+ # before_after::Symbol: :before, :after
215
+ # insert if this port is a member of unsubscripted array.
216
+ def insert(before_after)
217
+ return unless @owner.is_a?(TECSCDE::TECSModel::TmPortArray)
218
+ @owner.insert(self, before_after)
219
+ end
220
+
221
+ #=== TmPort#editable?
222
+ def editable?
223
+ @owner.editable?
224
+ end
225
+
226
+ #=== TmPort#owner_cell
227
+ def owner_cell
228
+ if @owner.is_a?(TECSCDE::TECSModel::TmCell)
229
+ @owner
230
+ elsif @owner.is_a?(TECSCDE::TECSModel::TmPortArray)
231
+ @owner.owner
232
+ else
233
+ raise "unknown cell"
234
+ end
235
+ end
236
+ end
237
+ end
238
+ end
@@ -0,0 +1,246 @@
1
+ #
2
+ # TECSCDE - TECS Component Diagram Editor
3
+ #
4
+ # Copyright (C) 2014-2019 by TOPPERS Project
5
+ #
6
+ # The above copyright holders grant permission gratis to use,
7
+ # duplicate, modify, or redistribute (hereafter called use) this
8
+ # software (including the one made by modifying this software),
9
+ # provided that the following four conditions (1) through (4) are
10
+ # satisfied.
11
+ #
12
+ # (1) When this software is used in the form of source code, the above
13
+ # copyright notice, this use conditions, and the disclaimer shown
14
+ # below must be retained in the source code without modification.
15
+ #
16
+ # (2) When this software is redistributed in the forms usable for the
17
+ # development of other software, such as in library form, the above
18
+ # copyright notice, this use conditions, and the disclaimer shown
19
+ # below must be shown without modification in the document provided
20
+ # with the redistributed software, such as the user manual.
21
+ #
22
+ # (3) When this software is redistributed in the forms unusable for the
23
+ # development of other software, such as the case when the software
24
+ # is embedded in a piece of equipment, either of the following two
25
+ # conditions must be satisfied:
26
+ #
27
+ # (a) The above copyright notice, this use conditions, and the
28
+ # disclaimer shown below must be shown without modification in
29
+ # the document provided with the redistributed software, such as
30
+ # the user manual.
31
+ #
32
+ # (b) How the software is to be redistributed must be reported to the
33
+ # TOPPERS Project according to the procedure described
34
+ # separately.
35
+ #
36
+ # (4) The above copyright holders and the TOPPERS Project are exempt
37
+ # from responsibility for any type of damage directly or indirectly
38
+ # caused from the use of this software and are indemnified by any
39
+ # users or end users of this software from any and all causes of
40
+ # action whatsoever.
41
+ #
42
+ # THIS SOFTWARE IS PROVIDED "AS IS." THE ABOVE COPYRIGHT HOLDERS AND
43
+ # THE TOPPERS PROJECT DISCLAIM ANY EXPRESS OR IMPLIED WARRANTIES,
44
+ # INCLUDING, BUT NOT LIMITED TO, ITS APPLICABILITY TO A PARTICULAR
45
+ # PURPOSE. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS AND THE
46
+ # TOPPERS PROJECT BE LIABLE FOR ANY TYPE OF DAMAGE DIRECTLY OR
47
+ # INDIRECTLY CAUSED FROM THE USE OF THIS SOFTWARE.
48
+ #
49
+
50
+ require "tecscde/tecs_model/tm_port_array"
51
+
52
+ module TECSCDE
53
+ class TECSModel
54
+ class TmPortArray < TECSCDE::TmObject
55
+ # @ports::[TmPort]
56
+ # @port_def::Port
57
+ # @actual_size::Integer
58
+ # @subscript1::subscript value of 1st element. to check consistency of subscript
59
+
60
+ attr_reader :actual_size, :ports
61
+
62
+ # TmPortArray#get_port_for_new_join
63
+ # this method is for load
64
+ def get_port_for_new_join(subscript)
65
+ if @subscript1.nil?
66
+ # 1st element of this entry array
67
+ @subscript1 = subscript
68
+ elsif (@subscript1 >= 0 && subscript < 0) || (@subscript1 < 0 && subscript >= 0)
69
+ TECSCDE.logger.error("TM9999 array subscript inconsistent (similar error to S1128)")
70
+ return nil
71
+ end
72
+
73
+ modified do
74
+ # p "new_join: for name:#{@port_def.get_name}[ #{subscript} ] owner:#{@owner.get_name}, len=#{@ports.length}"
75
+ if subscript >= 0
76
+ if subscript >= @actual_size
77
+ unless @port_def.get_array_size == "[]"
78
+ TECSCDE.logger.error("#{@owner.get_name}.#{@port_def.get_name}[#{subscript}]: subscript=#{subscript} out of range(0..(#{@actual_size - 1})")
79
+ return nil
80
+ end
81
+ # in case of unsized array, extend array
82
+ # extend array size
83
+ (0..subscript).each do |subsc|
84
+ next if @ports[subsc]
85
+ port = new_port(subsc)
86
+ @ports[subsc] = port
87
+ end
88
+ @actual_size = @ports.length
89
+ # p "new_join: 1 for name:#{@port_def.get_name}[ #{subscript} ] owner:#{@owner.get_name}, len=#{@ports.length}"
90
+ return @ports[subscript]
91
+ else
92
+ port = @ports[subscript]
93
+ # p "new_join: 2 for name:#{@port_def.get_name}[ #{subscript} ] owner:#{@owner.get_name}, len=#{@ports.length}"
94
+ return port unless instance_of?(TECSCDE::TECSModel::TmCPortArray) # CPort cannot have multiple join
95
+ if port.get_join
96
+ TECSCDE.logger.error("#{@owner.get_name}.#{@port_def.get_name}[#{subscript}]: duplicate join")
97
+ return nil
98
+ end
99
+ end
100
+ else # no index
101
+ found_port = @ports.find do |pt|
102
+ pt.get_join.nil?
103
+ end
104
+ return found_port if found_port
105
+
106
+ # in case of unsized array, extend array
107
+ if @port_def.get_array_size == "[]"
108
+ port = new_port(@ports.length)
109
+ @ports << port
110
+ @actual_size = @ports.length
111
+ return port
112
+ end
113
+ end
114
+ return nil
115
+ end
116
+ end
117
+
118
+ #=== TmPortArray#get_near_port
119
+ def get_near_port(x, y)
120
+ @ports.each do |port|
121
+ xp, yp = port.get_position
122
+ # p "get_near_port x=#{x} y=#{y} xp=#{xp} yp=#{yp}"
123
+ if ((xp - x).abs < NEAR_DIST) && ((yp - y).abs < NEAR_DIST)
124
+ # p "near port: found"
125
+ return port
126
+ end
127
+ end
128
+ nil
129
+ end
130
+
131
+ #=== TmPortArray#array?
132
+ def array?
133
+ true
134
+ end
135
+
136
+ def moved_edge(x_inc_l, x_inc_r, y_inc_t, y_inc_b)
137
+ @ports.each do |port|
138
+ port.moved_edge(x_inc_l, x_inc_r, y_inc_t, y_inc_b)
139
+ end
140
+ end
141
+
142
+ def moved(x_inc, y_inc)
143
+ @ports.each do |port|
144
+ port.moved(x_inc, y_inc)
145
+ end
146
+ end
147
+
148
+ def get_member(subscript)
149
+ if subscript < 0 || subscript >= @actual_size
150
+ nil
151
+ else
152
+ @ports[subscript]
153
+ end
154
+ end
155
+
156
+ #=== TmPortArray#delete
157
+ # this method is called from TmCell
158
+ def delete
159
+ @ports.each(&:delete)
160
+ end
161
+
162
+ #=== TmPortArray#delete_highlighted
163
+ # this method is called from Control
164
+ def delete_highlighted(port)
165
+ if @port_def.get_array_size != "[]"
166
+ TECSCDE.message_box(<<~MESSAGE, :OK)
167
+ Array size is fixed (#{@port_def.get_array_size}).
168
+ Cannot delete array member.
169
+ MESSAGE
170
+ return
171
+ end
172
+ index = @ports.index(port)
173
+ if index != 0
174
+ modified do
175
+ TECSCDE.logger.info("delete #### subscript=#{port.get_subscript}")
176
+ port.delete
177
+ if @ports.delete(port).nil?
178
+ TECSCDE.logger.info("delete: not found")
179
+ end
180
+ index = 0
181
+ @ports.each do |pt|
182
+ pt.set_subscript(index)
183
+ index += 1
184
+ end
185
+ end
186
+ else
187
+ TECSCDE.message_box(<<~MESSAGE, :OK)
188
+ cannot delete array member with subscript==0
189
+ MESSAGE
190
+ end
191
+ end
192
+
193
+ #=== TmPortArray#insert
194
+ # this method is called from Control
195
+ def insert(port, before_after)
196
+ if @port_def.get_array_size != "[]"
197
+ TECSCDE.message_box(<<~MESSAGE, :OK)
198
+ Array size is fixed (#{@port_def.get_array_size}).
199
+ Cannot insert array member.
200
+ MESSAGE
201
+ return
202
+ end
203
+ modified do
204
+ @owner.adjust_port_position_to_insert(port)
205
+ subsc = port.get_subscript
206
+ i = @ports.length - 1
207
+ while i > subsc
208
+ @ports[i].set_subscript(@ports[i].get_subscript + 1)
209
+ @ports[i + 1] = @ports[i]
210
+ i -= 1
211
+ end
212
+ new_port = new_port(subsc + 1)
213
+ new_port.set_position(port.get_edge_side, port.offset + DIST_PORT)
214
+ @ports[subsc + 1] = new_port
215
+
216
+ TECSCDE.logger.info("insert ####")
217
+ end
218
+ end
219
+
220
+ def complete?
221
+ @ports.all?(&:complete?)
222
+ end
223
+
224
+ #=== TmPortArray#editable?
225
+ def editable?
226
+ @owner.editable?
227
+ end
228
+
229
+ #=== TmPortArray#unsubscripted_array?
230
+ def unsubscripted_array?
231
+ @port_def.get_array_size == "[]"
232
+ end
233
+
234
+ #=== TmPortArray#clone_for_undo
235
+ def clone_for_undo
236
+ bu = clone
237
+ bu.copy_from(self)
238
+ bu
239
+ end
240
+
241
+ def setup_clone(ports)
242
+ @ports = ports.dup
243
+ end
244
+ end
245
+ end
246
+ end