Class: TECSCDE::TECSModel::TmPort

Inherits:
TECSCDE::TmObject show all
Defined in:
lib/tecscde/tecs_model/tm_port.rb

Direct Known Subclasses

TmCPort, TmEPort

Instance Attribute Summary collapse

Attributes inherited from TECSCDE::TmObject

#owner

Instance Method Summary collapse

Methods inherited from TECSCDE::TmObject

#copy_from, #model, #modified

Instance Attribute Details

#offsetObject (readonly)

@edge_side::Integer() @offset::Integer(mm) # distance from top or left side @owner::TmCell | TmXPortArray (Reverse Reference)

@port_def

::Port

@subscript::Integer | Nil



63
64
65
# File 'lib/tecscde/tecs_model/tm_port.rb', line 63

def offset
  @offset
end

Instance Method Details

#array?Boolean

TmPort#array?

Returns:

  • (Boolean)


193
194
195
# File 'lib/tecscde/tecs_model/tm_port.rb', line 193

def array?
  false
end

#delete_highlightedObject

TmPort#delete_highlighted

delete_highlighted if this port is a member of unsubscripted array.



207
208
209
210
211
# File 'lib/tecscde/tecs_model/tm_port.rb', line 207

def delete_highlighted
  return unless @owner.editable?
  return unless @owner.is_a?(TECSCDE::TECSModel::TmPortArray)
  @owner.delete_highlighted(self)
end

#editable?Boolean

TmPort#editable?

Returns:

  • (Boolean)


222
223
224
# File 'lib/tecscde/tecs_model/tm_port.rb', line 222

def editable?
  @owner.editable?
end

#get_cellObject



150
151
152
153
154
155
156
# File 'lib/tecscde/tecs_model/tm_port.rb', line 150

def get_cell
  if @owner.is_a?(TECSCDE::TECSModel::TmCell)
    @owner
  else
    @owner.owner
  end
end

#get_edge_sideObject



133
134
135
# File 'lib/tecscde/tecs_model/tm_port.rb', line 133

def get_edge_side
  @edge_side
end

#get_edge_side_nameObject



137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/tecscde/tecs_model/tm_port.rb', line 137

def get_edge_side_name
  case @edge_side
  when EDGE_TOP
    :EDGE_TOP
  when EDGE_BOTTOM
    :EDGE_BOTTOM
  when EDGE_LEFT
    :EDGE_LEFT
  when EDGE_RIGHT
    :EDGE_RIGHT
  end
end

#get_nameObject



172
173
174
# File 'lib/tecscde/tecs_model/tm_port.rb', line 172

def get_name
  @port_def.get_name
end

#get_normal_bar_of_edge(join) ⇒ Object

tmport#get_normal_bar_of_edge

(1) (6) bar from call port. this indicate A position. join::TmJoin



110
111
112
113
114
115
116
117
# File 'lib/tecscde/tecs_model/tm_port.rb', line 110

def get_normal_bar_of_edge(join)
  pos = get_cell.get_edge_position_in_normal_dir(@edge_side) + CPGAP * TECSModel.get_sign_of_normal(@edge_side)
  if TECSCDE::TECSModel.vertical?(@edge_side)
    TECSCDE::TECSModel::HBar.new(pos, join)
  else
    TECSCDE::TECSModel::VBar.new(pos, join)
  end
end

#get_positionObject



158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/tecscde/tecs_model/tm_port.rb', line 158

def get_position
  x, y, w, h = get_cell.get_geometry
  case @edge_side
  when EDGE_TOP
    [x + @offset, y]
  when EDGE_BOTTOM
    [x + @offset, y + h]
  when EDGE_LEFT
    [x, y + @offset]
  when EDGE_RIGHT
    [x + w, y + @offset]
  end
end

#get_position_in_normal_dirObject



125
126
127
# File 'lib/tecscde/tecs_model/tm_port.rb', line 125

def get_position_in_normal_dir
  get_cell.get_edge_position_in_normal_dir(@edge_side)
end

#get_position_in_tangential_dirObject

TmPort#get_position_in_tangential_dir



