Skip to content

Commit

Permalink
Bug fix in multisimulation.
Browse files Browse the repository at this point in the history
  • Loading branch information
zekeriya.sari committed Apr 30, 2021
1 parent 2b8de36 commit 0f148bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Causal"
uuid = "c45f814d-238a-4fdc-b3d7-673e55950ac7"
authors = ["Zekeriya Sarı <zekeriya.sari@deu.edu.tr>", "Serkan Günel <serkan.gunel@deu.edu.tr>"]
version = "0.3.1"
version = "0.3.2"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
37 changes: 18 additions & 19 deletions src/components/sinks/sinks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,34 @@ macro def_sink(ex)
:( buflen::Int = 64 ),
:( plugin::$PLUGIN_TYPE_SYMBOL = nothing ),
:( timebuf::$TIMEBUF_TYPE_SYMBOL = Buffer(buflen) ),
:( databuf::$DATABUF_TYPE_SYMBOL = Causal.construct_sink_buffers(input, buflen) ),
:( sinkcallback::$SINK_CALLBACK_TYPE_SYMBOL =
Causal.construct_sink_callback(databuf, timebuf, plugin, action, id) ),
:( databuf::$DATABUF_TYPE_SYMBOL = length(input) == 1 ? Buffer(buflen) : Buffer(length(input), buflen) ),
:( sinkcallback::$SINK_CALLBACK_TYPE_SYMBOL = plugin === nothing ?
Callback(sink->ishit(databuf), sink->action(sink, outbuf(timebuf), outbuf(databuf)), true, id) :
Callback(sink->ishit(databuf), sink->action(sink, outbuf(timebuf), plugin.process(outbuf(databuf))), true, id) ),
])
quote
Base.@kwdef $ex
end |> esc
end

# FIXME: Buffer types are not compatible for callbacks. Revise the buffer types.
# FIXME: When this bug is fixed, revise also the read method to read data files.
function construct_sink_buffers(input, buflen)
T = datatype(input)
n = length(input)
n == 1 ? Buffer(T, buflen) : [Buffer(T, buflen) for i in 1 : n]
end
# function construct_sink_buffers(input, buflen)
# T = datatype(input)
# n = length(input)
# n == 1 ? Buffer(T, buflen) : [Buffer(T, buflen) for i in 1 : n]
# end

construct_sink_callback(databuf::Buffer, timebuf, plugin::Nothing, action, id) =
Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), reverse(databuf.output)), true, id)
# construct_sink_callback(databuf::Buffer, timebuf, plugin::Nothing, action, id) =
# Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), reverse(databuf.output)), true, id)

construct_sink_callback(databuf::AbstractVector{<:Buffer}, timebuf, plugin::Nothing, action, id) =
Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), hcat([reverse(buf.output) for buf in databuf]...)), true, id)
# construct_sink_callback(databuf::AbstractVector{<:Buffer}, timebuf, plugin::Nothing, action, id) =
# Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), hcat([reverse(buf.output) for buf in databuf]...)), true, id)

construct_sink_callback(databuf::Buffer, timebuf, plugin::AbstractPlugin, action, id) =
Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), plugin.process(reverse(databuf.output))), true, id)
# construct_sink_callback(databuf::Buffer, timebuf, plugin::AbstractPlugin, action, id) =
# Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), plugin.process(reverse(databuf.output))), true, id)

construct_sink_callback(databuf::AbstractVector{<:Buffer}, timebuf, plugin::AbstractPlugin, action, id) =
Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), plugin.process(hcat([reverse(buf.output) for buf in databuf]...))),
true, id)
# construct_sink_callback(databuf::AbstractVector{<:Buffer}, timebuf, plugin::AbstractPlugin, action, id) =
# Callback(sink->ishit(timebuf), sink->action(sink, reverse(timebuf.output), plugin.process(hcat([reverse(buf.output) for buf in databuf]...))),
# true, id)


##### Define sink library
Expand Down

0 comments on commit 0f148bf

Please sign in to comment.