inline Port.setstate; remove unused network codes

This commit is contained in:
Redo0
2021-05-25 20:37:29 -05:00
parent c62d7340b0
commit 09e65faec4
5 changed files with 18 additions and 32 deletions

View File

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