120
121
122
123
# File 'lib/tecscde/tecs_model/tm_port.rb', line 120

def get_position_in_tangential_dir
  x, y, _width, _height = get_cell.get_geometry
  TECSCDE::TECSModel.vertical?(@edge_side) ? y + @offset : x + @offset
end

#get_sign_of_normalObject



129
130
131
# File 'lib/tecscde/tecs_model/tm_port.rb', line 129

def get_sign_of_normal
  TECSCDE::TECSModel.get_sign_of_normal(@edge_side)
end

#get_signatureObject

TmPort# get_signature

RETURN::Signature



178
179
180
# File 'lib/tecscde/tecs_model/tm_port.rb', line 178

def get_signature
  @port_def.get_signature
end

#get_subscriptObject



182
183
184
# File 'lib/tecscde/tecs_model/tm_port.rb', line 182

def get_subscript
  @subscript
end

#insert(before_after) ⇒ Object

TmPort#insert

before_after::Symbol: :before, :after insert if this port is a member of unsubscripted array.



216
217
218
219
# File 'lib/tecscde/tecs_model/tm_port.rb', line 216

def insert(before_after)
  return unless @owner.is_a?(TECSCDE::TECSModel::TmPortArray)
  @owner.insert(self, before_after)
end

#move(x_inc, y_inc) ⇒ Object

TmPort#move



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/tecscde/tecs_model/tm_port.rb', line 66

def move(x_inc, y_inc)
  modified do
    # p "move x=#{x_inc} y=#{y_inc}"
    _x, _y, w, h = owner_cell.get_geometry
    case @edge_side
    when EDGE_LEFT, EDGE_RIGHT
      offs = TECSModel.round_length_val(@offset + y_inc)
      if offs < 0 || offs > h
        return
      end
      x_inc = 0
    when EDGE_TOP, EDGE_BOTTOM
      offs = TECSCDE::TECSModel.round_length_val(@offset + x_inc)
      # p "offs=#{offs} x=#{x} w=#{w}"
      if offs < 0 || offs > w
        return
      end
      y_inc = 0
    end
    @offset = offs
    moved_edge(x_inc, x_inc, y_inc, y_inc)
  end
end

#moved_edge(x_inc_l, x_inc_r, y_inc_t, y_inc_b) ⇒ Object

TmPort#moved_edge

moved cell’s edge x_inc_l::Float : left edge moved, value is incremental x_inc_r::Float : right edge moved, value is incremental y_inc_t::Float : top edge moved, value is incremental y_inc_b::Float : bottom edge moved, value is incremental



96
97
98
99
100
101
102
103
104
105
# File 'lib/tecscde/tecs_model/tm_port.rb', line 96

def moved_edge(x_inc_l, x_inc_r, y_inc_t, y_inc_b)
  case @edge_side
  when EDGE_TOP, EDGE_LEFT
    moved(x_inc_l, y_inc_t)
  when EDGE_BOTTOM
    moved(x_inc_l, y_inc_b)
  when EDGE_RIGHT
    moved(x_inc_r, y_inc_t)
  end
end

#owner_cellObject

TmPort#owner_cell



227
228
229
230
231
232
233
234
235
# File 'lib/tecscde/tecs_model/tm_port.rb', line 227

def owner_cell
  if @owner.is_a?(TECSCDE::TECSModel::TmCell)
    @owner
  elsif @owner.is_a?(TECSCDE::TECSModel::TmPortArray)
    @owner.owner
  else
    raise "unknown cell"
  end
end

#set_position(edge_side, offset) ⇒ Object

TmPort#set_position



198
199
200
201
202
203
# File 'lib/tecscde/tecs_model/tm_port.rb', line 198

def set_position(edge_side, offset)
  modified do
    @edge_side = edge_side
    @offset = TECSCDE::TECSModel.round_length_val(offset)
  end
end

#set_subscript(subscript) ⇒ Object



186
187
188
189
190
# File 'lib/tecscde/tecs_model/tm_port.rb', line 186

def set_subscript(subscript)
  modified do
    @subscript = subscript
  end
end