inline Port.setstate; remove unused network codes
This commit is contained in:
16
sim/port.lua
16
sim/port.lua
@@ -15,7 +15,7 @@ PortDirections = {
|
||||
|
||||
Port = {}
|
||||
|
||||
function Port.new(type, direction, position, causeupdate)
|
||||
function Port.new(type, direction, position, causeupdate, idx)
|
||||
local o = {
|
||||
type = type,
|
||||
direction = direction,
|
||||
@@ -24,22 +24,11 @@ function Port.new(type, direction, position, causeupdate)
|
||||
state = false,
|
||||
gate = nil,
|
||||
group = nil,
|
||||
idx = idx,
|
||||
}
|
||||
return o
|
||||
end
|
||||
|
||||
function Port.setstate(port, state) -- output state
|
||||
if state ~= port.state then
|
||||
local group = port.group
|
||||
group.state_num = group.state_num - (port.state and 1 or 0) + (state and 1 or 0)
|
||||
port.state = state
|
||||
|
||||
if (group.state_num>0) ~= group.state then
|
||||
Simulation.queuegroup(GSim, group)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Port.getconnectionposition(port)
|
||||
local offset = PortDirections[port.direction]
|
||||
return {port.position[1]+offset[1], port.position[2]+offset[2], port.position[3]+offset[3]}
|
||||
@@ -69,6 +58,7 @@ end
|
||||
|
||||
function Port.setgroup(port, group)
|
||||
port.group = group
|
||||
Port.getgate(port).port_nets[port.idx] = group
|
||||
end
|
||||
|
||||
function Port.getgroup(port)
|
||||
|
||||
Reference in New Issue
Block a user